本文主要給大家介紹MySQL多源復制配置實施步驟,文章內容都是筆者用心摘選和編輯的,具有一定的針對性,對大家的參考意義還是比較大的,下面跟筆者一起了解下MySQL多源復制配置實施步驟吧。
成都創(chuàng)新互聯(lián)公司從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術服務公司,擁有項目成都網(wǎng)站制作、網(wǎng)站建設網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元海城做網(wǎng)站,已為上家服務,為海城各地企業(yè)和個人服務,聯(lián)系電話:18980820575多源復制的意義
1.可以在一個從庫上對多個云服務器的數(shù)據(jù)庫進行匯總,或者對一個數(shù)據(jù)庫的分庫分表進行匯總。
2.集約使用從庫云服務器的硬件資源,畢竟弱一個數(shù)據(jù)庫業(yè)務量較小確占用整個云服務器資源是不經(jīng)濟的。
3.更方便的對個業(yè)務庫進行數(shù)據(jù)備份,優(yōu)化數(shù)據(jù)庫備份腳本編寫邏輯
拓補圖
實施步驟
1.備份主庫上的數(shù)據(jù),考慮到gtid的問題建議只采用mysqldump程序進行備份
centos:#mysqldump --login-path=3306 \ #mysql官方工具都支持login-path快速登錄 --single-transaction \ #事務一致性備份,防止備份完整性被事務一致性破壞 --master-data=2 \ #在備份文件的頭部加一句change master to pos的注釋語句 -A >ip06p3306.sql #備份所有數(shù)據(jù)庫
2.將導出的文件傳輸?shù)綇膸斓脑品掌魃?/p>
centos_ip06:#scp ip06p3306.sql root@192.168.1.11:/root/ centos_ip31:#scp ip31p3306.sql root@192.168.1.11:/root/
3.將主庫的備份文件導入到從庫上
centos:#mysql --login-path=3306 \ -f <ip06p3306.sql #-f參數(shù),忽略應用備份時產(chǎn)生的GTID沖突
4.從兩份備份文件的頭部查看兩個主庫備份時執(zhí)行到的GTID
centos:#less ip06p3306.sql|grep PURGED #得到GTID_ip06 centos:#less ip31p3306.sql|grep PURGED #得到GTID_ip31
5.重新設置從庫的GTID(在從庫上執(zhí)行)
mysql>reset master; mysql>set global gtid_purged='GTID_ip06,GTID_ip31';
6.將從庫的指向各自的主庫
mysql>change master to \ master_host='192.168.1.6',master_port=3306,\ master_user='repl',master_password='123456', \ master_auto_postion=1 \自動對齊GTID,從庫宕機重啟后,刪除未執(zhí)行relaylog,重新拉取 for channel 'master_3306';為這個主設定一個頻道名,可設為易于辨認的名字
7.設置不方便同步的庫:(如會導致復制出重復用戶的mysql庫)
但sys,performance,information為模式或者視圖一樣的存在,數(shù)據(jù)在讀取時即時生成,不真正存儲數(shù)據(jù),可以不過濾
mysql>stop slave sql_thread;#停止從庫的重放進程,比停止整個從庫要方便的多 mysql>change replication filter \ replicate_ignore_db=(mysql,db1);\#把復制的庫放在括號里,并用,分隔 mysql>start slave sql_thread;
8.查看信息:
mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.6 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000016 Read_Master_Log_Pos: 194 Relay_Log_File: localhost-relay-bin-master_3306.000033 Relay_Log_Pos: 367 Relay_Master_Log_File: mysql-bin.000016 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: 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: 194 Relay_Log_Space: 803 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: 0 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: 13306 Master_UUID: 449fdd93-1b80-11e7-b054-000c29aa1d65 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: 066c3194-2b4b-11e7-b67b-000c290b6ef0:1-2951823, 449fdd93-1b80-11e7-b054-000c29aa1d65:1-140, efa1d12e-3c56-11e7-a99e-000c29ba498d:1-481 Auto_Position: 1 Replicate_Rewrite_DB: Channel_Name: master_3306 Master_TLS_Version: *************************** 2. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.31 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000026 Read_Master_Log_Pos: 375018221 Relay_Log_File: localhost-relay-bin-master_zabbix.000032 Relay_Log_Pos: 375018394 Relay_Master_Log_File: mysql-bin.000026 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: 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: 375018221 Relay_Log_Space: 375018619 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: 0 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: 313306 Master_UUID: 066c3194-2b4b-11e7-b67b-000c290b6ef0 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 066c3194-2b4b-11e7-b67b-000c290b6ef0:2310554-2951823 Executed_Gtid_Set: 066c3194-2b4b-11e7-b67b-000c290b6ef0:1-2951823, 449fdd93-1b80-11e7-b054-000c29aa1d65:1-140, efa1d12e-3c56-11e7-a99e-000c29ba498d:1-481 Auto_Position: 1 Replicate_Rewrite_DB: Channel_Name: master_zabbix Master_TLS_Version: 2 rows in set (0.01 sec)
看完以上關于MySQL多源復制配置實施步驟,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識信息 ,可以持續(xù)關注我們的行業(yè)資訊欄目的。
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
名稱欄目:MySQL多源復制配置實施步驟-創(chuàng)新互聯(lián)
標題鏈接:http://muchs.cn/article4/hshie.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、全網(wǎng)營銷推廣、品牌網(wǎng)站制作、外貿建站、網(wǎng)站維護、網(wǎng)頁設計公司
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內容