MyCat配置文件备份

MyCat配置文件备份

具体参数含义见《MyCat基础》


【1】server.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?xml version="1.0" encoding="UTF-8"?>
<!-- - - Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License. - You
may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0
- - Unless required by applicable law or agreed to in writing, software -
distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
License for the specific language governing permissions and - limitations
under the License. -->
<!DOCTYPE mycat:server SYSTEM "server.dtd">
<mycat:server xmlns:mycat="http://io.mycat/">
<system>
<!-- 编码格式 -->
<property name="charset">utf8mb4</property>
<!-- 1为开启实时统计、0为关闭 -->
<property name="useSqlStat">1</property>

<!-- 1为开启全加班一致性检测、0为关闭 -->
<property name="useGlobleTableCheck">0</property>

<!-- 紫金大盘日志输出前缀 -->
<property name="logPrefix">mycat</property>

<!-- 紫金大盘日志开关 1开启 0关闭 -->
<property name="logEnabled">0</property>

<!-- 最大连接数 0不限制 -->
<!-- <property name="maxConnections">0</property> -->

<!-- 优雅停机连接强制关闭超时判断时间 -->
<property name="offlineWaitTime">80000</property>

<!--1为开启mysql压缩协议 -->
<!-- <property name="useCompression">1</property> -->
<!--设置模拟的MySQL版本号 -->
<!-- <property name="fakeMySQLVersion">5.6.20</property> -->
<!-- <property name="processorBufferChunk">40960</property> -->

<property name="txIsolation">2</property>
<!-- 事务终端是否由mycat控制,默认为true -->
<property name="txInterruptByMycat">false</property>
<property name="processors">256</property>
<property name="processorExecutor">256</property>

<!--默认为type 0: DirectByteBufferPool | type 1 ByteBufferArena -->
<property name="processorBufferPoolType">0</property>

<!-- 后端连接 空闲检查周期 30秒 -->
<!-- <property name="dataNodeIdleCheckPeriod">300000</property> -->
<!-- 后端连接 心跳检查周期 60秒 -->
<!-- <property name="dataNodeHeartbeatPeriod">600000</property> -->

<!--默认是65535 64K 用于sql解析时最大文本长度 -->
<!--<property name="maxStringLiteralLength">65535</property> -->
<property name="sequnceHandlerType">1</property>
<!--<property name="backSocketNoDelay">1</property> -->
<!--<property name="frontSocketNoDelay">1</property> -->


<!-- <property name="bindIp">0.0.0.0</property> -->
<!-- <property name="serverPort">8066</property> -->
<!-- <property name="managerPort">9066</property> -->

<!-- 连接空闲超时30分钟 -->
<property name="idleTimeout">900000</property>
<!-- sql执行超时5分钟 -->
<!-- <property name="sqlExecuteTimeout">300</property> -->


<!-- <property name="frontWriteQueueSize">4096</property> -->

<!--分布式事务开关,0为不过滤分布式事务,1为过滤分布式事务(如果分布式事务内只涉及全局表,则不过滤),2为不过滤分布式事务,但是记录分布式事务日志 -->
<property name="handleDistributedTransactions">0</property>
<!-- 哪些表允许分布式事务 判断逻辑如下: 1. handleDistributedTransactions ==0 时,所有表都允许分布式事务.
handleDistributedTransactions ==1 时,不允许分布式事务时, 所有表都不允许分布式事务. handleDistributedTransactions
==2 时,只允许distributedTransactionsTables 的表允许分布式事务 -->
<property name="distributedTransactionsTables">
</property>

<!-- off heap for merge/order/group/limit 1开启 0关闭 -->
<property name="useOffHeapForMerge">0</property>
<!-- 单位为m -->
<property name="memoryPageSize">1m</property>
<!-- 单位为k -->
<property name="spillsFileBufferSize">1k</property>
<property name="useStreamOutput">0</property>
<!-- 单位为m -->
<property name="systemReserveMemorySize">384m</property>


<!--是否采用zookeeper协调切换 -->
<property name="useZKSwitch">false</property>

