mycat的安装及部署
mycat的安装及部署
部署jdk环境
检查现有版本JDK
# java -version
查找java相关文件并卸载
rpm -qa | grep java
[root@localhost local]# rpm -qa | grep java
subversion-javahl-1.6.11-9.el6_4.x86_64
ant-javamail-1.7.1-13.el6.x86_64
java-1.6.0-openjdk-javadoc-1.6.0.0-1.66.1.13.0.el6.x86_64
java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
java-1.6.0-openjdk-devel-1.6.0.0-1.66.1.13.0.el6.x86_64
libvirt-java-0.4.9-1.el6.noarch
eclipse-mylyn-java-3.4.2-9.el6.x86_64
lpg-java-compat-1.1.0-4.1.el6.noarch
pki-java-tools-9.0.3-32.el6.noarch
tzdata-java-2013g-1.el6.noarch
java_cup-0.10k-5.el6.x86_64
libvirt-java-devel-0.4.9-1.el6.noarch
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
java-1.7.0-openjdk-devel-1.7.0.45-2.4.3.3.el6.x86_64
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
[root@localhost local]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
[root@localhost local]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
rpm -ivh jdk-8u71-linux-x64.rpm
将java命令加入到环境变量中
vim /etc/profile
//添加内容
JAVA_HOME=/usr/java/jdk1.8.0_71
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
//使配置立即生效
# source /etc/profile
//查看PATH
# echo $PATH
3、配置mycat中的jdk文件路径
# cd /usr/local/mycat/conf/
# vim wrapper.conf
# Java Application
wrapper.java.command=/usr/java/jdk1.7.0_79/bin/java
mycat的安装及部署
tar xf Mycat-Server-1.4-RC-Linux-RW-20150724.tar.gz
cd /usr/local/mycat/conf/
vi /usr/local/mycat/conf/wrapper.conf
wrapper.java.command=/usr/java/jdk1.8.0_71/bin/java
[root@yqy103 conf]# cd /usr/local/mycat/conf
[root@yqy103 conf]# cp schema.xml schema.xml.bak
[root@yqy103 conf]# vim schema.xml
4、读写分离配置(重点配置):
# cp schema.xml schema.xml.bak
# vim schema.xml
<schema name="TD_OA" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
<dataNode name="dn1" dataHost="localhost1" database="TD_OA" />
<dataNode name="dn2" dataHost="localhost1" database="TD_OA" />
<dataNode name="dn3" dataHost="localhost1" database="TD_OA" />
<!--<dataNode name="dn4" dataHost="sequoiadb1" database="SAMPLE" />
<dataNode name="jdbc_dn1" dataHost="jdbchost" database="db1" />
<dataNode name="jdbc_dn2" dataHost="jdbchost" database="db2" />
<dataNode name="jdbc_dn3" dataHost="jdbchost" database="db3" /> -->
<dataHost name="localhost1" 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="hostM1" url="192.168.8.60:3306" user="mycat"
password="pass">
<!-- can have multi read hosts -->
<readHost host="hostS1" url="192.168.11.145:3306" user="mycat_r" password="pass" />
</writeHost>
</dataHost>
(1)<schema name="TD_OA" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
这里的TD_OA就是我们所宣称的数据库名称,必须和server.xml中的用户指定的数据库名称一致。添加一个dataNode="dn1",是指定了我们这个库只有在dn1上,没有分库。
(2)<dataNode name="dn1" dataHost="localhost1" database="TD_OA" />
这里只需要改database的名字,TD_OA就是你真是的数据库上的数据库名,可根据自己的数据库名称修改。
(3) <dataHost name="localhost1" maxCon="1000" minCon="10" balance="1"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
需要配置的位置:
balance="1" writeType="0" switchType="1"
balance
1、balance=0 不开启读写分离机制,所有读操作都发送到当前可用的writehostle .
2、balance=1 全部的readhost与stand by writeHost 参与select语句的负载均衡。简单的说,双主双从模式(M1àS1,M2àS2,并且M1和M2互为主备),正常情况下,M1,S1,S2都参与select语句的复杂均衡。
3、balance=2 所有读操作都随机的在readhost和writehost上分发
writeType
负载均衡类型,目前的取值有3种:
1、writeType="0", 所有写操作发送到配置的第一个writeHost。
2、writeType="1",所有写操作都随机的发送到配置的writeHost。
3、writeType="2",不执行写操作。
switchType
1、switchType=-1 表示不自动切换
2、switchType=1 默认值,自动切换
3、switchType=2 基于MySQL 主从同步的状态决定是否切换
(4)<writeHost host="hostM1" url="192.168.8.60:3306" user="mycat" password="pass">
<!? can have multi read hosts ?>
<readHost host="hostS1" url="192.168.11.145:3306" user="mycat_r" password="pass" />
注意:
这里配置的是读写服务器的IP地址和端口访问,访问的用户名和密码;而且一定要先在客户端测试OK了以后在进行配置。
5、将mycat命令加入到配置文件中
# vim /etc/profile
export PATH=/usr/local/mycat/bin:$PATH
# source /etc/profile
6、创建管理用户
主库上对mycat用户授权如下:
用户:mycat 密码:pass 端口:3306
权限:insert,delete,update,select
命令:grant insert,delete,update,select on TD_OA.* to mycat@'192.168.8.%' identified by 'pass';
flush privileges;
从库上mycat_r用户授权如下:
用户:mycat_r 密码:pass 端口:3306
权限: select
grant select on TD_OA.* to mycat_r@'192.168.8.%' identified by 'pass';
flush privileges;
提示:由于主库和从库是同步mysql数据库复制的,所以从库上的mycat用户会自动和主库的一致,即无法实现只读select的授权
revoke insert,update,delete on TD_OA.* from mycat@'192.168.8.%'; #<=回收insert update delete 权限
修改mycat配置文件
vim /usr/local/mycat/conf/server.xml
<user name="mycat">
<property name="password">pass</property>
<property name="schemas">TD_OA</property>
</user>
<user name="mycat_r">
<property name="password">pass</property>
<property name="schemas">TD_OA</property>
<property name="readOnly">true</property>
</user>
注意:
①这里配置的是可以连接主库的两个用户
用户:mycat 密码:pass 给予此用户TD_OA数据库增删改查的权限。
用户:mycat_r 密码:pass 给予此用户TD_OA数据库读的权限。
②这里的TD_OA,不一定是你数据库上的真实库名,可以任意指定,只要接下来和schema.xml的配置文件的库名统一即可。
Running Mycat-server...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
wrapper | JVM exited while loading the application.
jvm 1 | Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: oawebserver002: oawebserver002: Temporary failure in name resolution
解决:编辑Hosts文件将主机名和IP绑定
# vim /etc/hosts
192.168.8.60 oawebserver002
# mycat restart使配置生效
在客户端连接mysql主库服务器:
# yum install -y mysql
# mysql -umycat -ppass -h192.168.8.60 -P8066
8、管理命令与监控
mycat自身有类似其他数据库的管理监控方式,可通过mysql命令行,登陆端口9066执行相应的SQL操作,也可通过jdbc的方式进行远程连接管理。
登录:目前mycat有两个端口,8066数据端口,9066管理端口。命令行登录时通过9066管理端口来执行:
mysql -umycat -ppass -h127.0.0.1 -P9066 -DTD_OA
选项:
-h 后面接主机
-u mycat server.xml配置的逻辑库用户
-p mycat server.xml配置的逻辑库密码
-P 后面接的端口9066,注意P大写
-D Mycat server.xml中配置的逻辑库
1、查看所有的命令,如下:
mysql> show @@help;
+--------------------------------------+-----------------------------------+
| STATEMENT | DESCRIPTION |
+--------------------------------------+-----------------------------------+
| clear @@slow where datanode = ? | Clear slow sql by datanode |
| clear @@slow where schema = ? | Clear slow sql by schema |
| kill @@connection id1,id2,... | Kill the specified connections |
| offline | Change MyCat status to OFF |
| online | Change MyCat status to ON |
| 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 |
| rollback @@config | Rollback all config from memory |
| rollback @@route | Rollback route config from memory |
| rollback @@user | Rollback user config from memory |
| show @@backend | Report backend connection status |
| show @@cache | Report system cache usage |
| show @@command | Report commands status |
| show @@connection | Report connection status |
| show @@connection.sql | Report connection sql |
| 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 @@heartbeat | Report heartbeat status |
| show @@parser | Report parser status |
| show @@processor | Report processor status |
| show @@router | Report router status |
| show @@server | Report server status |
| show @@session | Report front session details |
| show @@slow where datanode = ? | Report datanode slow sql |
| show @@slow where schema = ? | Report schema slow sql |
| show @@sql where id = ? | Report specify SQL |
| show @@sql.detail where id = ? | Report execute detail status |
| show @@sql.execute | Report execute status |
| show @@sql.slow | Report slow SQL |
| show @@threadpool | Report threadPool status |
| show @@time.current | Report current timestamp |
| show @@time.startup | Report startup timestamp |
| show @@version | Report Mycat Server version |
| stop @@heartbeat name:time | Pause dataNode heartbeat |
| switch @@datasource name:index | Switch dataSource |
+--------------------------------------+-----------------------------------+
40 rows in set (0.01 sec)
2、显示mycat数据库的列表,对应的在scehma.xml配置的逻辑库
mysql> show @@databases;
+----------+
| DATABASE |
+----------+
| TD_OA |
+----------+
1 row in set (0.00 sec)
3、显示mycat数据节点的列表,对应的是scehma.xml配置文件的dataNode节点
mysql> show @@datanode;
+------+------------------+-------+-------+--------+------+------+---------+------------+----------+---------+---------------+
| NAME | DATHOST | INDEX | TYPE | ACTIVE | IDLE | SIZE | EXECUTE | TOTAL_TIME | MAX_TIME | MAX_SQL | RECOVERY_TIME |
+------+------------------+-------+-------+--------+------+------+---------+------------+----------+---------+---------------+
| dn1 | localhost1/TD_OA | 0 | mysql | 0 | 10 | 1000 | 10 | 0 | 0 | 0 | -1 |
| dn2 | localhost1/TD_OA | 0 | mysql | 0 | 10 | 1000 | 10 | 0 | 0 | 0 | -1 |
| dn3 | localhost1/TD_OA | 0 | mysql | 0 | 10 | 1000 | 10 | 0 | 0 | 0 | -1 |
+------+------------------+-------+-------+--------+------+------+---------+------------+----------+---------+---------------+
其中,NAME表示datanode的名称;dataHost 对应的是dataHost属性的值,数据主机的名称,ACTIVE表示活跃的连接数,IDIE表示闲置的连接数,SIZE对应的是总连接的数量。
mysql> show @@heartbeat;
+--------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
| NAME | TYPE | HOST | PORT | RS_CODE | RETRY | STATUS | TIMEOUT | EXECUTE_TIME | LAST_ACTIVE_TIME | STOP |
+--------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
| hostM1 | mysql | 192.168.8.60 | 3306 | 1 | 0 | idle | 0 | 0,0,0 | 2016-04-22 19:19:05 | false |
| hostS1 | mysql | 192.168.11.145 | 3306 | 1 | 0 | idle | 0 | 0,0,0 | 2016-04-22 19:19:05 | false |
+--------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
RS_CODE状态为1,正常状态
4、获取当前mycat的版本
mysql> show @@version;
5、显示mycat前端连接状态
mysql> show @@connection;
6、显示mycat后端连接状态
mysql> show @@backend;
7、显示数据源
mysql> show @@datasource;
特别说明:
reload @@config,这个命令在执行的时候,mycat服务不可用,防止提交的事物出错。
部署jdk环境
检查现有版本JDK
# java -version
查找java相关文件并卸载
rpm -qa | grep java
[root@localhost local]# rpm -qa | grep java
subversion-javahl-1.6.11-9.el6_4.x86_64
ant-javamail-1.7.1-13.el6.x86_64
java-1.6.0-openjdk-javadoc-1.6.0.0-1.66.1.13.0.el6.x86_64
java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
java-1.6.0-openjdk-devel-1.6.0.0-1.66.1.13.0.el6.x86_64
libvirt-java-0.4.9-1.el6.noarch
eclipse-mylyn-java-3.4.2-9.el6.x86_64
lpg-java-compat-1.1.0-4.1.el6.noarch
pki-java-tools-9.0.3-32.el6.noarch
tzdata-java-2013g-1.el6.noarch
java_cup-0.10k-5.el6.x86_64
libvirt-java-devel-0.4.9-1.el6.noarch
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
java-1.7.0-openjdk-devel-1.7.0.45-2.4.3.3.el6.x86_64
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
[root@localhost local]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
[root@localhost local]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
rpm -ivh jdk-8u71-linux-x64.rpm
将java命令加入到环境变量中
vim /etc/profile
//添加内容
JAVA_HOME=/usr/java/jdk1.8.0_71
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
//使配置立即生效
# source /etc/profile
//查看PATH
# echo $PATH
3、配置mycat中的jdk文件路径
# cd /usr/local/mycat/conf/
# vim wrapper.conf
# Java Application
wrapper.java.command=/usr/java/jdk1.7.0_79/bin/java
mycat的安装及部署
tar xf Mycat-Server-1.4-RC-Linux-RW-20150724.tar.gz
cd /usr/local/mycat/conf/
vi /usr/local/mycat/conf/wrapper.conf
wrapper.java.command=/usr/java/jdk1.8.0_71/bin/java
[root@yqy103 conf]# cd /usr/local/mycat/conf
[root@yqy103 conf]# cp schema.xml schema.xml.bak
[root@yqy103 conf]# vim schema.xml
4、读写分离配置(重点配置):
# cp schema.xml schema.xml.bak
# vim schema.xml
<schema name="TD_OA" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
<dataNode name="dn1" dataHost="localhost1" database="TD_OA" />
<dataNode name="dn2" dataHost="localhost1" database="TD_OA" />
<dataNode name="dn3" dataHost="localhost1" database="TD_OA" />
<!--<dataNode name="dn4" dataHost="sequoiadb1" database="SAMPLE" />
<dataNode name="jdbc_dn1" dataHost="jdbchost" database="db1" />
<dataNode name="jdbc_dn2" dataHost="jdbchost" database="db2" />
<dataNode name="jdbc_dn3" dataHost="jdbchost" database="db3" /> -->
<dataHost name="localhost1" 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="hostM1" url="192.168.8.60:3306" user="mycat"
password="pass">
<!-- can have multi read hosts -->
<readHost host="hostS1" url="192.168.11.145:3306" user="mycat_r" password="pass" />
</writeHost>
</dataHost>
(1)<schema name="TD_OA" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
这里的TD_OA就是我们所宣称的数据库名称,必须和server.xml中的用户指定的数据库名称一致。添加一个dataNode="dn1",是指定了我们这个库只有在dn1上,没有分库。
(2)<dataNode name="dn1" dataHost="localhost1" database="TD_OA" />
这里只需要改database的名字,TD_OA就是你真是的数据库上的数据库名,可根据自己的数据库名称修改。
(3) <dataHost name="localhost1" maxCon="1000" minCon="10" balance="1"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
需要配置的位置:
balance="1" writeType="0" switchType="1"
balance
1、balance=0 不开启读写分离机制,所有读操作都发送到当前可用的writehostle .
2、balance=1 全部的readhost与stand by writeHost 参与select语句的负载均衡。简单的说,双主双从模式(M1àS1,M2àS2,并且M1和M2互为主备),正常情况下,M1,S1,S2都参与select语句的复杂均衡。
3、balance=2 所有读操作都随机的在readhost和writehost上分发
writeType
负载均衡类型,目前的取值有3种:
1、writeType="0", 所有写操作发送到配置的第一个writeHost。
2、writeType="1",所有写操作都随机的发送到配置的writeHost。
3、writeType="2",不执行写操作。
switchType
1、switchType=-1 表示不自动切换
2、switchType=1 默认值,自动切换
3、switchType=2 基于MySQL 主从同步的状态决定是否切换
(4)<writeHost host="hostM1" url="192.168.8.60:3306" user="mycat" password="pass">
<!? can have multi read hosts ?>
<readHost host="hostS1" url="192.168.11.145:3306" user="mycat_r" password="pass" />
注意:
这里配置的是读写服务器的IP地址和端口访问,访问的用户名和密码;而且一定要先在客户端测试OK了以后在进行配置。
5、将mycat命令加入到配置文件中
# vim /etc/profile
export PATH=/usr/local/mycat/bin:$PATH
# source /etc/profile
6、创建管理用户
主库上对mycat用户授权如下:
用户:mycat 密码:pass 端口:3306
权限:insert,delete,update,select
命令:grant insert,delete,update,select on TD_OA.* to mycat@'192.168.8.%' identified by 'pass';
flush privileges;
从库上mycat_r用户授权如下:
用户:mycat_r 密码:pass 端口:3306
权限: select
grant select on TD_OA.* to mycat_r@'192.168.8.%' identified by 'pass';
flush privileges;
提示:由于主库和从库是同步mysql数据库复制的,所以从库上的mycat用户会自动和主库的一致,即无法实现只读select的授权
revoke insert,update,delete on TD_OA.* from mycat@'192.168.8.%'; #<=回收insert update delete 权限
修改mycat配置文件
vim /usr/local/mycat/conf/server.xml
<user name="mycat">
<property name="password">pass</property>
<property name="schemas">TD_OA</property>
</user>
<user name="mycat_r">
<property name="password">pass</property>
<property name="schemas">TD_OA</property>
<property name="readOnly">true</property>
</user>
注意:
①这里配置的是可以连接主库的两个用户
用户:mycat 密码:pass 给予此用户TD_OA数据库增删改查的权限。
用户:mycat_r 密码:pass 给予此用户TD_OA数据库读的权限。
②这里的TD_OA,不一定是你数据库上的真实库名,可以任意指定,只要接下来和schema.xml的配置文件的库名统一即可。
7、启动mycat
# mycat console #<=通过console命令启动mycat,这样方便提取信息Running Mycat-server...
wrapper | --> Wrapper Started as Console
wrapper | Launching a JVM...
wrapper | JVM exited while loading the application.
jvm 1 | Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: oawebserver002: oawebserver002: Temporary failure in name resolution
解决:编辑Hosts文件将主机名和IP绑定
# vim /etc/hosts
192.168.8.60 oawebserver002
# mycat restart使配置生效
在客户端连接mysql主库服务器:
# yum install -y mysql
# mysql -umycat -ppass -h192.168.8.60 -P8066
8、管理命令与监控
mycat自身有类似其他数据库的管理监控方式,可通过mysql命令行,登陆端口9066执行相应的SQL操作,也可通过jdbc的方式进行远程连接管理。
登录:目前mycat有两个端口,8066数据端口,9066管理端口。命令行登录时通过9066管理端口来执行:
mysql -umycat -ppass -h127.0.0.1 -P9066 -DTD_OA
选项:
-h 后面接主机
-u mycat server.xml配置的逻辑库用户
-p mycat server.xml配置的逻辑库密码
-P 后面接的端口9066,注意P大写
-D Mycat server.xml中配置的逻辑库
1、查看所有的命令,如下:
mysql> show @@help;
+--------------------------------------+-----------------------------------+
| STATEMENT | DESCRIPTION |
+--------------------------------------+-----------------------------------+
| clear @@slow where datanode = ? | Clear slow sql by datanode |
| clear @@slow where schema = ? | Clear slow sql by schema |
| kill @@connection id1,id2,... | Kill the specified connections |
| offline | Change MyCat status to OFF |
| online | Change MyCat status to ON |
| 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 |
| rollback @@config | Rollback all config from memory |
| rollback @@route | Rollback route config from memory |
| rollback @@user | Rollback user config from memory |
| show @@backend | Report backend connection status |
| show @@cache | Report system cache usage |
| show @@command | Report commands status |
| show @@connection | Report connection status |
| show @@connection.sql | Report connection sql |
| 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 @@heartbeat | Report heartbeat status |
| show @@parser | Report parser status |
| show @@processor | Report processor status |
| show @@router | Report router status |
| show @@server | Report server status |
| show @@session | Report front session details |
| show @@slow where datanode = ? | Report datanode slow sql |
| show @@slow where schema = ? | Report schema slow sql |
| show @@sql where id = ? | Report specify SQL |
| show @@sql.detail where id = ? | Report execute detail status |
| show @@sql.execute | Report execute status |
| show @@sql.slow | Report slow SQL |
| show @@threadpool | Report threadPool status |
| show @@time.current | Report current timestamp |
| show @@time.startup | Report startup timestamp |
| show @@version | Report Mycat Server version |
| stop @@heartbeat name:time | Pause dataNode heartbeat |
| switch @@datasource name:index | Switch dataSource |
+--------------------------------------+-----------------------------------+
40 rows in set (0.01 sec)
2、显示mycat数据库的列表,对应的在scehma.xml配置的逻辑库
mysql> show @@databases;
+----------+
| DATABASE |
+----------+
| TD_OA |
+----------+
1 row in set (0.00 sec)
3、显示mycat数据节点的列表,对应的是scehma.xml配置文件的dataNode节点
mysql> show @@datanode;
+------+------------------+-------+-------+--------+------+------+---------+------------+----------+---------+---------------+
| NAME | DATHOST | INDEX | TYPE | ACTIVE | IDLE | SIZE | EXECUTE | TOTAL_TIME | MAX_TIME | MAX_SQL | RECOVERY_TIME |
+------+------------------+-------+-------+--------+------+------+---------+------------+----------+---------+---------------+
| dn1 | localhost1/TD_OA | 0 | mysql | 0 | 10 | 1000 | 10 | 0 | 0 | 0 | -1 |
| dn2 | localhost1/TD_OA | 0 | mysql | 0 | 10 | 1000 | 10 | 0 | 0 | 0 | -1 |
| dn3 | localhost1/TD_OA | 0 | mysql | 0 | 10 | 1000 | 10 | 0 | 0 | 0 | -1 |
+------+------------------+-------+-------+--------+------+------+---------+------------+----------+---------+---------------+
其中,NAME表示datanode的名称;dataHost 对应的是dataHost属性的值,数据主机的名称,ACTIVE表示活跃的连接数,IDIE表示闲置的连接数,SIZE对应的是总连接的数量。
mysql> show @@heartbeat;
+--------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
| NAME | TYPE | HOST | PORT | RS_CODE | RETRY | STATUS | TIMEOUT | EXECUTE_TIME | LAST_ACTIVE_TIME | STOP |
+--------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
| hostM1 | mysql | 192.168.8.60 | 3306 | 1 | 0 | idle | 0 | 0,0,0 | 2016-04-22 19:19:05 | false |
| hostS1 | mysql | 192.168.11.145 | 3306 | 1 | 0 | idle | 0 | 0,0,0 | 2016-04-22 19:19:05 | false |
+--------+-------+----------------+------+---------+-------+--------+---------+--------------+---------------------+-------+
RS_CODE状态为1,正常状态
4、获取当前mycat的版本
mysql> show @@version;
5、显示mycat前端连接状态
mysql> show @@connection;
6、显示mycat后端连接状态
mysql> show @@backend;
7、显示数据源
mysql> show @@datasource;
特别说明:
reload @@config,这个命令在执行的时候,mycat服务不可用,防止提交的事物出错。
正文到此结束
- 本文标签: 暂无相关标签
- 本文链接: https://www.jimmy2k.top/article/157
- 版权声明: 本文由JimmyZ的个人博客原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权