{"id":498,"title":"centos7\u4e0bmycat\u5b89\u88c5\u53ca\u914d\u7f6e","good":1,"bad":9,"hit":3174,"created_at":"2020-07-03 16:57:00","content":"

mycat\u5b98\u65b9\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/dl.mycat.org.cn\/<\/a><\/p>

<\/p>

\u9700\u6c42\uff0c\u7531\u4e8e\u78c1\u76d8\u7a7a\u95f4\u6709\u9650\uff0c\u9700\u8981\u5c06ip\u5e93\u4e00\u90e8\u5206\u6570\u636e\u5b58\u5728\u4e00\u53f0\u670d\u52a1\u5668\uff0c\u4e00\u90e8\u5206\u5b58\u4e8e\u53e6\u4e00\u4e2a\u670d\u52a1\u5668<\/p>

\u6700\u7ec8\u6548\u679c\uff1a<\/p>

\"image.png\"\/<\/p>

<\/p>

\u9700\u8981\u5148\u5b89\u88c5java jdk<\/p>

1\u3001\u5b89\u88c5<\/p>

\u5148\u8981\u5b89\u88c5java1.7\u6216\u4ee5\u4e0a\u7248\u672c<\/p>

yum install java<\/p>

java -version\u67e5\u770b\u7248\u672c<\/p>

<\/p>

<\/p>

\u4e0b\u8f7d\u540e\u89e3\u538b\uff0c\u4fee\u6539config\u76ee\u5f55\u4e2d\u7684server.xml\uff0c\u6ce8\u610f\uff0c\u4e0b\u9762\u7684\u5bc6\u7801\u4e0d\u662fmysql\u6570\u636e\u5e93\u7684\u5bc6\u7801\uff0c\u662f\u8fde\u63a5mycat\u7684\u5bc6\u7801\uff0c\u8fde\u63a5\u7684\u7aef\u53e3\u662f8066\u800c\u4e0d\u662f3306<\/p>

\"image.png\"\/<\/p>

<\/p>

\u4fee\u6539schemal.xml<\/p>

<\/span><\/p>

<\/p>

<?xml version="1.0"?><\/p>

<!DOCTYPE mycat:schema SYSTEM "schema.dtd"><\/p>

<mycat:schema xmlns:mycat="http:\/\/io.mycat\/"><\/p>

<\/p>

<schema name="mycat_ips" checkSQLschema="true" sqlMaxLimit="100" randomDataNode="node1<\/strong><\/em>"><\/p>

<\/span><table name="ip_001" primaryKey="id" dataNode="node1,node2" rule="auto-sharding-long<\/strong>" autoIncrement="true" fetchStoreNodeByJdbc="true"><\/table><\/p>

<\/span><table name="ip_002" primaryKey="id" dataNode="node1,node2" rule="auto-sharding-long" autoIncrement="true" fetchStoreNodeByJdbc="true"><\/table><\/p>

<\/schema><\/p>

<dataNode name="node1<\/strong><\/em>" dataHost="tencent<\/strong>" database="ip" \/><\/p>

<dataNode name="node2" dataHost="aliyun<\/strong>" database="ip" \/><\/p>

<dataHost name="tencent<\/strong>" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="jdbc" switchType="1"  slaveThreshold="100"><\/p>

<\/span><heartbeat>select user()<\/heartbeat><\/p>

        <!--\u56e0\u4e3amycat\u88c5\u5728\u8fd9\u4e00\u53f0\u4e0a\uff0c\u8fd9\u91cc\u7528localhost\u8fde\u63a5\u52a0\u5feb\u901f\u5ea6--><\/strong><\/p>

<\/span><writeHost host="tencent167" url="jdbc:mysql:\/\/localhost:3306<\/strong>" user="root" password="\u672c\u53f0\u670d\u52a1\u5668mysql\u5bc6\u7801"><\/writeHost><\/p>

<\/dataHost><\/p>

<!--macCon\u6700\u5927\u8fde\u63a5\u6570\uff0cminCon\u6700\u5c0f\u8fde\u63a5\u6570,balance:\u8d1f\u8f7d\u5747\u8861\u7c7b\u578b\uff080\u4e0d\u5f00\u542f\u8bfb\u5199\u5206\u7c7b\uff0c1,2\u8bfb\u5199\u5747\u5300\u5206\u914d\uff0c3\u8bfb\u843d\u5728readHost\u4e0a\uff09<\/p>

<dataHost name="aliyun<\/strong>" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="jdbc" switchType="1"  slaveThreshold="100"><\/p>

        <heartbeat>select user()<\/heartbeat><\/p>

        <writeHost host="ali234" url="jdbc:mysql:\/\/\u53e6\u4e00\u53f0\u670d\u52a1\u5668\u7684\u516c\u7f51ip<\/strong>:3306" user="root" password="\u672c\u53f0\u670d\u52a1\u5668mysql\u5bc6\u7801"><\/writeHost><\/p>

<\/dataHost><\/p>

<\/mycat:schema><\/p>

<\/span>\u6839\u636eschemal.xml\u4e2d\u7684rule="auto-sharding-long<\/strong>"\u5728rule.xml\u4e2d\u67e5\u627e<\/p>

\"image.png\"\/<\/p>

\u6839\u636ealgorithm\u4e2d\u7684\u503c\u7ee7\u7eed\u67e5\u627e\uff1a<\/span><\/p>

\"image.png\"\/<\/span><\/p>

\u7136\u540e\u4fee\u6539\uff1a<\/span><\/p>

\"image.png\"\/<\/span><\/p>

\u4e0a\u9762\u7684\u914d\u7f6e\u8868\u793a\uff1a<\/p>

id\u4f4d\u4e8e0-1203240960\u5b58\u4e8e\u4e00\u53f0\u6570\u636e\u5e93\uff0c<\/p>

\u5176\u5b83\u5b58\u4e8e\u53e6\u4e00\u53f0\u6570\u636e\u5e93<\/p>

<\/span><\/p>

\u7136\u540e\u542f\u52a8mycat,\u5982\u679c\u770b\u5230successfully\u8868\u793a\u6210\u529f\uff0c\u5982\u679c\u62a5\u9519\u4e00\u822c\u662f\u914d\u7f6e\u95ee\u9898\uff0c\u6309\u63d0\u793a\u4fee\u6539\u5373\u53ef\uff1b<\/p>

\u5982\u679cnavicate\u8fde\u63a5\u65f6\u62a51184\u9519\u8bef\uff0c\u8bf7\u770b\u8fd9\u91cc\uff1ahttp:\/\/www.hu-rong.com\/article\/499<\/a><\/p>

<\/p>

\"image.png\"\/<\/p>

\u4ee5\u540e\u53f0\u65b9\u5f0f\u542f\u52a8\uff1a.\/mycat start<\/p>

\u8bbe\u4e3a\u5f00\u673a\u542f\u52a8\uff1a\u5728\/etc\/rc.d\/rc.local\u4e2d\u52a0\u5165\/mycal\u8def\u5f84\/bin\/mycat start<\/p>

<\/span><\/p>

\u4e91\u670d\u52a1\u5668\u5b89\u5168\u7ec4\u5165\u7ad9\u89c4\u5219\u4e2d\u653e\u5f008066\u7aef\u53e3(<\/span>TCP:8066<\/span>)\uff0c\u5f00\u542fmycat\u8fdc\u7a0b\u8bbf\u95ee\uff1a<\/span><\/p>

<\/span><\/p>

<\/span><\/p>

<\/span><\/p>

\u5b98\u65b9\u6587\u6863\uff1ahttp:\/\/www.mycat.org.cn\/document\/mycat-definitive-guide.pdf<\/a><\/p>

<\/p>

schema.xml\u76f8\u5173\u914d\u7f6e\u8bf4\u660e\uff1a<\/p>

\"image.png\"\/<\/p>

<\/p>

\"image.png\"\/<\/p>

\"image.png\"\/<\/p>

<\/p>"}