溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Cento7.4安裝mycat和mycat-eye

發(fā)布時(shí)間:2020-08-06 20:28:01 來(lái)源:網(wǎng)絡(luò) 閱讀:3150 作者:澎湃2017 欄目:MySQL數(shù)據(jù)庫(kù)

前提:


  環(huán)境要求已安裝JDK1.7+版本
  已安裝mysql客戶端(yum install mysql)
  操作系統(tǒng)IP:192.168.75.48

安裝mycat


下載解壓

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

根據(jù)實(shí)際情況修改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的邏輯庫(kù)名稱,鏈接需要用的 -->
    <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數(shù)據(jù)庫(kù)的庫(kù)名 -->

    <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節(jié)點(diǎn)中各屬性說(shuō)明:
    name:指定邏輯數(shù)據(jù)節(jié)點(diǎn)名稱;
    dataHost:指定邏輯數(shù)據(jù)節(jié)點(diǎn)物理主機(jī)節(jié)點(diǎn)名稱;
    database:指定物理主機(jī)節(jié)點(diǎn)上。如果一個(gè)節(jié)點(diǎn)上有多個(gè)庫(kù),可使用表達(dá)式db$0-99,     表示指定0-99這100個(gè)數(shù)據(jù)庫(kù);

    dataHost 節(jié)點(diǎn)中各屬性說(shuō)明:
        name:物理主機(jī)節(jié)點(diǎn)名稱;
        maxCon:指定物理主機(jī)服務(wù)最大支持1000個(gè)連接;
        minCon:指定物理主機(jī)服務(wù)最小保持10個(gè)連接;
        writeType:指定寫入類型;
            0,只在writeHost節(jié)點(diǎn)寫入;
            1,在所有節(jié)點(diǎn)都寫入。慎重開(kāi)啟,多節(jié)點(diǎn)寫入順序?yàn)槟J(rèn)寫入根據(jù)配置順序,第一個(gè)掛掉切換另一個(gè);
        dbType:指定數(shù)據(jù)庫(kù)類型;
        dbDriver:指定數(shù)據(jù)庫(kù)驅(qū)動(dòng);
        balance:指定物理主機(jī)服務(wù)的負(fù)載模式。
            0,不開(kāi)啟讀寫分離機(jī)制;
            1,全部的readHost與stand by writeHost參與select語(yǔ)句的負(fù)載均衡,簡(jiǎn)單的說(shuō),當(dāng)雙主雙從模式(M1->S1,M2->S2,并且M1與 M2互為主備),正常情況下,M2,S1,S2都參與select語(yǔ)句的負(fù)載均衡;
            2,所有的readHost與writeHost都參與select語(yǔ)句的負(fù)載均衡,也就是說(shuō),當(dāng)系統(tǒng)的寫操作壓力不大的情況下,所有主機(jī)都可以承擔(dān)負(fù)載均衡;
-->
    <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>
        <!-- 可以配置多個(gè)主從 -->
        <writeHost host="hostM1" url="192.168.75.94:3306" user="xx_Corn_User" password="xxxxxxxx">
            <!-- 可以配置多個(gè)從庫(kù) -->
            <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為不需要密碼登陸 ,默認(rèn)為0,設(shè)置為1則需要指定默認(rèn)賬戶-->
    <property name="useHandshakeV10">1</property>
    <property name="useSqlStat">1</property>  <!-- 1為開(kāi)啟實(shí)時(shí)統(tǒng)計(jì)、0為關(guān)閉 -->
    <property name="useGlobleTableCheck">0</property>  <!-- 1為開(kāi)啟全加班一致性檢測(cè)、0為關(guān)閉 -->

        <property name="sequnceHandlerType">2</property>
    <property name="subqueryRelationshipCheck">false</property> <!-- 子查詢中存在關(guān)聯(lián)查詢的情況下,檢查關(guān)聯(lián)字段中是否有分片字段 .默認(rèn) false -->
      <!--  <property name="useCompression">1</property>--> <!--1為開(kāi)啟mysql壓縮協(xié)議-->
        <!--  <property name="fakeMySQLVersion">5.6.20</property>--> <!--設(shè)置模擬的MySQL版本號(hào)-->
    <!-- <property name="processorBufferChunk">40960</property> -->
    <!-- 
    <property name="processors">1</property> 
    <property name="processorExecutor">32</property> 
     -->
        <!--默認(rèn)為type 0: DirectByteBufferPool | type 1 ByteBufferArena | type 2 NettyBufferPool -->
        <property name="processorBufferPoolType">0</property>
        <!--默認(rèn)是65535 64K 用于sql解析時(shí)最大文本長(zhǎng)度 -->
        <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> -->
        <!--分布式事務(wù)開(kāi)關(guān),0為不過(guò)濾分布式事務(wù),1為過(guò)濾分布式事務(wù)(如果分布式事務(wù)內(nèi)只涉及全局表,則不過(guò)濾),2為不過(guò)濾分布式事務(wù),但是記錄分布式事務(wù)日志-->
        <property name="handleDistributedTransactions">0</property>
            <!--
            off heap for merge/order/group/limit      1開(kāi)啟   0關(guān)閉
        -->
        <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協(xié)調(diào)切換  -->
        <property name="useZKSwitch">false</property>
        <!-- XA Recovery Log日志路徑 -->
        <!--<property name="XARecoveryLogBaseDir">./</property>-->
        <!-- XA Recovery Log日志名稱 -->
        <!--<property name="XARecoveryLogBaseName">tmlog</property>-->

    </system>

    <!-- 全局SQL防火墻設(shè)置 -->
    <!--白名單可以使用通配符%或著*-->
    <!--例如<host host="127.0.0.*" user="root"/>-->
    <!--例如<host host="127.0.*" user="root"/>-->
    <!--例如<host host="127.*" user="root"/>-->
    <!--例如<host host="1*7.*" user="root"/>-->
    <!--這些配置情況下對(duì)于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>

        <!-- 表級(jí) DML 權(quán)限設(shè)置 -->
        <!--        
        <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>

修改環(huán)境變量

echo export PATH=$PATH:/usr/local/mycat/bin >>/etc/profile
echo export MYCAT_HOME=/usr/local/mycat >> /etc/profile
source /etc/profile

創(chuàng)建mycat用戶

groupadd mycat -g 910
useradd  mycat -g 910
chown -R mycat:mycat /usr/local/mycat

啟動(dòng)mycat

cd /usr/local/mycat/bin
./mycat start

命令行登陸
mysql -u xx_Corn_User -pxxxxxx -P8066 -h 127.0.0.1

安裝zookeeper


下載解壓

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

啟動(dòng)zookeeper

cd /usr/local/zookeeper-3.4.6/bin/
./zkServer.sh start

安裝mycat-eye


下載解壓

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

啟動(dòng)mycat-eye

cd /usr/local/mycat-web
./start.sh &

訪問(wèn)mycat-eye

http://192.168.75.48:8082/mycat
Cento7.4安裝mycat和mycat-eye

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI