MyCat详细介绍,请参考https://www.biaodianfu.com/mycat.html

9066管理端口,请参考https://www.cnblogs.com/parryyang/p/5606071.html

1.创建mycat用户

useradd mycat
passwd mycat

2.下载安装包、解压并赋权

wget http://dl.mycat.io/1.6.6.1/Mycat-server-1.6.6.1-release-20181031195535-linux.tar.gz
tar -xzvf Mycat-server-1.6.6.1-release-20181031195535-linux.tar.gz -C /usr/local
chown -R mycat:mycat /usr/local/mycat

3.配置环境变量

vi /etc/profile
增加
## jdk env
JAVA_HOME=/usr/java/jdk1.8.0_192
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
## mycat env
export MYCAT_HOME=/usr/local/mycat
export PATH=$PATH:$MYCAT_HOME/bin
source /etc/profile

4.配置server.xml
vi /usr/local/mycat/conf/server.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mycat:server SYSTEM "server.dtd">
<mycat:server xmlns:mycat="http://io.mycat/">
<system>
<!--
<property name="processors">32</property>
<property name="processorExecutor">32</property>
<property name="bindIp">0.0.0.0</property>
<property name="frontWriteQueueSize">4096</property>
<property name="idleTimeout">300000</property>
<property name="mutiNodePatchSize">100</property>
-->
<property name="defaultSqlParser">druidparser</property>
<property name="mutiNodeLimitType">1</property>
<property name="serverPort">8066</property>
<property name="managerPort">9066</property>
</system>
<!-- 任意设置登陆 mycat 的用户名,密码,数据库 -->
<user name="test">
<property name="password">test</property>
<property name="schemas">TESTDB</property>
</user> <user name="user">
<property name="password">user</property>
<property name="schemas">TESTDB</property>
<property name="readOnly">true</property>
</user>
<!--
<quarantine>
<whitehost>
<host host="127.0.0.1" user="mycat"/>
<host host="127.0.0.2" user="mycat"/>
</whitehost>
<blacklist check="false"></blacklist>
</quarantine>
-->
</mycat:server>

5.配置schema.xml
vi /usr/local/mycat/conf/schema.xml

<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
<!-- 这里不配置,代表所有的表分片到dn1节点-->
</schema>
<dataNode name="dn1" dataHost="dataHost01" database="test" />
<dataHost name="dataHost01" maxCon="1000" minCon="10" balance="1"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<!-- can have multi write hosts -->
<writeHost host="mysql_b1" url="192.168.0.242:3306" user="root" password="abc123">
<!-- can have multi read hosts -->
<readHost host="mysql_b2" url="192.168.0.240:3306" user="root" password="abc123" />
</writeHost>
</dataHost>
</mycat:schema>

6.启动Mycat

mycat start

7.查看mycat启动日志
[root@mycat-server2 data]# mycat console
Running Mycat-server...
Mycat-server is already running.

8.连接MyCat
连接管理端口:

[root@mycat-server2 data]# mysql -h192.168.0.252 -P9066 -utest -ptest
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.6.29-mycat-1.6.6.1-release-20181031195535 MyCat Server (monitor) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 查看所有的可用命令:
mysql> show @@help;
+--------------------------------------------------------------+--------------------------------------------+
| STATEMENT | DESCRIPTION |
+--------------------------------------------------------------+--------------------------------------------+
| show @@time.current | Report current timestamp |
| show @@time.startup | Report startup timestamp |
| show @@version | Report Mycat Server version |
| show @@server | Report server status |
| show @@threadpool | Report threadPool status |
| show @@database | Report databases |
| show @@datanode | Report dataNodes |
| show @@datanode where schema = ? | Report dataNodes |
| show @@datasource | Report dataSources |
| show @@datasource where dataNode = ? | Report dataSources |
| show @@datasource.synstatus | Report datasource data synchronous |
| show @@datasource.syndetail where name=? | Report datasource data synchronous detail |
| show @@datasource.cluster | Report datasource galary cluster variables |
| show @@processor | Report processor status |
| show @@command | Report commands status |
| show @@connection | Report connection status |
| show @@cache | Report system cache usage |
| show @@backend | Report backend connection status | ##显示后端物理库连接信息,包括当前连接数,端口等信息
| show @@session | Report front session details |
| show @@connection.sql | Report connection sql | ## 显示当前前端客户端连接情况
| show @@sql.execute | Report execute status |
| show @@sql.detail where id = ? | Report execute detail status |
| show @@sql | Report SQL list |
| show @@sql.high | Report Hight Frequency SQL |
| show @@sql.slow | Report slow SQL |
| show @@sql.resultset | Report BIG RESULTSET SQL |
| show @@sql.sum | Report User RW Stat |
| show @@sql.sum.user | Report User RW Stat |
| show @@sql.sum.table | Report Table RW Stat |
| show @@parser | Report parser status |
| show @@router | Report router status |
| show @@heartbeat | Report heartbeat status |
| show @@heartbeat.detail where name=? | Report heartbeat current detail |
| show @@slow where schema = ? | Report schema slow sql |
| show @@slow where datanode = ? | Report datanode slow sql |
| show @@sysparam | Report system param |
| show @@syslog limit=? | Report system mycat.log |
| show @@white | show mycat white host |
| show @@white.set=?,? | set mycat white host,[ip,user] |
| show @@directmemory=1 or 2 | show mycat direct memory usage |
| show @@check_global -SCHEMA= ? -TABLE=? -retry=? -interval=? | check mycat global table consistency |
| switch @@datasource name:index | Switch dataSource |
| kill @@connection id1,id2,... | Kill the specified connections |
| stop @@heartbeat name:time | Pause dataNode heartbeat |
| reload @@config | Reload basic config from file |
| reload @@config_all | Reload all config from file |
| reload @@route | Reload route config from file |
| reload @@user | Reload user config from file |
| reload @@sqlslow= | Set Slow SQL Time(ms) |
| reload @@user_stat | Reset show @@sql @@sql.sum @@sql.slow |
| rollback @@config | Rollback all config from memory |
| rollback @@route | Rollback route config from memory |
| rollback @@user | Rollback user config from memory |
| reload @@sqlstat=open | Open real-time sql stat analyzer |
| reload @@sqlstat=close | Close real-time sql stat analyzer |
| offline | Change MyCat status to OFF |
| online | Change MyCat status to ON |
| clear @@slow where schema = ? | Clear slow sql by schema |
| clear @@slow where datanode = ? | Clear slow sql by datanode |
+--------------------------------------------------------------+--------------------------------------------+
59 rows in set (0.01 sec)
# 查看所有的逻辑数据库:
mysql> show @@database;
+----------+
| DATABASE |
+----------+
| TESTDB |
+----------+
1 row in set (0.00 sec)
# 查看所有的数据节点:
mysql> show @@datanode;
Empty set (0.00 sec) mysql> show @@datasource;
+----------+----------+-------+---------------+------+------+--------+------+------+---------+-----------+------------+
| DATANODE | NAME | TYPE | HOST | PORT | W/R | ACTIVE | IDLE | SIZE | EXECUTE | READ_LOAD | WRITE_LOAD |
+----------+----------+-------+---------------+------+------+--------+------+------+---------+-----------+------------+
| dn1 | mysql_b1 | mysql | 192.168.0.242 | 3306 | W | 0 | 10 | 1000 | 6215 | 0 | 2 |
| dn1 | mysql_b2 | mysql | 192.168.0.240 | 3306 | R | 0 | 9 | 1000 | 6299 | 84 | 0 |
+----------+----------+-------+---------------+------+------+--------+------+------+---------+-----------+------------+
2 rows in set (0.00 sec) mysql> quit
Bye

连接数据操作端口:

[root@mycat-server2 data]# mysql -h192.168.0.252 -P8066 -utest -ptest
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.6.29-mycat-1.6.6.1-release-20181031195535 MyCat Server (OpenCloudDB) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 可以看见的都是逻辑数据库:
mysql> show databases;
+----------+
| DATABASE |
+----------+
| TESTDB |
+----------+
1 row in set (0.00 sec)
# 使用指定的逻辑数据库:
mysql> use TESTDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
# 查看所有的数据表:
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| member |
| t01 |
| t02 |
| t03 |
+----------------+
4 rows in set (0.03 sec)

参数说明:

-h 后面是主机,即当前 mycat 安装的主机地址,本地可用 127.0.0.1 远程需要远程 ip;
-u Mycat server.xml 中配置的逻辑库用户;
-p Mycat server.xml 中配置的逻辑库密码;
-P 后面是端口 默认 9066,注意 P 是大写;
-d Mycat server.xml 中配置的逻辑库。

9.MyCat操作命令:

启动MyCat: mycat start;
停止MyCat: mycat stop;
前台运行: mycat console;
重启服务: mycat restart;
暂停: mycat pause;
查看启动状态: mycat status;

10.修改log4j的配置

为了让信息启动时更好定位,需要将conf/log4j2.xml的文件修改为debug级别。

附:其他问题
MySQL8.0的客户端连不上Mycat?
解决方案:使用mysql5的客户端可以正常访问,待详细分析