<!-- 开启预编译支持 true开启 false关闭 -->
<property name="usePreparedStmt">true</property>

</system>

<!-- 全局SQL防火墙设置 -->
<!-- <firewall> <whitehost> <host host="127.0.0.1" user="mycat"/> <host
host="127.0.0.2" user="mycat"/> </whitehost> <blacklist check="false"> </blacklist>
</firewall> -->

<user name="root">
<property name="password">yourPassword</property>
<property name="schemas">YourSchemaName</property>
</user>

</mycat:server>

【2】schema.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">

<!-- 逻辑库:共包含原车1、车2、临时车、公共库的表 -->
<schema name="YourSchemaName" checkSQLschema="false" sqlMaxLimit="" dataNode="">
<!-- 车1:9库 —— 1-8正常均分,9库灰度,只存255和511表 -->
<!-- 配送信息表:不分表 -->
<table name='DELIVERY_INFO' primaryKey='CART_NO' dataNode="dn_cart1_$1-9" rule="Rule" />
<!-- 购物车表(车1表):512表 —— 255和511为灰度表 -->
<table name='SHOPPINGCART' subTables="SHOPPINGCART_$1-512" primaryKey="CART_NO" rule="FoolishMod512Rule" dataNode="dn_cart1_$1-9"/>
<table name="SHOPPINGCART_$1-254" primaryKey="CART_NO" subTblLocRule="flat" dataNode="dn_cart1_$1-8" />
<table name="SHOPPINGCART_$257-510" primaryKey="CART_NO" subTblLocRule="flat" dataNode="dn_cart1_$1-8" />
<table name="SHOPPINGCART_256,SHOPPINGCART_512" primaryKey="CART_NO" dataNode="dn_cart1_8" />
<!-- 255、511 灰度表-->
<table name="SHOPPINGCART_255,SHOPPINGCART_511" primaryKey="CART_NO" dataNode="dn_cart1_9" />

<!-- 购物车详细信息表:512表 —— 255和511为灰度表 -->
<table name='SHOPPINGCART_DETAIL' subTables="SHOPPINGCART_DETAIL_$1-512" primaryKey="ITEM_NO" rule="FoolishMod512Rule" dataNode="dn_cart1_$1-9" />
<table name="SHOPPINGCART_DETAIL_$1-254" primaryKey="ITEM_NO" subTblLocRule="flat" dataNode="dn_cart1_$1-8" />
<table name="SHOPPINGCART_DETAIL_$257-510" primaryKey="ITEM_NO" subTblLocRule="flat" dataNode="dn_cart1_$1-8" />
<table name="SHOPPINGCART_DETAIL_256,SHOPPINGCART_DETAIL_512" primaryKey="ITEM_NO" dataNode="dn_cart1_8" />
<!-- 255、511 灰度表-->
<table name="SHOPPINGCART_DETAIL_255,SHOPPINGCART_DETAIL_511" primaryKey="ITEM_NO" dataNode="dn_cart1_9" />

<!-- 门店信息表:512表 —— 255和511为灰度表 -->
<table name='SHOPPINGSTORE_INFO' subTables="SHOPPINGSTORE_INFO_$1-512" primaryKey="ID" rule="FoolishMod512Rule" dataNode="dn_cart1_$1-9" />
<table name="SHOPPINGSTORE_INFO_$1-254" primaryKey="ID" subTblLocRule="flat" dataNode="dn_cart1_$1-8" />
<table name="SHOPPINGSTORE_INFO_$257-510" primaryKey="ID" subTblLocRule="flat" dataNode="dn_cart1_$1-8" />
<table name="SHOPPINGSTORE_INFO_256,SHOPPINGSTORE_INFO_512" primaryKey="ID" dataNode="dn_cart1_8" />
<!-- 255、511 灰度表-->
<table name="SHOPPINGSTORE_INFO_255,SHOPPINGSTORE_INFO_511" primaryKey="ID" dataNode="dn_cart1_9" />

