优点: 读写分离
负载均衡
支持数据的分片自动路由与聚合
安装mycat
1、配置java环境,下载JDK
[root@tomcat1 ~]# tar xf jdk-8u181-linux-x64.tar.gz -C /usr/local/
[root@tomcat1 ~]# ln -s /usr/local/jdk1.8.0_181/ /usr/local/java
[root@tomcat1 ~]# vim /etc/profile
export JAVA_HOME=/usr/local/java
export PATH=PATH:PATH:PATH:JAVA_HOME/bin
[root@tomcat1 ~]# source /etc/profile
[root@tomcat1 ~]# java -version
java version “1.8.0_181”
Java™ SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot™ 64-Bit Server VM (build 25.181-b13, mixed mode)
2、安装mycat
wget http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
tar xf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz -C /usr/local
3、创建库,并且授权给mycat一个账户,在一台主节点上面创建就行
[root@mysql1 ~]# mysql -pQfcloud123.
mysql> create database galera;
mysql> grant all on galera.* to mycat@‘10.30.162.%’ identified by ‘Qfcloud123.’;
mysql> flush privileges;
4、配置mycat(可以部署两台mycat,做keepalived高可用)
[root@proxy1 ~]# cd /usr/local/mycat/conf/
[root@proxy1 conf]# vim server.xml
配置web端访问mycat的账号密码
123456
galera_test 需要对应schema.xml中的内容
[root@proxy1 conf]# vim schema.xml
<?xml version=\”1.0\”?>
<mycat:schema xmlns:mycat=\”\”>http://io.mycat/\”>
select user() 验证数据库是否正常**主从模式读写分离**写主机读主机读主机
集群模式
</mycat:schema>
5、启动,验证
/usr/local/mycat/bin/mycat start
[root@proxy1 ~]# ss -antp | grep java
LISTEN 0 1 127.0.0.1:32000 : users:((“java”,pid=1665,fd=4),(“wrapper-linux-x”,pid=1663,fd=4))
LISTEN 0 50 :::1984 ::? users:((“java”,pid=1665,fd=55))
LISTEN 0 50 :::41825 ::? users:((“java”,pid=1665,fd=54))
LISTEN 0 50 :::44913 ::? users:((“java”,pid=1665,fd=56))
[root@proxy1 ~]# jps
1350 WrapperSimpleApp
1367 Jps