mycat 添加一个hash分片方法
-rwxrwxrwx. 1 root root 28 Sep 1 20:36 partition-hash-int.txt -rwxr-xr-x 1 root root 36 Sep 1 20:36 partition-hash-orders-int.txt -rwxrwxrwx. 1 root root 102 Sep 1 20:36 partition-range-mod.txt -rwxrwxrwx. 1 root root 4068 Sep 1 20:36 rule.xml -rwxrwxrwx. 1 root root 2640 Sep 1 20:36 schema.xml -rwxrwxrwx. 1 root root 413 Sep 1 20:36 sequence_conf.properties -rwxrwxrwx. 1 root root 75 Sep 1 20:36 sequence_db_conf.properties -rwxrwxrwx. 1 root root 27 Sep 1 20:36 sequence_distributed_conf.properties -rwxrwxrwx. 1 root root 51 Sep 1 20:36 sequence_time_conf.properties -rwxrwxrwx. 1 root root 1389 Sep 1 20:36 server.xml -rwxrwxrwx. 1 root root 16 Oct 28 2016 sharding-by-enum.txt -rwxrwxrwx. 1 root root 4185 Aug 13 22:34 wrapper.conf drwxrwxrwx. 2 root root 4096 Sep 1 20:36 zkconf drwxrwxrwx. 2 root root 35 Mar 19 21:25 zkdownload [root@localhost conf]# more rule.xml <!DOCTYPE mycat:rule SYSTEM "rule.dtd"> <mycat:rule xmlns:mycat="http://io.mycat/"> <tableRule name="rule1"> <rule> <columns>id</columns> <algorithm>func1</algorithm> </rule> </tableRule> <tableRule name="rule2"> <rule> <columns>user_id</columns> <algorithm>func1</algorithm> </rule> </tableRule> <tableRule name="sharding-by-intfile"> <rule> <columns>sharding_id</columns> <algorithm>hash-int</algorithm> </rule> </tableRule> <tableRule name="sharding-for-orders"> <rule> <columns>sharding_id</columns> <algorithm>hash-int-orders</algorithm> </rule> </tableRule> <tableRule name="auto-sharding-long">
sharding-for-orders 对着 sharding-by-intfile 弄的 , 主要是分片数量不同
[root@localhost conf]# more schema.xml <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat:schema xmlns:mycat="http://io.mycat/"> <schema name="TESTDB" checkSQLschema="false"> <table name="admin" dataNode="dn1" needAddLimit="false"/> <table name="tunnel" dataNode="dn1" needAddLimit="false"/> <table name="tenant_auto_pay" dataNode="dn1" needAddLimit="false"/> <table name="tenant_channels_fee" dataNode="dn1" needAddLimit="false"/> <table name="channel_dict" dataNode="dn1" needAddLimit="false"/> <table name="orders_payfor_another" dataNode="dn1" primaryKey="ORDER_NO" needAddLimit="false"/> <table name="account_san_channel" dataNode="dn1" needAddLimit="false"/> <table name="announce" dataNode="dn1" needAddLimit="false"/> <table name="tenant_log" dataNode="dn1" needAddLimit="false"/> <table name="tenant" dataNode="dn1,dn2,dn3,dn4" primaryKey="SUPER_ID" needAddLimit="false" type="global"/> <table name="tenant_security" dataNode="dn1,dn2,dn3,dn4" primaryKey="ID" needAddLimit="false" type="global"/> <table name="tenant_card" dataNode="dn1,dn2,dn3,dn4" primaryKey="ID" needAddLimit="false" type="global"/> <table name="tenant_account" dataNode="dn1,dn2,dn3,dn4" primaryKey="ID" needAddLimit="false" type="global"/> <table name="orders" dataNode="dn1,dn2,dn3,dn4" rule="sharding-for-orders" primaryKey="ID" needAddLimit="false"/> <table name="orders_status" dataNode="dn1" needAddLimit="false"/> <table name="tenant_withdraws" dataNode="dn1,dn2,dn3" rule="sharding-by-intfile" primaryKey="ID" needAddLimit="false"/> </schema> <dataNode name="dn1" dataHost="localhost1" database="db1"/> <dataNode name="dn2" dataHost="localhost1" database="db2"/> <dataNode name="dn3" dataHost="localhost1" database="db3"/> <dataNode name="dn4" dataHost="platform01" database="db1"/> <dataHost balance="1" maxCon="500" minCon="100" name="localhost1" writeType="0" switchType="-1" slaveThreshold="100" dbType="mysql" dbDriver="native"> <heartbeat>select user()</heartbeat> <writeHost host="hostM1" url="127.0.0.1:3306" password="wuhan85123_" user="root"> <readHost host="hostS2" url="144.48.xxx.154:3306" password="wuhan85123_" user="root"/> </writeHost> </dataHost> <dataHost balance="1" maxCon="500" minCon="100" name="platform01" writeType="0" switchType="-1" slaveThreshold="100" dbType="mysql" dbDriver="native"> <heartbeat>select user()</heartbeat> <writeHost host="Mplatform01" url="47.75.xxx.154:3306" password="wuhan85123_" user="root"/> </dataHost> </mycat:schema> [root@localhost conf]#
[root@localhost conf]# more partition-hash-int.txt 10000=0 10010=1 #LP 10020=2 [root@localhost conf]# more partition-hash-orders-int.txt 10000=0 10010=1 #LP 10020=2 10030=3 [root@localhost conf]#
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】