MySQL高可用之MHA的搭建--錯誤整合
1.檢查整個複製環境狀況時,出現錯誤
masterha_check_repl –conf=/etc/masterha/app1.cnf
錯誤一:mysql日誌檔案未找到和mysql命令未找到
Can't exec "mysqlbinlog": No such file or directory at /usr/local/share/perl5/MHA/BinlogManager.pm line 99.
mysqlbinlog version not found!
Testing mysql connection and privileges..sh: mysql: command not found
mysql command failed with rc 127:0!
可以通過以下方法解決(在所有節點上執行):
## 主:
[root ~]$ ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog
[root ~]$ ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
## 從:
[root ~]$ ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog
[root ~]$ ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
## 從:
[root ~]$ ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog
[root ~]$ ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
錯誤二:master_ip_failover 未註釋或者未修改
Sun Jan 18 13:19:41 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln214] Failed to get master_ip_failover_script status with return code 255:0.
Sun Jan 18 13:19:41 2015 - [error ][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln383] Error happend on checking configurations. at /usr/local/bin/masterha_check_repl line 48
Sun Jan 18 13:19:41 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln478] Error happened on monitoring servers.
Sun Jan 18 13:19:41 2015 - [info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!
Failover兩種方式:一種是虛擬IP地址,一種是全域性配置檔案。MHA並沒有限定使用哪一種方式,而是讓使用者自己選擇,虛擬IP地址的方式會牽扯到其它的軟體,比如keepalive軟體,而且還要修改指令碼master_ip_failover。
所以先暫時註釋master_ip_failover_script= /usr/local/bin/master_ip_failover這個選項。修改該指令碼以後再開啟該選項
錯誤三:
[[email protected] ~]# masterha_check_repl --conf=/etc/masterha/app1.cnf
Wed Jul 11 21:41:41 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Jul 11 21:41:41 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Wed Jul 11 21:41:41 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Wed Jul 11 21:41:41 2018 - [info] MHA::MasterMonitor version 0.56.
Wed Jul 11 21:41:41 2018 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln301] Got MySQL error when connecting 172.25.32.3(172.25.32.3:3306) :1045:Access denied for user 'root'@'server4' (using password: YES), but this is not a MySQL crash. Check MySQL server settings.
at /usr/share/perl5/vendor_perl/MHA/ServerManager.pm line 297
Wed Jul 11 21:41:41 2018 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln301] Got MySQL error when connecting 172.25.32.2(172.25.32.2:3306) :1045:Access denied for user 'root'@'server4' (using password: YES), but this is not a MySQL crash. Check MySQL server settings.
at /usr/share/perl5/vendor_perl/MHA/ServerManager.pm line 297
Wed Jul 11 21:41:41 2018 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln301] Got MySQL error when connecting 172.25.32.1(172.25.32.1:3306) :1045:Access denied for user 'root'@'server4' (using password: YES), but this is not a MySQL crash. Check MySQL server settings.
at /usr/share/perl5/vendor_perl/MHA/ServerManager.pm line 297
Wed Jul 11 21:41:41 2018 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln309] Got fatal error, stopping operations
Wed Jul 11 21:41:41 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln424] Error happened on checking configurations. at /usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm line 326
Wed Jul 11 21:41:41 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln523] Error happened on monitoring servers.
Wed Jul 11 21:41:41 2018 - [info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!
修改方法:
mysql> grant all on *.* to [email protected]'172.25.32.%' identified by 'westos';
Query OK, 0 rows affected, 1 warning (0.04 sec)
授權之後就OK
錯誤四:
Wed Jul 11 21:49:07 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln361] None of slaves can be master. Check failover configuration file or log-bin settings in my.cnf
Wed Jul 11 21:49:07 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln424] Error happened on checking configurations. at /usr/bin/masterha_check_repl line 48
Wed Jul 11 21:49:07 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln523] Error happened on monitoring servers.
Wed Jul 11 21:49:07 2018 - [info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!
原因:/etc/my.cnf 配置檔案中未加入log-bin=mysql-bin
解決辦法:
新增log-bin=mysql-bin 到配置檔案中,重啟mysql後,重新檢測
2.線上切換主伺服器時,出現錯誤:
錯誤一:
[[email protected] masterha]# masterha_master_switch --conf=/etc/masterha/app1.cnf --master_state=alive --new_master_host=172.25.32.1 --new_master_port=3306 --orig_master_is_new_slave --running_updates_limit=10000
Wed Jul 11 22:44:25 2018 - [info] MHA::MasterRotate version 0.56.
Wed Jul 11 22:44:25 2018 - [info] Starting online master switch..
Wed Jul 11 22:44:25 2018 - [info]
Wed Jul 11 22:44:25 2018 - [info] * Phase 1: Configuration Check Phase..
Wed Jul 11 22:44:25 2018 - [info]
Wed Jul 11 22:44:25 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Jul 11 22:44:25 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Wed Jul 11 22:44:25 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Wed Jul 11 22:44:25 2018 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln653] There are 2 non-slave servers! MHA manages at most one non-slave server. Check configurations.
Wed Jul 11 22:44:25 2018 - [error][/usr/share/perl5/vendor_perl/MHA/ManagerUtil.pm, ln177] Got ERROR: at /usr/share/perl5/vendor_perl/MHA/MasterRotate.pm line 85
原因: 存在兩個主伺服器
解決辦法:只保留一個主伺服器,另一個或其他成為從伺服器
mysql> change master to master_host='172.25.32.2',master_user='repl',master_password='westos',master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.28 sec)
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
錯誤二:
[[email protected] masterha]# masterha_master_switch --conf=/etc/masterha/app1.cnf --master_state=alive --new_master_host=172.25.32.3 --new_master_port=3306 --orig_master_is_new_slave --running_updates_limit=10000
Wed Jul 11 23:06:27 2018 - [info] Checking MHA is not monitoring or doing failover..
Wed Jul 11 23:06:27 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterRotate.pm, ln142] Getting advisory lock failed on the current master. MHA Monitor runs on the current master. Stop MHA Manager/Monitor and try again.
Wed Jul 11 23:06:27 2018 - [error][/usr/share/perl5/vendor_perl/MHA/ManagerUtil.pm, ln177] Got ERROR: at /usr/bin/masterha_master_switch line 53
原因:線上切換時,MHA管理器未停止
解決辦法:
MHA管理器停止監聽:
[[email protected] masterha]# masterha_stop --conf=/etc/masterha/app1.cnf
Stopped app1 successfully.
[1]+ Exit 1 nohup masterha_manager --conf=/etc/masterha/app1.cnf
3.檢查ssh免密連線時出現錯誤:
錯誤一:
[[email protected] ~]# masterha_check_ssh --conf=/etc/masterha/app1.cnf
Mon Jul 9 13:31:20 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Jul 9 13:31:20 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Parameter name --user is invalid!
at /usr/share/perl5/vendor_perl/MHA/SSHCheck.pm line 148
[[email protected] ~]#
配置檔案app1.cnf有錯誤
4.指定主伺服器時出現錯誤:
root@localhost :(none)02:49:31>change master to master_host='56.56.56.117', master_port=3306, master_user='repl',master_password='123456',master_log_file='mysql-bin.001081',master_log_pos=17071655;
ERROR 1776 (HY000): Parameters MASTER_LOG_FILE, MASTER_LOG_POS, RELAY_LOG_FILE and RELAY_LOG_POS cannot be set when MASTER_AUTO_POSITION is active.
解決的辦法:
由於之前用的master_auto_position=1,現在改回0,重新用pos方法change就可以了。
[email protected] :(none)02:49:41>change master to master_auto_position=0;
Query OK, 0 rows affected (0.21 sec)
[email protected] :(none)02:52:50>change master to master_host='56.56.56.117', master_port=3306, master_user='repl',master_password='123456',master_log_file='mysql-bin.001081',master_log_pos=17071655;
Query OK, 0 rows affected, 2 warnings (0.11 sec)
[email protected] :(none)02:53:08>start slave;
Query OK, 0 rows affected (0.01 sec)
相關推薦
MySQL高可用之MHA的搭建--錯誤整合
1.檢查整個複製環境狀況時,出現錯誤 masterha_check_repl –conf=/etc/masterha/app1.cnf 錯誤一:mysql日誌檔案未找到和mysql命令未找到 Can't exec "mysqlbinlog": No s
MySQL高可用之MHA的搭建
測試環境 四臺虛擬機器: server2:master 寫入 server3:Candicate master 讀 server4:slave 讀 server5:Monitor host
MySQL高可用之MHA
ha高可用 filter 保存 yum mysql 復制 ast 詳細 ima ssh MHA,MySQL的高可用架構,在基於主從架構的模式下,當主服務器掛掉之後,由MHA中manager來決定從哪臺slave從服務器當中選擇一臺作為master主服務器,通常是比較從服
MySQL高可用之MHA理論章節
MHA 高可用 復制 背景介紹 高可用架構對於互聯網服務基本是標配,無論是應用服務還是數據庫服務都需要做到高可用。本文是對MySQL數據庫的高可用方案中,基於主從復制的MHA軟件理論部分進行梳理和小結。 MHA軟件介紹 1.MHA軟件是由MHA Manager(管理節點)和MHA Node(數據節
mysql 高可用之mha實現
一 mha簡介 mha是由日本DeNA公司youshimaton(現就職於Facebook公司)開發,是一套MySQL環境下故障切換和主從提升的高可用軟體。據說可以在0~30秒內完成主從切換, 並且在切換過程中可以最大限度的保持資料一致性,當然本人認為保持資料一致性這個
mysql高可用之MHA(補充3)--管理多組主從複製
前面我們瞭解了mha管理一組主從,然而在實際生產環境中不同的應用會使用不同的資料庫,因此會有多組主從複製,我們可以使用一個mha manager 來管理多組主從複製資料庫。我們只需要建立一個全域性配置檔案,你可以將這幾組中相同的配置資訊寫到全域性配置檔案中,如使用者名稱、密
【DB寶19】在Docker中使用MySQL高可用之MHA
[toc] # 一、MHA簡介和架構 ## 1.1 MHA簡介 MHA(Master High Availability Manager and tools for MySQL)目前在MySQL高可用方面是一個相對成熟的解決方案,它是由日本人youshimaton採用Perl語言編寫的一個指令碼管理
Mysql 的高可用之 MHA
mysql 的高可用 郵件報警 Mysql 的高可用之 MHAMHA作為MySQL高可用性環境下故障切換和主從提升的高可用軟件。在MySQL故障切換過程中,MHA能做
MHA MySQL 高可用集群搭建
配置文件 manage 獲取 getopt server rsa 安裝 ref == 軟件版本MySQL: 5.7MHA: 0.56CentOS: 7.4 MySQL服務器Master: 192.168.1.224 mysql01Slave1: 192.168.1.22
MySQL高可用方案 MHA之二 master_ip_failover
[[email protected] bin]# vi master_ip_failover 1 cat master_ip_failover 2 #!/usr/bin/env perl 3 use strict; 4 use warnings FAT
MySQL高可用方案 MHA之四 keepalived 半同步複製
[[email protected] ~]# cat /etc/mysql_mha/app1.cnf [server default]manager_log=/data/mysql_mha/app1-manager.logmanager_workdir=/data/m
mysql高可用架構mha之master_ip_failover腳本
warnings ddr long HERE eat code ida val nbsp 腳本如下: #!/usr/bin/env perl use strict; use warnings FATAL => ‘all‘; u
(轉)MySQL高可用方案MHA的部署和原理
進制 說明 only manager 方案 運行 例如 必須 轉移 背後深層次的邏輯: MHA Node則運行在每個mysql節點上,MHA Manager會定時探測集群中的master節點,當master出現故障時,它自動將最新數據的slave提升為master,然後將其
MySQL高可用部署MHA
運行 code relay rontab form inter 二進制 for 簡單記錄 MHA簡介 MHA 由兩部分組成: MHA Manager(管理節點)和 MHA Node(數據節點)。 MHA Manager可以單獨部署在一臺獨立的機器上管理多個 master-
MySQL高可用之雙主複製模式
MySQL雙主模式高可用實現 生產案例:VIP:10.105.98.211MASTERHOSTNAME IPADDR PORTmy-prod01.oracle.com 192.168.10.97 3306 my-prod02.oracle.com 192.168.10.5 3306 SL
配置MySQL高可用叢集MHA
配置MySQL高可用叢集+++++++++++++++++++主機角色 :客戶端 client50資料庫伺服器 mysql51 到 mysql55管理主機 mgm56VIP地址 192.168.4.100拓撲結構: client50 | mysql51主 |
MySQL高可用架構-MHA環境部署記錄
一、MHA介紹 1 2 3
MySQL高可用之PXC簡介
PXC簡介: galera產品是以galera cluster方式為mysql提高高可用叢集解決方案的。galera cluster就是集成了galera外掛的mysql叢集。galera replication是codership提供的mysql資料同步方案,具有高可用性,方便擴充套件,並且可以實現多個m
Mysql高可用架構——MHA
MHA(Master High Availability)什麼是資料庫的高可用性呢??資料庫主機中我們會有做成主從關係的或者其他關係型資料庫,如果主掛了,不會影響資料的訪問,假如是一主三從架構,主庫掛了,但主庫能被從庫ssh上去的情況下,MHA從三個從庫中選擇同步最接近的作為
MySQL高可用方案--MHA原理
簡介 MHA(Master High Availability)目前在MySQL高可用方面是一個相對成熟的解決方案,它由日本DeNA公司youshimaton(現就職於Facebook公司)開發,是日本的一位MySQL專家採用Perl語言編寫的一個指令碼管理工具,該工具僅適用於MySQLReplicatio