CentOS7.5下安装Mycat连接MySQL8.0的更多相关文章

  1. 个人亲测,在win10系统下安装多实例mysql8.0详细教程

    由于公司的新项目需要导入sql脚本,需要更高版本的mysql数据库,原来的数据库我也不想删除和升级,因此安装了第二个mysql8的实例,废话不多说,步骤如下: 1.下载mysqlGPL版本,我下载的版 ...

  2. Win10环境下安装压缩包版本MySQL-8.0.13

    准备工作 系统环境:Windows 10 1803版本: 压缩包:MySQL-8.0.13 Windows zip包下载: 安装过程 1. 加载安装包到你的安装目录 将下载的MySQL压缩包解压并移到 ...

  3. [C++]_ELVE_Windows下QT5.12连接MySql8.0解决方案

    #0x01 准备 1)要保证QT和MySQL都是一样的位数,我的就是都安装的64位. 2)安装Qt5.12,这里主要提一点,在安装时候,有个选择插件那块,尽量都选上,里面有个database选项,记得 ...

  4. CentOS7.X 下安装MySQL8.0(附文件)

    这是64位的安装包.如果需要32位的可以去官网下载哦.步骤一样 1 获取安装资源包 mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar 链接: https://pan.b ...

  5. CentOS7 Python3下安装 TensorToolbox 1.0.22时的一些错误及解决办法

    CentOS7 Python3下安装 TensorToolbox 1.0.22 (python3) [jiangshan@localhost ~]$ pip install TensorToolbox ...

  6. Centos7.2下安装redis&通用键值命令

    Centos7.2下安装redis&通用键值命令 Centos7.2下安装redis 官方网站:https://redis.io/ 1.进入/usr/local/src/目录 cd /usr/ ...

  7. navicate 连接mysql8.0,个人踩坑问题汇总

    navicate 连接mysql8.0,个人踩坑问题汇总本文目录:1:安装mysql8.0新增全新验证方式,安装如果不修改mysql连接不上2:mysql启动命令问题3:navicate 运程连接My ...

  8. linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦

    linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦(一) 一.Linux下安装MySQL 1.下载 下载地址:http://dev.mysql.co ...

  9. Win10下mysql5.5和mysql8.0.19共存

    Win10下mysql5.5和mysql8.0.19共存 需求:由于之前做的项目用的是mysql5.5,而新接的项目指定用mysql8,需要myql5..5和8同时存在运行. 前提:电脑已经安装mys ...

随机推荐

  1. intellij idea 编译 kafka 源码

    1. 从 GitHub 网站,git clone kafka 源码 2. 下载安装好 gradle,scala 3. 进入 kafka 项目目录,依次执行 gradle wrapper,gradle ...

  2. 2018,ANG发展峰会惊喜来袭

    区块链的分享——ANG发展峰会重大来袭!2018年10月28日 时至今日,区块链技术已经被越来越多的人所熟知.法国著名的高新公司——凡赛公司汇集世界区块链专家,斥巨资打造了行业领先的区块链技术团队,并 ...

  3. Java数组声明、初始化

    维数组的声明方式:type var[]; 或type[] var; 声明数组时不能指定其长度(数组中元素的个数), Java中使用关键字new创建数组对象,格式为:数组名 = new 数组元素的类型 ...

  4. Java语法基础学习DayTwelve(泛型)

    一.泛型(Generic)在集合中的使用 1.作用 (1)解决元素存储的安全问题 (2)解决获取数据元素时,需要类型强转的问题 2.代码案例 //在集合没有使用泛型的情况下 List list = n ...

  5. node.js安装全攻略

    node.js学习也有近一年之久了,自开始以来,能遇到各种问题,就拿安装来说,总能遇到稀奇古怪的问题,但每次谷歌,或者百度,都能找到解决办法,逐渐也就养成了百度或者谷歌的毛病! 正常安装 第一步:下载 ...

  6. Linux运维之shell脚本进阶篇

    一.if语句的使用 1)语法规则 if [条件] then 指令 fi 或 if [条件];then 指令 fi 提示:分号相当于命令换行,上面两种语法等同特殊写法:if[ -f"$file ...

  7. DAY 13 开放封闭原则

    装饰器: 即是用一个函数去拓展另一个函数,同时遵循开放封闭原则 开放封闭原则 对修改关闭,对拓展开放 不允许修改源代码以及调用方式 以下是无参函数的基本格式 def outer(func): def ...

  8. What is the CocoaUI ?

    http://www.cocoaui.com/en https://github.com/ideawu/cocoaui 传统的 iOS 应用由于苹果自身的技术所限, 无法实现丰富的 UI 换皮肤(主题 ...

  9. centos安装VirtualBox增强包VBoxGuestAdditions

    1.如果你的CentOS 版本早于 6,那么需要在 /etc/grub.conf 中添加一行 divider=10,以将这个参数传递给核心,以减少 idle CPU load.   2.#yum up ...

  10. 冒泡排序到k趟

    浙大pat题目 将N个整数按从小到大排序的冒泡排序法是这样工作的:从头到尾比较相邻两个元素,如果前面的元素大于其紧随的后面元素,则交换它们.通过一遍扫描,则最后一个元素必定是最大的元素.然后用同样的方 ...