<!-- 购物车(车1)规格信息表:512表 —— 255和511为灰度表 -->
<table name='SPEC_INFO' subTables="SPEC_INFO_$1-512" primaryKey="ID" rule="FoolishMod512Rule" dataNode="dn_cart1_$1-9" />
<table name="SPEC_INFO_$1-254" primaryKey="ID" subTblLocRule="flat" dataNode="dn_cart1_$1-8" />
<table name="SPEC_INFO_$257-510" primaryKey="ID" subTblLocRule="flat" dataNode="dn_cart1_$1-8" />
<table name="SPEC_INFO_256,SPEC_INFO_512" primaryKey="ID" dataNode="dn_cart1_8" />
<!-- 255、511 灰度表-->
<table name="SPEC_INFO_255,SPEC_INFO_511" primaryKey="ID" dataNode="dn_cart1_9" />


<!-- 车2:9库 —— 1-8正常均分,9库灰度,只存255和511表 -->
<!-- 卡信息表:不分表 -->
<table name='CARD_INFO' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 卡分摊信息表(卡的金额需要分摊到购物车内的每一行商品):不分表 -->
<table name='CARD_SHARE' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 发票信息表:不分表 -->
<table name='INVOICE_INFO' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 中心仓发票信息表:不分表 -->
<table name='CENTER_STORE_INVOICE_INFO' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 券信息表:不分表 -->
<table name='COUPON_INFO' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 券分摊信息表(券的金额需要分摊到购物车内的每一行商品):不分表 -->
<table name='COUPON_SHARE' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 配送信息表:不分表 -->
<table name='SETTLE_DELIVERY_INFO' primaryKey='CART_NO' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 折扣表:不分表 -->
<table name='DISCOUNT' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 折扣分摊表(折扣的金额需要分摊到购物车内的每一行商品):不分表 -->
<table name='DSCT_SHARE' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 邮寄地址表:不分表 -->
<table name='POST_ADDRESS' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 邮寄信息表:不分表 -->
<table name='POST_INFO' primaryKey='CART_NO' dataNode="dn_cart2_$1-9" rule="Rule" />
<!-- 子商品(医保卡)表:不分表 -->
<table name='SUBCMMDTY_INFO' primaryKey='ID' dataNode="dn_cart2_$1-9" rule="Rule" />

<!-- 结算车表(车2表):512表 —— 255和511为灰度表 -->
<table name='SETTLECART' subTables="SETTLECART_$1-512" primaryKey="CART_NO" rule="FoolishMod512Rule" dataNode="dn_cart2_$1-9"/>
<table name="SETTLECART_$1-254" primaryKey="CART_NO" subTblLocRule="flat" dataNode="dn_cart2_$1-8" />
<table name="SETTLECART_$257-510" primaryKey="CART_NO" subTblLocRule="flat" dataNode="dn_cart2_$1-8" />
<table name="SETTLECART_256,SETTLECART_512" primaryKey="CART_NO" dataNode="dn_cart2_8" />
<!-- 255、511 灰度表-->
<table name="SETTLECART_255,SETTLECART_511" primaryKey="CART_NO" dataNode="dn_cart2_9" />

<!-- 结算车详细信息表(车2详细信息表):512表 —— 255和511为灰度表 -->
<table name='SETTLECART_DETAIL' subTables="SETTLECART_DETAIL_$1-512" primaryKey="ITEM_NO" rule="FoolishMod512Rule" dataNode="dn_cart2_$1-9"/>
<table name="SETTLECART_DETAIL_$1-254" primaryKey="ITEM_NO" subTblLocRule="flat" dataNode="dn_cart2_$1-8" />
<table name="SETTLECART_DETAIL_$257-510" primaryKey="ITEM_NO" subTblLocRule="flat" dataNode="dn_cart2_$1-8" />
<table name="SETTLECART_DETAIL_256,SETTLECART_DETAIL_512" primaryKey="ITEM_NO" dataNode="dn_cart2_8" />
<!-- 255、511 灰度表-->
<table name="SETTLECART_DETAIL_255,SETTLECART_DETAIL_511" primaryKey="ITEM_NO" dataNode="dn_cart2_9" />

