MyCat 双写双读自动负载切换配置

在使用MyCat自动负载切换这个功能之前,需要有已经配置好的两个master和两个slave mysql 实例,可以参考这里进行搭建:https://www.firegod.cn/2020/04/mysql-%e4%b8%bb%e4%bb%8e%e5%90%8c%e6%ad%a5%e9%85%8d%e7%bd%ae/

<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">

	<schema name="TESTDB" checkSQLschema="false">
		<!-- auto sharding by id (long) -->
		<table name="travelrecord" primaryKey="id" dataNode="dn1" autoIncrement="true"/>
	<dataNode name="dn1" dataHost="localhost1" database="db1" />
	<dataHost name="localhost1" maxCon="1000" minCon="10" balance="1"
			  writeType="0" dbType="mysql" dbDriver="native" switchType="2"  slaveThreshold="100">
		<heartbeat>show slave status</heartbeat>
		<!-- can have multi write hosts -->
		<writeHost host="hostM1" url="localhost:33060" user="root" password="12345678">
			<!-- can have multi read hosts -->
			<readHost host="hostS1" url="localhost:33061" user="root" password="12345678" />
		</writeHost>
		<writeHost host="hostM2" url="localhost:33062" user="root" password="12345678">
			<!-- can have multi read hosts -->
			<readHost host="hostS2" url="localhost:33063" user="root" password="12345678" />
		</writeHost>
	</dataHost>
</mycat:schema>

Leave a Comment

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据