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. jvm回收器回收过程一:CMS和 G1的初认知(持续更新中)

    CMS:介绍: 1.CMS(Concurrent Mark-Sweep)是以牺牲吞吐量为代价来获得最短回收停顿时间的垃圾回收器.对于要求服务器响应速度的应用上,这种垃圾回收器非常适合. 在启动JVM参 ...

  2. Mybatis 搭建遇到的坑

    1. <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC " ...

  3. 为什么企业需要IT资产管理

    为什么企业需要IT资产管理 为什么企业需要IT资产管理?其实这个问题,如同企业为什么要管理一样重要. 企业需要管理.因为有了管理,人.物可尽其用,在不同的位置.角色上发挥作用,然后按照一定的运维规则, ...

  4. oracle 导出某用户下的表

    exp test/test@orcl owner=test file=E:/all.dmp

  5. springCloud配置本地配中心SpringCloudConfig

    多环境配置 在一般开发过程中如果调试都在本地进行,则可以设置一个多环境配置,在本地与线上配置间来回切换. springcloud默认会访问的配置文件名是application.properties, ...

  6. 论坛短信息(JSP项目)

    if("list".equals(action)){ String username = request.getSession().getAttribute("login ...

  7. Angular4.0.0正式发布,附新特性及升级指南

    本文首发地址:Angular4.0.0正式发布,附新特性及升级指南 作者|孙薇 编辑|尾尾 经历了6个RC版本之后,Angular项目组终于发布了新版,即正式版 Angular 4.0.0.新版的 A ...

  8. 马凯军201771010116《面向对象程序设计Java》第八周学习总结

    一,理论知识学习部分 6.1.1 接口概念 两种含义:一,Java接口,Java语言中存在的结构,有特定的语法和结构:二,一个类所具有的方法的特征集合,是一种逻辑上的抽象.前者叫做“Java接口”,后 ...

  9. 马凯军201771010116《面向对象程序设计(java)》第四周学习总结

    第一部分:理论知识学习部分 第四章 1.类与对象的基础概念. 对象:即数据,对象有三个特性:行为 .状态.标识. 类是对象,事物的描述和抽象,是具有相同属性和行为的对象集合.对象则是该类事物的实例. ...

  10. 使用RTL-SDR打开车门

    在最近几年,入侵汽车在当代社会的黑客圈中成为热点,很多文章表明汽车产业还有很多东西等待完善,在本篇文章中,我会让你熟悉我一直研究的一些概念,以及如何在网状网络中使用一些便宜的部件渗透远程开门系统. 软 ...