<schema name="testdb">
<table name="goods" primaryKey="ID" type="global" dataNode="dn1,dn2" />
<table name="order" primaryKey="ID" dataNode="dn1,dn2" rule="sharding-by-date" />
</schema>
<!-- 分片配置 -->
<dataNode name="dn1" dataHost="dh1" database="db1"/>
<dataNode name="dn2" dataHost="dh2" database="db2"/>
<!-- 物理数据库配置 -->
<dataHost name="dh1" maxCon="1000" minCon="10" balance="0" switchType="1"
slaveThreshold="100">
<heartbeat>show slave status</heartbeat>
<writeHost host="MySQLA" url="172.16.1.1:3306" user="test" password="password"/>
</dataHost>
<dataHost name="dh2" maxCon="1000" minCon="10" balance="0" switchType="1"
slaveThreshold="100">
<heartbeat>show slave status</heartbeat>
<writeHost host="MySQLB" url="172.16.1.2:3306" user="test" password="password">
<readHost host="MySQLC" url="172.16.1.3:3306" user="test" password="password"/>
</writeHost>
</dataHost>
</dble:schema>
图解 schema.xml
schema架构详解.png
总结
schema.xml是DBLE中间件如何配置分片最重要一个配置文件;如能熟悉掌握其中的逻辑概念,就可以对dble
熟练配置;更高阶和详尽的用法,建议大家查阅官网的官方文档。
温馨提示:距离第一期 DBLE 有奖征稿活动结束还剩 10 天,我们已经收到 3 篇来自社区的投稿,欢迎其他同
学踊跃参与,投稿信息请联系爱可生开源社区!
评论