PXC简介
PXC作用如下图:
PXC特点:
强一致性,可以在任何节点上读写操作,每个节点不存在未同步的数据,性能偏低
生产环境架构图
两个PXC做分片,一个读写分离
mycat中schema.xml配置参考:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<!--配置数据表-->
<schema name="testdb" checkSQLschema="false" sqlMaxLimit="100">
<!--两个pxc取模-->
<table name="tb_house_resources" dataNode="dn1,dn2" rule="mod-long"/>
<!--一个读写分离-->
<table name="tb_ad" dataNode="dn3"/>
</schema>
<!--配置分片关系-->
<dataNode name="dn1" dataHost="cluster1" database="testdb"/>
<dataNode name="dn2" dataHost="cluster2" database="testdb"/>
<dataNode name="dn3" dataHost="cluster3" database="testdb"/>
<!--配置连接信息-->
<!--两个PXC分片-->
<dataHost name="cluster1" maxCon="1000" minCon="10" balance="2" writeType="1" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="W1" url="192.168.64.128:13306" user="root" password="root">
<readHost host="W1R1" url="192.168.64.128:13307" user="root" password="123456"/>
</writeHost>
</dataHost>
<dataHost name="cluster2" maxCon="1000" minCon="10" balance="2" writeType="1" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="W2" url="192.168.64.128:13308" user="root" password="root">
<readHost host="W2R1" url="192.168.64.128:13309" user="root" password="123456"/>
</writeHost>
</dataHost>
<!--一个读写分离-->
<dataHost name="cluster3" maxCon="1000" minCon="10" balance="3" writeType="1" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="W3" url="192.168.64.128:23306" user="root" password="root">
<readHost host="W3R1" url="192.168.64.128:23307" user="root" password="123456"/>
</writeHost>
</dataHost>
</mycat:schema>