SuSE涓婅繍琛孧yCat锛堜簩锛夛細閰嶇疆鍗曠偣MyCat
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SuSE涓婅繍琛孧yCat锛堜簩锛夛細閰嶇疆鍗曠偣MyCat相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e4%b8%8d%e5%90%8c' title='涓嶅悓'>涓嶅悓
limit span index mys update 閰嶇疆鏂囦欢 memory 缁撴瀯https://www.jianshu.com/p/8848f6a802b1
SuSE涓婅繍琛孧yCat锛堜簩锛夛細閰嶇疆鍗曠偣MyCat
鐩爣
閫氳繃鏈枃鎿嶄綔锛屾惌寤洪潤鎬佺粨鏋勫涓嬪浘鐨勪竴涓狹yCat闆嗙兢銆備负浜嗚妭鐪佽祫婧愶紝3涓墿鐞嗗簱閮藉皢瀛樻斁鍦ㄥ悓涓€涓狹ySQL瀹炰緥褰撲腑銆?/p>
閮ㄧ讲mysql鑺傜偣
鍒涘缓鍒嗙墖鑺傜偣锛堝簱锛?/h3>
CREATE DATABASE mycat00;
CREATE DATABASE mycat01;
CREATE DATABASE mycat02;
CREATE TABLE mycat00.test_tbl(
id INT UNSIGNED NOT NULL PRIMARY KEY,
date DATETIME NOT NULL );
CREATE TABLE mycat01.test_tbl(
id INT UNSIGNED NOT NULL PRIMARY KEY,
date DATETIME NOT NULL );
CREATE TABLE mycat02.test_tbl(
id INT UNSIGNED NOT NULL PRIMARY KEY,
date DATETIME NOT NULL );
鍒涘缓铏氭嫙琛ㄧ敤鎴?/h3>
CREATE USER 鈥榬oot鈥?span class="token variable">@鈥?鈥?IDENTIFIED BY 鈥榬oot鈥?span class="token punctuation">;
GRANT ALL PRIVILIGES ON `mycat%`.* TO 鈥榬oot鈥?span class="token variable">@鈥?鈥?span class="token punctuation">;
鎻掑叆鍘熷鏁版嵁
INSERT INTO mycat00.test_tbl(id,date)
VALUES (0,鈥?000-01-01鈥?span class="token punctuation">);
INSERT INTO mycat01.test_tbl(id,date)
VALUES (1,鈥?000-02-01鈥?span class="token punctuation">);
INSERT INTO mycat02.test_tbl(id,date)
VALUES (2,鈥?000-03-01鈥?span class="token punctuation">);
閰嶇疆MyCat
CREATE DATABASE mycat00;
CREATE DATABASE mycat01;
CREATE DATABASE mycat02;
CREATE TABLE mycat00.test_tbl(
id INT UNSIGNED NOT NULL PRIMARY KEY,
date DATETIME NOT NULL );
CREATE TABLE mycat01.test_tbl(
id INT UNSIGNED NOT NULL PRIMARY KEY,
date DATETIME NOT NULL );
CREATE TABLE mycat02.test_tbl(
id INT UNSIGNED NOT NULL PRIMARY KEY,
date DATETIME NOT NULL );
CREATE USER 鈥榬oot鈥?span class="token variable">@鈥?鈥?IDENTIFIED BY 鈥榬oot鈥?span class="token punctuation">;
GRANT ALL PRIVILIGES ON `mycat%`.* TO 鈥榬oot鈥?span class="token variable">@鈥?鈥?span class="token punctuation">;
鎻掑叆鍘熷鏁版嵁
INSERT INTO mycat00.test_tbl(id,date)
VALUES (0,鈥?000-01-01鈥?span class="token punctuation">);
INSERT INTO mycat01.test_tbl(id,date)
VALUES (1,鈥?000-02-01鈥?span class="token punctuation">);
INSERT INTO mycat02.test_tbl(id,date)
VALUES (2,鈥?000-03-01鈥?span class="token punctuation">);
閰嶇疆MyCat
MyCat鐨勯厤缃枃浠堕泦涓湪鍏堕厤缃枃浠跺す/usr/local/mycat/conf鍐咃紝浠ヤ笅宸ヤ綔灏嗕互璇ユ枃浠跺す涓哄熀鍑嗐€?/p>
璺敱瑙勫垯锛坮ule.xml锛?/h3>
澶囦唤鍘熸湁璺敱瑙勫垯鏂囦欢rule.xml鍚庯紝灏嗘暣涓猺ule.xml鏀瑰啓鎴愬涓嬪唴瀹癸細
<?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/">
<tableRule name="cicular_month_rule">
<rule>
<columns>date</columns>
<algorithm>cicular_month</algorithm>
</rule>
</tableRule>
<function name="cicular_month"
class="io.mycat.route.function.PartitionByMonth">
<property name="dateFormat">yyyy-MM-dd</property>
<property name="sBeginDate">2000-01-01</property>
<property name="sEndDate">2000-03-01</property>
<property name="nPartition">3</property>
</function>
</mycat:rule>
閰嶇疆铏氭嫙搴撳強铏氭嫙琛紙schema.xml锛?/h3>
澶囦唤鍘熸湁铏氭嫙搴撴枃浠秙chema.xml鍚庯紝灏嗘暣涓猻chema.xml鏀瑰啓鎴愬涓嬪唴瀹癸細
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100">
<table name="test_tbl" dataNode="dn00,dn01,dn02" rule="cicular_month_rule" />
</schema>
<dataNode name="dn00" dataHost="dh00" database="mycat00" />
<dataNode name="dn01" dataHost="dh00" database="mycat01" />
<dataNode name="dn02" dataHost="dh00" database="mycat02" />
<dataHost name="dh00"
dbType="mysql" dbDriver="native"
maxCon="9" minCon="1" balance="0" switchType="0">
<heartbeat>select 1</heartbeat>
<writeHost host="host00"
url="192.168.35.125:3306" user="root" password="root" />
</dataHost>
</mycat:schema>
閰嶇疆MyCat鏈嶅姟淇℃伅锛坰erver.xml鍙妋yid.properties锛?/h3>
澶囦唤鍘熸湁鏈嶅姟鍣ㄩ厤缃枃浠秙erver.xml鍚庯紝灏嗘暣涓猻erver.xml鏀瑰啓鎴愬涓嬪唴瀹癸細
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mycat:server SYSTEM "server.dtd">
<mycat:server xmlns:mycat="http://io.mycat/">
<system>
<property name="useSqlStat">0</property>
<property name="useGlobleTableCheck">0</property>
<property name="sequnceHandlerType">2</property>
<property name="processorBufferPoolType">0</property>
<property name="handleDistributedTransactions">0</property>
<property name="useOffHeapForMerge">1</property>
<property name="memoryPageSize">1m</property>
<property name="spillsFileBufferSize">1k</property>
<property name="useStreamOutput">0</property>
<property name="systemReserveMemorySize">384m</property>
<property name="useZKSwitch">false</property>
<property name="serverPort">8066</property>
<property name="managerPort">9066</property>
</system>
<user name="mycat_root">
<property name="password">123456</property>
<property name="schemas">TESTDB</property>
</user>
<user name="user">
<property name="password">user