MyCAT Server startup successfully. see logs in logs/mycat.log #啟動(dòng)成功將看到如下信息。
注意:如日志中出現(xiàn)192.168.110.2 not connected 等信息,請(qǐng)?jiān)试SB備mysql遠(yuǎn)程訪問(wèn)。
#登錄mysql console 進(jìn)入%home%/bin,執(zhí)行mysql -uroot -proot #授權(quán)。允許root用戶,從192.168.110.*的IP范圍 遠(yuǎn)程訪問(wèn)Bmysql mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.110.*' IDENTIFIED BY 'root' WITH GRANT OPTION; #生效,該操作很重要! mysql>FLUSH PRIVILEGES;
測(cè)試讀寫分離
驗(yàn)證是否同步
關(guān)閉B備mysql的同步,驗(yàn)證讀寫分離
mysql> slave stop; Query OK, 0 rows affected (0.00 sec) mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Master_Host: 192.168.110.1 Master_User: root Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000003 Read_Master_Log_Pos: 478 Relay_Log_File: wjt-1c698d8a032-relay-bin.00001 Relay_Log_Pos: 624 Relay_Master_Log_File: mysql-bin.000003 Slave_IO_Running: No Slave_SQL_Running: No Replicate_Do_DB: sync_test Replicate_Ignore_DB: mysql Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 478 Relay_Log_Space: 936 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: NULL Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 1 row in set (0.00 sec) ERROR: No query specified
3)使用navicat連接mycat,操作方式和連接物理mysql庫(kù)一致,用戶admin,密碼admin,端口8066
原因:mycat將查詢sq路由到B,因此讀取的結(jié)果集不一致。
最后,mycat使用可以參見(jiàn)官網(wǎng)的權(quán)威指南學(xué)習(xí)。雙主雙備架構(gòu)待后續(xù)更新。
總結(jié)
以上所述是小編給大家介紹的基于mysql+mycat搭建穩(wěn)定高可用集群負(fù)載均衡主備復(fù)制讀寫分離操作,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com