##############################mycat鏡像##############################html
5-1 創mycat鏡像
wget http://dl.mycat.io/1.6-RELEASE/Mycat-server-1.6-RELEASE-XXXXX-linux.tar.gz
yum jdk
docker commit mycat_server mycat:1.0
##### 含ssh
docker commit mycat_server mycat:1.1
5-2 容器mycat-master2
docker run --privileged -it --name mycat-master2 -p 18066:8066 -p 19066:9066 mycat:1.0
#--privileged
docker run --privileged -it --name mycat-master2 -p 18066:8066 -p 19066:9066 -p 10022:22 mycat:1.1
#sshd啓動
/usr/sbin/sshd -D &
#mycat啓動
/usr/local/mycat/ ./mycat startjava
5-3 vi /usr/local/mycat/conf/server.xml
mysql
vi schema.xml
<schema name="testdb" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn_test" >
</schema>
<dataNode name="dn_test" dataHost="localhost1" database="testdb" />
<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=" mariadb_master" url="172.17.0.3:3306" user="root"
password="root">
<!-- can have multi read hosts -->
<readHost host="mariadb_slave" url="172.17.0.2:3306" user="root" password="root" />
</writeHost>
<!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
</dataHost>linux
5-4 宿機ssh登陸 容器mycat-master2
ssh root@172.17.0.4 -p 22
5-5 MyCat服務主機登錄數據庫,測試同步效果.
#root@localhost
mysql -uroot -proot -h 127.0.0.1 -P 19066
5-6 主機 登陸MyCat代理端,測試讀寫分離服務.
#root@localhost
mysql -uroot -p123456 -h127.0.0.1 -P 18066
5-7 ssh 外網web
##############################zookeeper鏡像##############################
#172.17.0.5############################################################
#######################################################################
6-1 docker run -it --name zookeeper docker.io/centos:latest
wget http://dl.mycat.io/zookeeper-3.4.6.tar.gz
[root@localhost ~]# tar -xzvf zookeeper-3.4.6.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/zookeeper-3.4.6/conf/
[root@localhost ~]# cp zoo_sample.cfg zoo.cfg
[root@localhost ~]# vi zoo.cfg
dataDir=/usr/local/...
dataLogDir=/usr/local/...
6-2 zookeeper啓動
[root@localhost ~]# cd /usr/local/zookeeper-3.4.12/bin/
[root@localhost ~]# ./zkServer.sh start
[root@localhost ~]# netstat -ant | grep 2181
6-3 jdk
wget http://dl.mycat.io/jdk-8u20-linux-x64.tar.gz
6-4 生成鏡像
docker commit zookeeper zookeeper:1.0
6-5 生成容器mycat-web-zookeeper
docker run -it --name mycat-web-zookeeper -p 12181:2181 zookeeper:1.0
#mysql -uroot -p123456 -h127.0.0.1 -P 18066
#####mycat-eye##########################################################################################
7-1 容器mycat-web #172.17.0.6
docker run -it --name mycat-web -p 18082:8082 docker.io/centos:latest
7-2
wget http://dl.mycat.io/mycat-web-1.0/Mycat-web-1.0-SNAPSHOT-20170102153329-linux.tar.gz
7-3
[root@localhost ~]# mv Mycat-web-1.0-SNAPSHOT-20170102153329-linux.tar.gz Mycat-web-1.0-linux.tar.gz
[root@localhost ~]# tar -xzvf Mycat-web-1.0-SNAPSHOT-20170102153329-linux.tar.gz -C /usr/local
[root@localhost ~]#
[root@localhost ~]# ./start.sh &
[root@localhost ~]# netstat -an | grep "8082"
tcp 0 0 :::8082 :::* LISTEN
[root@localhost ~]# curl http://localhost:8082/mycat/
7-4
mycat-web註冊zookeeper以下:
cd /usr/local/mycat-web/mycat-web/WEB-INF/classes
vi mycat.properties
zookeeper=172.17.0.5:2181
###
cd /usr/local/mycat-web/
./start.sh &
7-5 進入容器mycat-web
docker exec -ti -u root mycat-web bash
7-6 主機訪問mycat-web
curl http://localhost:18082/mycat/
7-7 外網 mycat-eye
http://192.168.157.128:18082/mycat/sql
netstat -tulpn | grep :22
netstat -ant | grep 2181
java -version
vim /sshd.sh
#!/bin/bash
/usr/sbin/sshd -D
chmod 755 /sshd.sh
yum install net-tools
yum -y install wget
yum install java-1.8.0-openjdk* -y
docker
https://www.cnblogs.com/LyShark/p/10200146.html數據庫
https://blog.csdn.net/qq_37674858/article/details/80136826vim