您好,登錄后才能下訂單哦!
下文給大家?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ù)庫 | master | slave | 用戶名 | 密碼 |
---|---|---|---|---|
mall | 192.168.1.100 | 192.168.1.110 | root | 123456 |
member | 192.168.1.150 | 192.168.1.160 | root | 123456 |
schema.xml文件如下:
<?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)了。
免責(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)容。