您好,登錄后才能下訂單哦!
環境要求已安裝JDK1.7+版本
已安裝mysql客戶端(yum install mysql)
操作系統IP:192.168.75.48
下載解壓
wget http://dl.mycat.io/1.6.5/Mycat-server-1.6.5-release-20180122220033-linux.tar.gz
tar -zxvf Mycat-server-1.6.5-release-20180122220033-linux.tar.gz -C /usr/local/
cd /usr/local/mycat/conf
根據實際情況修改schema.xml,server.xml
例如:
schema.xml:
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<!-- phapp 是mycat的邏輯庫名稱,鏈接需要用的 -->
<schema name="xx_app" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1"></schema>
<schema name="xx_data" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn2"></schema>
<schema name="xx_dubbo_monitor" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn3"></schema>
<schema name="xx_log" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn4"></schema>
<schema name="xx_mis" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn5"></schema>
<schema name="xx_task" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn6"></schema>
<!-- database 是MySQL數據庫的庫名 -->
<dataNode name="dn1" dataHost="192.168.75.94" database="xx_app" />
<dataNode name="dn2" dataHost="192.168.75.94" database="xx_data" />
<dataNode name="dn3" dataHost="192.168.75.94" database="xx_dubbo_monitor" />
<dataNode name="dn4" dataHost="192.168.75.94" database="xx_log" />
<dataNode name="dn5" dataHost="192.168.75.94" database="xx_mis" />
<dataNode name="dn6" dataHost="192.168.75.94" database="xx_task" />
<!--
dataNode節點中各屬性說明:
name:指定邏輯數據節點名稱;
dataHost:指定邏輯數據節點物理主機節點名稱;
database:指定物理主機節點上。如果一個節點上有多個庫,可使用表達式db$0-99, 表示指定0-99這100個數據庫;
dataHost 節點中各屬性說明:
name:物理主機節點名稱;
maxCon:指定物理主機服務最大支持1000個連接;
minCon:指定物理主機服務最小保持10個連接;
writeType:指定寫入類型;
0,只在writeHost節點寫入;
1,在所有節點都寫入。慎重開啟,多節點寫入順序為默認寫入根據配置順序,第一個掛掉切換另一個;
dbType:指定數據庫類型;
dbDriver:指定數據庫驅動;
balance:指定物理主機服務的負載模式。
0,不開啟讀寫分離機制;
1,全部的readHost與stand by writeHost參與select語句的負載均衡,簡單的說,當雙主雙從模式(M1->S1,M2->S2,并且M1與 M2互為主備),正常情況下,M2,S1,S2都參與select語句的負載均衡;
2,所有的readHost與writeHost都參與select語句的負載均衡,也就是說,當系統的寫操作壓力不大的情況下,所有主機都可以承擔負載均衡;
-->
<dataHost name="192.168.75.94" maxCon="1000" minCon="10" balance="3" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>show slave status</heartbeat>
<!-- 可以配置多個主從 -->
<writeHost host="hostM1" url="192.168.75.94:3306" user="xx_Corn_User" password="xxxxxxxx">
<!-- 可以配置多個從庫 -->
<readHost host="hostS1" url="192.168.75.95:3306" user="xx_Corn_User" password="xxxxxxxx" />
</writeHost>
</dataHost>
</mycat:schema>
server.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:server SYSTEM "server.dtd">
<mycat:server xmlns:mycat="http://io.mycat/">
<system>
<property name="nonePasswordLogin">0</property> <!-- 0為需要密碼登陸、1為不需要密碼登陸 ,默認為0,設置為1則需要指定默認賬戶-->
<property name="useHandshakeV10">1</property>
<property name="useSqlStat">1</property> <!-- 1為開啟實時統計、0為關閉 -->
<property name="useGlobleTableCheck">0</property> <!-- 1為開啟全加班一致性檢測、0為關閉 -->
<property name="sequnceHandlerType">2</property>
<property name="subqueryRelationshipCheck">false</property> <!-- 子查詢中存在關聯查詢的情況下,檢查關聯字段中是否有分片字段 .默認 false -->
<!-- <property name="useCompression">1</property>--> <!--1為開啟mysql壓縮協議-->
<!-- <property name="fakeMySQLVersion">5.6.20</property>--> <!--設置模擬的MySQL版本號-->
<!-- <property name="processorBufferChunk">40960</property> -->
<!--
<property name="processors">1</property>
<property name="processorExecutor">32</property>
-->
<!--默認為type 0: DirectByteBufferPool | type 1 ByteBufferArena | type 2 NettyBufferPool -->
<property name="processorBufferPoolType">0</property>
<!--默認是65535 64K 用于sql解析時最大文本長度 -->
<property name="maxStringLiteralLength">65535</property>
<property name="sequnceHandlerType">0</property>
<property name="backSocketNoDelay">1</property>
<property name="frontSocketNoDelay">1</property>
<!--<property name="processorExecutor">16</property>-->
<!--
<property name="serverPort">8066</property> <property name="managerPort">9066</property>
<property name="idleTimeout">300000</property> <property name="bindIp">0.0.0.0</property>
<property name="frontWriteQueueSize">4096</property> <property name="processors">32</property> -->
<!--分布式事務開關,0為不過濾分布式事務,1為過濾分布式事務(如果分布式事務內只涉及全局表,則不過濾),2為不過濾分布式事務,但是記錄分布式事務日志-->
<property name="handleDistributedTransactions">0</property>
<!--
off heap for merge/order/group/limit 1開啟 0關閉
-->
<property name="useOffHeapForMerge">1</property>
<!--
單位為m
-->
<property name="memoryPageSize">64k</property>
<!--
單位為k
-->
<property name="spillsFileBufferSize">1k</property>
<property name="useStreamOutput">0</property>
<!--
單位為m
-->
<property name="systemReserveMemorySize">384m</property>
<!--是否采用zookeeper協調切換 -->
<property name="useZKSwitch">false</property>
<!-- XA Recovery Log日志路徑 -->
<!--<property name="XARecoveryLogBaseDir">./</property>-->
<!-- XA Recovery Log日志名稱 -->
<!--<property name="XARecoveryLogBaseName">tmlog</property>-->
</system>
<!-- 全局SQL防火墻設置 -->
<!--白名單可以使用通配符%或著*-->
<!--例如<host host="127.0.0.*" user="root"/>-->
<!--例如<host host="127.0.*" user="root"/>-->
<!--例如<host host="127.*" user="root"/>-->
<!--例如<host host="1*7.*" user="root"/>-->
<!--這些配置情況下對于127.0.0.1都能以root賬戶登錄-->
<!--
<firewall>
<whitehost>
<host host="1*7.0.0.*" user="root"/>
</whitehost>
<blacklist check="false">
</blacklist>
</firewall>
-->
<user name="xx_Corn_User" defaultAccount="true">
<property name="password">xxxxxxxx</property>
<property name="schemas">xx_app,xx_data,xx_dubbo_monitor,xx_log,xx_mis,xx_data,xx_task</property>
<!-- 表級 DML 權限設置 -->
<!--
<privileges check="false">
<schema name="TESTDB" dml="0110" >
<table name="tb01" dml="0000"></table>
<table name="tb02" dml="1111"></table>
</schema>
</privileges>
-->
</user>
<user name="user">
<property name="password">user</property>
<property name="schemas">xx_app</property>
<property name="readOnly">true</property>
</user>
</mycat:server>
修改環境變量
echo export PATH=$PATH:/usr/local/mycat/bin >>/etc/profile
echo export MYCAT_HOME=/usr/local/mycat >> /etc/profile
source /etc/profile
創建mycat用戶
groupadd mycat -g 910
useradd mycat -g 910
chown -R mycat:mycat /usr/local/mycat
啟動mycat
cd /usr/local/mycat/bin
./mycat start
命令行登陸
mysql -u xx_Corn_User -pxxxxxx -P8066 -h 127.0.0.1
下載解壓
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
tar -zxvf zookeeper-3.4.6.tar.gz -C /usr/local/
cd /usr/local/zookeeper-3.4.6/conf
cp zoo_sample.cfg zoo.cfg
啟動zookeeper
cd /usr/local/zookeeper-3.4.6/bin/
./zkServer.sh start
下載解壓
wget https://raw.githubusercontent.com/MyCATApache/Mycat-download/master/mycat-web-1.0/Mycat-web-1.0-SNAPSHOT-20160617163048-linux.tar.gz
tar -zxvf Mycat-web-1.0-SNAPSHOT-20160617163048-linux.tar.gz -C /usr/local/
修改zookeeper地址
cd /usr/local/mycat-web/mycat-web/WEB-INF/classes
vi mycat.properties
zookeeper=localhost:2181 ->zookeeper=127.0.0.1:2181
啟動mycat-eye
cd /usr/local/mycat-web
./start.sh &
訪問mycat-eye
http://192.168.75.48:8082/mycat
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。