<!-- 结算车规格信息:512表 —— 255和511为灰度表 -->
<table name='SETTLE_SPEC_INFO' subTables="SETTLE_SPEC_INFO_$1-512" primaryKey="ID" rule="FoolishMod512Rule" dataNode="dn_cart2_$1-9"/>
<table name="SETTLE_SPEC_INFO_$1-254" primaryKey="ID" subTblLocRule="flat" dataNode="dn_cart2_$1-8" />
<table name="SETTLE_SPEC_INFO_$257-510" primaryKey="ID" subTblLocRule="flat" dataNode="dn_cart2_$1-8" />
<table name="SETTLE_SPEC_INFO_256,SETTLE_SPEC_INFO_512" primaryKey="ID" dataNode="dn_cart2_8" />
<!-- 255、511 灰度表-->
<table name="SETTLE_SPEC_INFO_255,SETTLE_SPEC_INFO_511" primaryKey="ID" dataNode="dn_cart2_9" />

<!-- 结算车(车2)门店信息表:512表 —— 255和511为灰度表 -->
<table name='STORE_INFO' subTables="STORE_INFO_$1-512" primaryKey="ID" rule="FoolishMod512Rule" dataNode="dn_cart2_$1-9"/>
<table name="STORE_INFO_$1-254" primaryKey="ID" subTblLocRule="flat" dataNode="dn_cart2_$1-8" />
<table name="STORE_INFO_$257-510" primaryKey="ID" subTblLocRule="flat" dataNode="dn_cart2_$1-8" />
<table name="STORE_INFO_256,STORE_INFO_512" primaryKey="ID" dataNode="dn_cart2_8" />
<!-- 255、511 灰度表-->
<table name="STORE_INFO_255,STORE_INFO_511" primaryKey="ID" dataNode="dn_cart2_9" />


<!-- 公共库 -->
<!-- 临时车雪花算法UID生成器表:不分表 -->
<table name="TEMP_CART_UID_GENERATOR" primaryKey="ID" type="global" dataNode="dn_common_pub" />
<!-- 购物车(车1)雪花算法UID生成器表:不分表 -->
<table name="SHOPPING_CART_UID_GENERATOR" primaryKey="ID" type="global" dataNode="dn_common_pub" />
<!-- 结算车(车2)雪花算法UID生成器表:不分表 -->
<table name="SETTLE_CART_UID_GENERATOR" primaryKey="ID" type="global" dataNode="dn_common_pub" />
<!-- 准订单雪花算法UID生成器表:不分表 -->
<table name="ORDER_UID_GENERATOR" primaryKey="ID" type="global" dataNode="dn_common_pub" />
<!-- 省略部分公共表 -->


<!-- 临时车库 -->
<!-- 临时车表:不分表 -->
<table name="TEMPCART" primaryKey="CART_NO" type="global" dataNode="dn_common_temp" />
<!-- 临时车配送信息表:不分表 -->
<table name="TEMPDELIVERY_INFO" primaryKey="CART_NO" type="global" dataNode="dn_common_temp" />
<!-- 临时车商店信息表:不分表 -->
<table name="TEMPCARTSTORE_INFO" primaryKey="ID" type="global" dataNode="dn_common_temp" />
<!-- 临时车规格表:不分表 -->
<table name="TEMPSPEC_INFO" primaryKey="ID" type="global" dataNode="dn_common_temp" />
<!-- 临时车商品详情表:不分表 -->
<table name="TEMPCART_DETAIL" primaryKey="ITEM_NO" type="global" dataNode="dn_common_temp" />
</schema>

<!-- 数据节点 -->
<dataNode name="dn_cart1_1" dataHost="dh_cart1_1" database="cart1_001" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart1_2" dataHost="dh_cart1_2" database="cart1_002" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart1_3" dataHost="dh_cart1_3" database="cart1_003" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart1_4" dataHost="dh_cart1_4" database="cart1_004" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart1_5" dataHost="dh_cart1_5" database="cart1_005" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart1_6" dataHost="dh_cart1_6" database="cart1_006" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart1_7" dataHost="dh_cart1_7" database="cart1_007" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart1_8" dataHost="dh_cart1_8" database="cart1_008" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart1_9" dataHost="dh_cart1_9" database="cart1_000" saDataNode="false" saReadable="true"/>

