本文主要是介绍docker安装mycat,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
docker run --name mycat --privileged=true -p 8066:8066 -p 9066:9066 -d longhronshens/mycat-dockerdocker cp mycat:/usr/local/mycat/conf /data/mycat
修改配置文件:
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" ></schema><dataNode name="dn1" dataHost="host1" database="jeesun_goods" /><dataHost name="host1" 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.31.52:3306" user="root"password="root12"><!-- can have multi read hosts --><readHost host="hostS2" url="192.168.31.52:3307" user="root" password="root12" /> </writeHost></dataHost></mycat:schema>
server.xml:
<user name="mycat"><property name="password">root12</property><property name="schemas">TESTDB</property>
</user>
启动容器:
docker run --name mycat -v /data/mycat/schema.xml:/usr/local/mycat/conf/schema.xml -v /data/mycat/rule.xml:/usr/local/mycat/conf/rule.xml -v /data/mycat/server.xml:/usr/local/mycat/conf/server.xml --privileged=true -p 8066:8066 -p 9066:9066 -e MYSQL_ROOT_PASSWORD=root -d longhronshens/mycat-docker
连接:
ip:8066 mycat root12测试是否连接成功
这篇关于docker安装mycat的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!