Slave_SQL_Running_State: Slave has read all> Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
ERROR:
No query specified
master建立测试库
mysql> create database db1;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.3.%'> Query OK, 0 rows affected (0.29 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql>
三、安装mycat
1.安装Java
提示:mycat正常应该独立一台机器
共3台主机
master(172.16.3.226),
slave(172.16.3.228),
mycat(172.16.3.229)
jdk-8u144-linux-x64.tar.gz
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
# cd /opt/
# tar zxvf jdk-8u144-linux-x64.tar.gz
# rm -rf jdk-8u144-linux-x64.tar.gz
# vi /etc/profile
### normal add stand alone ###
export JAVA_HOME=/opt/jdk1.8.0_144
export JRE_HOME=$JAVA_HOME/jre
export> export PATH=$PATH:$JAVA_HOME/bin
[root@masterdb ~]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
[root@masterdb ~]#
2.安装mycat
# cd /opt
Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
官网地址:http://dl.mycat.io/1.6-RELEASE/
# tar -xvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
# rm -rf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
# groupadd mycat
# useradd -g mycat mycat
# chown -R mycat:mycat mycat/
3.mycat 登录流程
firewall--> user (logical user)--> schemas(logical db) -->
dataNode(physical db/logical host) --> dataHost(logical host)
-->writeHost or readHost(physical host)
# cd /opt/mycat/conf/
# vi server.xml
.......
.......
.......
mycat123456
TESTDB
[root@mycat conf]# more schema.xml
select user()
[root@mycat conf]#
# vi /etc/profile
export MYCAT_HOME=/opt/mycat
export PATH=$MYCAT_HOME/bin:$PATH:$JAVA_HOME/bin
4.安装MySQL软件
# cd /opt
# tar zxvf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
# mv mysql-5.6.37-linux-glibc2.12-x86_64 mysql-5.6.37
# vi /etc/profile
export JAVA_HOME=/opt/jdk1.8.0_144
export JRE_HOME=$JAVA_HOME/jre
export> export MYCAT_HOME=/opt/mycat
export MYSQL_HOME=/opt/mysql-5.6.37
export PATH=$MYCAT_HOME/bin:$PATH:$JAVA_HOME/bin:$MYSQL_HOME/bin
5.启动mycat
[root@masterdb ~]# mycat start
Starting Mycat-server...
[root@masterdb ~]#
6.测试使用
[root@mycat conf]# mysql -u mycat -h 172.16.3.229 -P 8066 -pmycat123456 -D TESTDB
Warning: Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection> Server version: 5.6.29-mycat-1.6-RELEASE-20161028204710 MyCat Server (OpenCloundDB)
Copyright (c) 2000, 2017, 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> select * from t1;
Empty set (0.28 sec)
mysql> insert into t1 values(1,'Peter'),(2,'Chris');
Query OK, 2 rows affected (0.06 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from t1;
+------+-------+
|> +------+-------+
| 1 | Peter |
| 2 | Chris |
+------+-------+
2 rows in set (0.01 sec)
mysql>