CentOS7.5下安装Mycat连接MySQL8.0
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的更多相关文章
- 个人亲测,在win10系统下安装多实例mysql8.0详细教程
由于公司的新项目需要导入sql脚本,需要更高版本的mysql数据库,原来的数据库我也不想删除和升级,因此安装了第二个mysql8的实例,废话不多说,步骤如下: 1.下载mysqlGPL版本,我下载的版 ...
- Win10环境下安装压缩包版本MySQL-8.0.13
准备工作 系统环境:Windows 10 1803版本: 压缩包:MySQL-8.0.13 Windows zip包下载: 安装过程 1. 加载安装包到你的安装目录 将下载的MySQL压缩包解压并移到 ...
- [C++]_ELVE_Windows下QT5.12连接MySql8.0解决方案
#0x01 准备 1)要保证QT和MySQL都是一样的位数,我的就是都安装的64位. 2)安装Qt5.12,这里主要提一点,在安装时候,有个选择插件那块,尽量都选上,里面有个database选项,记得 ...
- CentOS7.X 下安装MySQL8.0(附文件)
这是64位的安装包.如果需要32位的可以去官网下载哦.步骤一样 1 获取安装资源包 mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar 链接: https://pan.b ...
- CentOS7 Python3下安装 TensorToolbox 1.0.22时的一些错误及解决办法
CentOS7 Python3下安装 TensorToolbox 1.0.22 (python3) [jiangshan@localhost ~]$ pip install TensorToolbox ...
- Centos7.2下安装redis&通用键值命令
Centos7.2下安装redis&通用键值命令 Centos7.2下安装redis 官方网站:https://redis.io/ 1.进入/usr/local/src/目录 cd /usr/ ...
- navicate 连接mysql8.0,个人踩坑问题汇总
navicate 连接mysql8.0,个人踩坑问题汇总本文目录:1:安装mysql8.0新增全新验证方式,安装如果不修改mysql连接不上2:mysql启动命令问题3:navicate 运程连接My ...
- linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦
linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦(一) 一.Linux下安装MySQL 1.下载 下载地址:http://dev.mysql.co ...
- Win10下mysql5.5和mysql8.0.19共存
Win10下mysql5.5和mysql8.0.19共存 需求:由于之前做的项目用的是mysql5.5,而新接的项目指定用mysql8,需要myql5..5和8同时存在运行. 前提:电脑已经安装mys ...
随机推荐
- AngularJS +Kendo UI Grid template
var dataSource = new kendo.data.DataSource({ transport: { dataType: "json", read: inputUri ...
- Java实现类似eval()函数或exec()函数的功能
一篇参考博客:http://www.cnblogs.com/fangwenyu/archive/2011/10/12/2209051.html 在Python中有一个exec()函数,同样在JavaS ...
- vscode 快捷键
ctrl+/ 单行注释:// 若要多行注释://,先选中这些要注释的行,再按ctrl+/ shift+Alt+A 多行注释 撤销刚才的操作:Ctrl+Z 恢复刚才的操作:Ctrl+Shift+Z ...
- Aop理解 ioc理解
AOP 把 [核心代码]和[非核心代码]分离 提高开发的效率 java设计模式: https://www.cnblogs.com/malihe/p/6891920.html N+1就是: 1:一条查询 ...
- python项目运行环境安装小结
安装最新即可,实际的版本号可能不一样 安装过程较复杂,建议用一台单独的vm安装,能做成docker image最好 基础软件 nginx-1.10.0: sudo apt-get install ng ...
- delete 与 delete []
/* Module: delete与delete[]的区别.cpp Notices: Copyright (c) 2017 Landy Tan */ #include <iostream> ...
- 【IDEA&&Eclipse】1、为何 IntelliJ IDEA 比 Eclipse 更适合于专业java开发者
圣战 有一些没有唯一正确答案的“永恒”的问题,例如哪个更好:是Windows还是Linux,Java还是C#:谁更强壮:Chuck Norris还是Van Damme. 其中的一个圣战便是Java I ...
- vue-cli 安装过程出现错误
如果是这样得错误,那是你在安装sass得问题,需要安装python2,安装好就行了
- nodejs - 1)上传图片 ,并显示 , 2)模块 formidable
1.代码: 1-1: 入口文件: index.js var server = require('./server'); var router = require("./router" ...
- 莫烦tensorflow(8)-CNN
import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#number 1 to 10 dat ...