<dataNode name="dn_cart2_1" dataHost="dh_cart2_1" database="cart2_000" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart2_2" dataHost="dh_cart2_2" database="cart2_001" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart2_3" dataHost="dh_cart2_3" database="cart2_002" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart2_4" dataHost="dh_cart2_4" database="cart2_003" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart2_5" dataHost="dh_cart2_5" database="cart2_004" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart2_6" dataHost="dh_cart2_6" database="cart2_005" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart2_7" dataHost="dh_cart2_7" database="cart2_006" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart2_8" dataHost="dh_cart2_8" database="cart2_007" saDataNode="false" saReadable="true"/>
<dataNode name="dn_cart2_9" dataHost="dh_cart2_9" database="cart2_008" saDataNode="false" saReadable="true"/>

<dataNode name="dn_common_pub" dataHost="dh_common_pub" database="public" />
<dataNode name="dn_common_temp" dataHost="dh_common_temp" database="temp" />

<!-- 节点主机 -->
<!-- 车1库 -->
<dataHost name="dh_cart1_1" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.123:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart1_2" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.159:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart1_3" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.127:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart1_4" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.143:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart1_5" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.147:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart1_6" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.151:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart1_7" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.135:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart1_8" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.155:3306" user="user" password=""/>
</dataHost>
<!-- 灰度库 -->
<dataHost name="dh_cart1_9" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.139:3306" user="user" password=""/>
</dataHost>

<!-- 车2库 -->
<dataHost name="dh_cart2_1" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.107:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart2_2" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.119:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart2_3" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.111:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart2_4" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.115:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart2_5" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.91:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart2_6" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.131:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart2_7" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.163:3306" user="user" password=""/>
</dataHost>
<dataHost name="dh_cart2_8" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.99:3306" user="user" password=""/>
</dataHost>
<!-- 灰度库 -->
<dataHost name="dh_cart2_9" maxCon="150" minCon="10" balance="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="10.243.194.103:3306" user="user" password=""/>
</dataHost>

<!-- 公共库-->
<dataHost name="dh_common_pub" maxCon="500" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="host_common_pub" url="10.243.194.69:3306"></writeHost>
</dataHost>

<!-- 临时车库 -->
<dataHost name="dh_common_temp" maxCon="500" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="host_common_temp" url="10.243.194.73:3306"></writeHost>
</dataHost>

</mycat:schema>

【3】rule.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="UTF-8"?>
<!-- - - Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License. - You
may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0
- - Unless required by applicable law or agreed to in writing, software -
distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
License for the specific language governing permissions and - limitations
under the License. -->
<!DOCTYPE mycat:rule SYSTEM "rule.dtd">
<mycat:rule xmlns:mycat="http://io.mycat/">
<!-- 根据会员号 % 512决定分表 -->
<tableRule name="FoolishMod512Rule">
<rule>
<columns>CUSTOMER_NO</columns>
<algorithm>mod512</algorithm>
</rule>
</tableRule>

<!-- 根据给定的txt文件分库:256、511在9库,其他 % 8 -->
<tableRule name="Rule">
<rule>
<columns>CUSTOMER_NO</columns>
<algorithm>partitionByPattern</algorithm>
</rule>
</tableRule>

<!-- 函数 -->
<function name="mod512" class="io.mycat.route.function.PartitionByMod">
<property name="count">512</property>
</function>

<function name="partitionByPattern" class="io.mycat.route.function.PartitionByPattern">
<property name="patternValue">512</property>
<property name="defaultNode">0</property>
<property name="mapFile">pattern.txt</property>
</function>

</mycat:rule>

pattern.txt

  • 256、511分到灰度库:即9
  • 其他都是根据 CUSTOMER_NO % 8 决定落到1 ~ 8库的哪个库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
