溫馨提示×

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

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

mycat實(shí)現(xiàn)讀寫分離及數(shù)據(jù)庫負(fù)載均衡的實(shí)驗(yàn)

發(fā)布時(shí)間:2020-04-20 14:15:40 來源:億速云 閱讀:289 作者:三月 欄目:系統(tǒng)運(yùn)維

下文給大家?guī)韒ycat實(shí)現(xiàn)讀寫分離及數(shù)據(jù)庫負(fù)載均衡的實(shí)驗(yàn),希望能夠給大家在實(shí)際運(yùn)用中帶來一定的幫助,負(fù)載均衡涉及的東西比較多,理論也不多,網(wǎng)上有很多書籍,今天我們就用億速云在行業(yè)內(nèi)累計(jì)的經(jīng)驗(yàn)做一個(gè)解答。

系統(tǒng)存在2個(gè)Mariadb 10.3數(shù)據(jù)庫主從集群

數(shù)據(jù)庫masterslave用戶名密碼
mall192.168.1.100192.168.1.110root123456
member192.168.1.150192.168.1.160root123456

schema.xml文件如下:

mycat實(shí)現(xiàn)讀寫分離及數(shù)據(jù)庫負(fù)載均衡的實(shí)驗(yàn)

<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">

        <schema name="mall" checkSQLschema="false" sqlMaxLimit="100" dataNode="mall_dn" >
        </schema>

        <schema name="member" checkSQLschema="false" sqlMaxLimit="100" dataNode="member_dn" >
        </schema>

        <dataNode name="mall_dn" dataHost="malldbhost" database="mall" />
        <dataNode name="member_dn" dataHost="memberdbhost" database="member" />

        <dataHost name="malldbhost" maxCon="1000" minCon="10" balance="3"
                          writeType="0" dbType="mysql" dbDriver="native" switchType="1"  slaveThreshold="100">
                <heartbeat>select user()</heartbeat>
                <writeHost host="master" url="192.168.1.100:3306" user="root" password="123456">
                        <readHost host="slave" url="192.168.1.110:3306" user="root" password="123456">
                        </readHost>
                </writeHost>
        </dataHost>

        <dataHost name="memberdbhost" maxCon="1000" minCon="10" balance="3"
                          writeType="0" dbType="mysql" dbDriver="native" switchType="1"  slaveThreshold="100">
                <heartbeat>select user()</heartbeat>
                <writeHost host="membermaster" url="192.168.1.150:3306" user="root" password="123456">
                        <readHost host="memberslave" url="192.168.1.160:3306" user="root" password="123456">
                        </readHost>
                </writeHost>
        </dataHost>

</mycat:schema>

server.xml局部

        <user name="root" defaultAccount="true">
                <property name="password">123456</property>
                <property name="schemas">mall,member</property>
        </user>
        <user name="mall" defaultAccount="true">
                <property name="password">123456</property>
                <property name="schemas">mall</property>
        </user>
        <user name="member" defaultAccount="true">
                <property name="password">123456</property>
                <property name="schemas">member</property>
        </user>

        <user name="read">
                <property name="password">123456</property>
                <property name="schemas">mall,member</property>
                <property name="readOnly">true</property>

       </user>

看了以上關(guān)于mycat實(shí)現(xiàn)讀寫分離及數(shù)據(jù)庫負(fù)載均衡的實(shí)驗(yàn),如果大家還有什么地方需要了解的可以在億速云行業(yè)資訊里查找自己感興趣的或者找我們的專業(yè)技術(shù)工程師解答的,億速云技術(shù)工程師在行業(yè)內(nèi)擁有十幾年的經(jīng)驗(yàn)了。


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

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

AI