mysql高可用之MHA(補充3)--管理多組主從複製

來源:互聯網
上載者:User

標籤:mha mysql   mha 多組主從複製   masterha_default.cnf   mha manager   

前面我們瞭解了mha管理一組主從,然而在實際生產環境中不同的應用會使用不同的資料庫,因此會有多組主從複製,我們可以使用一個mha manager 來管理多組主從複製資料庫。我們只需要建立一個全域設定檔,你可以將這幾組中相同的配置資訊寫到全域設定檔中,如使用者名稱、密碼等,而其他的配置資訊單獨寫到每個app*.cnf中。

官網介紹:

https://code.google.com/p/mysql-master-ha/wiki/Configuration

下面我們就來介紹下:

mha架構:


如上:我們使用一個mha manager節點來管理3組主從複製,我這面只配置兩組,每組具體的配置請參考前面的博文,在此只介紹重點。

10.10.10.59 mha manager

APP1:

10.10.10.56 master

10.10.10.57 slave1

10.10.10.58 slave2

10.10.10.60 vip

APP2:

10.10.10.61 master

10.10.10.62 slave1

10.10.10.63 slave2

10.10.10.64 vip

1.建立全域設定檔masterha_default.cnf

mkdir -p /etc/mhacp /usr/local/src/mha4mysql-manager-0.56/samples/conf/masterha_default.cnf /etc/mha/ln -s /etc/mha/masterha_default.cnf /etc/masterha_default.cnf#將相同的配置資訊寫到全域設定檔中[[email protected] mha]# cat masterha_default.cnf [server default]master_binlog_dir=/data/mysqlpassword=123456ping_interval=1remote_workdir=/tmprepl_password=123456repl_user=repreport_script=/usr/local/bin/send_reportssh_port=22ssh_user=rootuser=mha
注意:masterha_default.cnf一定要在/etc下,否則檢查過程中會找不到這個檔案,為將所有的mha相關設定檔放在一起方便管理,我做了軟串連。
2.建立每個應用對應的設定檔app*.conf

app1.conf

[[email protected] mha]# cat /etc/mha/app1.cnf [server default]manager_log=/var/log/masterha/app1/manager.logmanager_workdir=/var/log/masterha/app1master_ip_failover_script=/usr/local/bin/master_ip_failover_app1master_ip_online_change_script=/usr/local/bin/master_ip_online_change_app1[server1]hostname=10.10.10.56port=3306[server2]candidate_master=1check_repl_delay=0hostname=10.10.10.57port=3306[server3]hostname=10.10.10.58port=3306
app2.conf

[[email protected] mha]# cat /etc/mha/app2.cnf [server default]manager_log=/var/log/masterha/app2/manager.logmanager_workdir=/var/log/masterha/app2master_ip_failover_script=/usr/local/bin/master_ip_failover_app2master_ip_online_change_script=/usr/local/bin/master_ip_online_change_app2[server1]hostname=10.10.10.61port=3306[server2]candidate_master=1check_repl_delay=0hostname=10.10.10.62port=3306[server3]hostname=10.10.10.63port=3306
注意:每個應用的master_ip_failover_script和master_ip_online_change_script對應的指令碼不一樣,因為我們在遷移過程中使用vip來達到高可用的目的,master_ip_failover在自動failover過程中使vip會自動漂移,而master_ip_online_change在線上遷移過程中使vip漂移。因此在多個主從複製組我們使用多個不同的指令碼來管理不同的ip。

3.檢查ssh配置

masterha_check_ssh --conf=/etc/mha/app1.cnf

masterha_check_ssh --conf=/etc/mha/app2.cnf

註:(1)全域設定檔在檢測過程中會自動檢查,如果找不到全域設定檔,就會讀取指定的應用設定檔。

(2)每個主從複製組都需要和mha manager節點配置ssh無密碼登入,但組與組之前不要配置。

4.檢查replication配置

masterha_check_repl --conf=/etc/mha/app1.cnf

masterha_check_repl --conf=/etc/mha/app2.cnf

5.啟動監控

nohup masterha_manager --conf=/etc/mha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/masterha/app1/manager.log 2>&1 &

nohup masterha_manager --conf=/etc/mha/app2.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/masterha/app1/manager.log 2>&1 &

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

mysql高可用之MHA(補充3)--管理多組主從複製

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.