0-0=0
1-1=1
2-2=2
3-3=3
4-4=4
5-5=5
6-6=6
7-7=7
8-8=0
9-9=1
10-10=2
11-11=3
12-12=4
13-13=5
14-14=6
15-15=7
16-16=0
17-17=1
18-18=2
19-19=3
20-20=4
21-21=5
22-22=6
23-23=7
24-24=0
25-25=1
26-26=2
27-27=3
28-28=4
29-29=5
30-30=6
31-31=7
32-32=0
33-33=1
34-34=2
35-35=3
36-36=4
37-37=5
38-38=6
39-39=7
40-40=0
41-41=1
42-42=2
43-43=3
44-44=4
45-45=5
46-46=6
47-47=7
48-48=0
49-49=1
50-50=2
51-51=3
52-52=4
53-53=5
54-54=6
55-55=7
56-56=0
57-57=1
58-58=2
59-59=3
60-60=4
61-61=5
62-62=6
63-63=7
64-64=0
65-65=1
66-66=2
67-67=3
68-68=4
69-69=5
70-70=6
71-71=7
72-72=0
73-73=1
74-74=2
75-75=3
76-76=4
77-77=5
78-78=6
79-79=7
80-80=0
81-81=1
82-82=2
83-83=3
84-84=4
85-85=5
86-86=6
87-87=7
88-88=0
89-89=1
90-90=2
91-91=3
92-92=4
93-93=5
94-94=6
95-95=7
96-96=0
97-97=1
98-98=2
99-99=3
100-100=4
101-101=5
102-102=6
103-103=7
104-104=0
105-105=1
106-106=2
107-107=3
108-108=4
109-109=5
110-110=6
111-111=7
112-112=0
113-113=1
114-114=2
115-115=3
116-116=4
117-117=5
118-118=6
119-119=7
120-120=0
121-121=1
122-122=2
123-123=3
124-124=4
125-125=5
126-126=6
127-127=7
128-128=0
129-129=1
130-130=2
131-131=3
132-132=4
133-133=5
134-134=6
135-135=7
136-136=0
137-137=1
138-138=2
139-139=3
140-140=4
141-141=5
142-142=6
143-143=7
144-144=0
145-145=1
146-146=2
147-147=3
148-148=4
149-149=5
150-150=6
151-151=7
152-152=0
153-153=1
154-154=2
155-155=3
156-156=4
157-157=5
158-158=6
159-159=7
160-160=0
161-161=1
162-162=2
163-163=3
164-164=4
165-165=5
166-166=6
167-167=7
168-168=0
169-169=1
170-170=2
171-171=3
172-172=4
173-173=5
174-174=6
175-175=7
176-176=0
177-177=1
178-178=2
179-179=3
180-180=4
181-181=5
182-182=6
183-183=7
184-184=0
185-185=1
186-186=2
187-187=3
188-188=4
189-189=5
190-190=6
191-191=7
192-192=0
193-193=1
194-194=2
195-195=3
196-196=4
197-197=5
198-198=6
199-199=7
200-200=0
201-201=1
202-202=2
203-203=3
204-204=4
205-205=5
206-206=6
207-207=7
208-208=0
209-209=1
210-210=2
211-211=3
212-212=4
213-213=5
214-214=6
215-215=7
216-216=0
217-217=1
218-218=2
219-219=3
220-220=4
221-221=5
222-222=6
223-223=7
224-224=0
225-225=1
226-226=2
227-227=3
228-228=4
229-229=5
230-230=6
231-231=7
232-232=0
233-233=1
234-234=2
235-235=3
236-236=4
237-237=5
238-238=6
239-239=7
240-240=0
241-241=1
242-242=2
243-243=3
244-244=4
245-245=5
246-246=6
247-247=7
248-248=0
249-249=1
250-250=2
251-251=3
252-252=4
253-253=5
254-254=6
255-255=8
256-256=0
257-257=1
258-258=2
259-259=3
260-260=4
261-261=5
262-262=6
263-263=7
264-264=0
265-265=1
266-266=2
267-267=3
268-268=4
269-269=5
270-270=6
271-271=7
272-272=0
273-273=1
274-274=2
275-275=3
276-276=4
277-277=5
278-278=6
279-279=7
280-280=0
281-281=1
282-282=2
283-283=3
284-284=4
285-285=5
286-286=6
287-287=7
288-288=0
289-289=1
290-290=2
291-291=3
292-292=4
293-293=5
294-294=6
295-295=7
296-296=0
297-297=1
298-298=2
299-299=3
300-300=4
301-301=5
302-302=6
303-303=7
304-304=0
305-305=1
306-306=2
307-307=3
308-308=4
309-309=5
310-310=6
311-311=7
312-312=0
313-313=1
314-314=2
315-315=3
316-316=4
317-317=5
318-318=6
319-319=7
320-320=0
321-321=1
322-322=2
323-323=3
324-324=4
325-325=5
326-326=6
327-327=7
328-328=0
329-329=1
330-330=2
331-331=3
332-332=4
333-333=5
334-334=6
335-335=7
336-336=0
337-337=1
338-338=2
339-339=3
340-340=4
341-341=5
342-342=6
343-343=7
344-344=0
345-345=1
346-346=2
347-347=3
348-348=4
349-349=5
350-350=6
351-351=7
352-352=0
353-353=1
354-354=2
355-355=3
356-356=4
357-357=5
358-358=6
359-359=7
360-360=0
361-361=1
362-362=2
363-363=3
364-364=4
365-365=5
366-366=6
367-367=7
368-368=0
369-369=1
370-370=2
371-371=3
372-372=4
373-373=5
374-374=6
375-375=7
376-376=0
377-377=1
378-378=2
379-379=3
380-380=4
381-381=5
382-382=6
383-383=7
384-384=0
385-385=1
386-386=2
387-387=3
388-388=4
389-389=5
390-390=6
391-391=7
392-392=0
393-393=1
394-394=2
395-395=3
396-396=4
397-397=5
398-398=6
399-399=7
400-400=0
401-401=1
402-402=2
403-403=3
404-404=4
405-405=5
406-406=6
407-407=7
408-408=0
409-409=1
410-410=2
411-411=3
412-412=4
413-413=5
414-414=6
415-415=7
416-416=0
417-417=1
418-418=2
419-419=3
420-420=4
421-421=5
422-422=6
423-423=7
424-424=0
425-425=1
426-426=2
427-427=3
428-428=4
429-429=5
430-430=6
431-431=7
432-432=0
433-433=1
434-434=2
435-435=3
436-436=4
437-437=5
438-438=6
439-439=7
440-440=0
441-441=1
442-442=2
443-443=3
444-444=4
445-445=5
446-446=6
447-447=7
448-448=0
449-449=1
450-450=2
451-451=3
452-452=4
453-453=5
454-454=6
455-455=7
456-456=0
457-457=1
458-458=2
459-459=3
460-460=4
461-461=5
462-462=6
463-463=7
464-464=0
465-465=1
466-466=2
467-467=3
468-468=4
469-469=5
470-470=6
471-471=7
472-472=0
473-473=1
474-474=2
475-475=3
476-476=4
477-477=5
478-478=6
479-479=7
480-480=0
481-481=1
482-482=2
483-483=3
484-484=4
485-485=5
486-486=6
487-487=7
488-488=0
489-489=1
490-490=2
491-491=3
492-492=4
493-493=5
494-494=6
495-495=7
496-496=0
497-497=1
498-498=2
499-499=3
500-500=4
501-501=5
502-502=6
503-503=7
504-504=0
505-505=1
506-506=2
507-507=3
508-508=4
509-509=5
510-510=6
511-511=8
-------------本文结束感谢您的阅读-------------

本文标题:MyCat配置文件备份

文章作者:DragonBaby308

发布时间:2019年10月11日 - 18:59

最后更新:2019年10月15日 - 20:42

原始链接:http://www.dragonbaby308.com/MyCat-conf/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

急事可以使用右下角的DaoVoice,我绑定了微信会立即回复,否则还是推荐Valine留言喔( ఠൠఠ )ノ
0%