赞
踩
修改 server.xml\schema.xml\rule.xml 配置文件<!-- 修改 mycat/conf/server.xml--><property name = "useZKSwitch" > true </property> <!-- 此处要注释调保留 false--><user name = "root" defaultAccount = "true" > <!-- 逻辑数据库用户 --><property name = "password" > ok </property> <!-- 逻辑数据库密码 --><property name = "schemas" > TESTDB </property> <!-- 逻辑数据库名 --></user><!-- 另外 1 个 user 可以注释掉 -->
<mycat:schema xmlns:mycat = "http://io.mycat/" ><schema name = "TESTDB" checkSQLschema = "true" sqlMaxLimit = "100" > <!-- 这里的name 要和 server.xml 文件中逻辑数据库名一致 --><!-- 这里有一张表就配置一个 table--><!-- 这里的 rule 是 rule.xml 中的 tableRule 名字根据需要配置 --><table name = "userinfos" dataNode = "mc01,mc02" rule = "mod-long"/></schema><!-- 这里 dataHost 是下面两个 dataHost 的名字 database 是真实 Mysql 数据库中的数据库名 --><dataNode name = "mc01" dataHost = "mc01" database = "db1" /><dataNode name = "mc02" dataHost = "mc02" database = "db2" /><dataHost name = "mc01" maxCon = "1000" minCon = "10" balance = "0"writeType = "0" dbType = "mysql" dbDriver = "native" switchType = "1"slaveThreshold = "100" ><heartbeat> select user() </heartbeat><writeHost host = "hostM1" url = "192.168.126.130:3306"user = "root" password = "ok" ></writeHost></dataHost><dataHost name = "mc02" maxCon = "1000" minCon = "10" balance = "0"writeType = "0" dbType = "mysql" dbDriver = "native" switchType = "1"slaveThreshold = "100" ><heartbeat> select user() </heartbeat><writeHost host = "hostM1" url = "192.168.126.131:3306"user = "root" password = "ok" ></writeHost></dataHost>
<tableRule name = "mod-long" ><rule><columns> userid </columns> <!-- 这里是按表中某列进行分割数据 --><algorithm> mod-long </algorithm></rule></tableRule><function name = "mod-long" class = "io.mycat.route.function.PartitionByMod" ><!-- 根据 mysql 节点的数量配置 count --><property name = "count" > 2 </property></function>
mycat/bin/mycat console( 如果不看启动情况可以使用 mycat/bin/mycat start )
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。