1. 程式人生 > >mysql MHA指令碼masterha_master_switch手動操作常見錯誤

mysql MHA指令碼masterha_master_switch手動操作常見錯誤

Mon May 21 16:56:06 2018 - [error][/usr/local/share/perl5/MHA/MasterFailover.pm, ln1261] Failed to activate master IP address for centos129 with return code 10:0 解決辦法:
[warning] Got timeout on MySQL Ping child process and killed it! at /usr/local/share/perl5/MHA/HealthCheck.pm line 385 解決辦法:

Can't exec "mysqlbinlog": 沒有那個檔案或目錄 at /usr/local/share/perl5/MHA/BinlogManager.pm line 99. 解決辦法:
在node節點上執行 which mysqlbinlog,比如我的結果就是
   [localhost~]$ which mysqlbinlog
   /usr/local/mysql/bin/mysqlbinlog
   需要做一個軟連線
   ln -s /data/mysql/bin/mysqlbinlog   /usr/bin/mysqlbinlog
(shiyan:ln -s /data/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog)

Tue May 22 13:45:25 2018 - [error][/usr/local/share/perl5/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. Tue May 22 13:45:25 2018 - [error][/usr/local/share/perl5/MHA/ManagerUtil.pm, ln178] Got ERROR: at /usr/local/bin/masterha_master_switch line 53.
解決辦法:
masterha_stop --conf=/etc/masterha/app1.cnf


Wed May 23 10:42:48 2018 - [error][/usr/local/share/perl5/MHA/MasterRotate.pm, ln161] We should not start online master switch when one of connections are running long updates on the current master(centos128(192.168.44.128:3306)). Currently 1 update thread(s) are running. Details: {'Time' => '4304','db' => undef,'Id' => '1','User' => 'event_scheduler','State' => 'Waiting on empty queue','Command' => 'Daemon','Info' => undef,'Host' => 'localhost'} Wed May 23 10:42:48 2018 - [error][/usr/local/share/perl5/MHA/ManagerUtil.pm, ln178] Got ERROR: at /usr/local/bin/masterha_master_switch line 53. 解決方法:
關掉event_schedule即可:
(product)[email protected] [(none)]> SET GLOBAL event_scheduler =off;
Query OK, 0 rows affected (0.00 sec)
(product)[email protected] [(none)]> Select @@event_scheduler;


Wed May 23 10:53:48 2018 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln1145] 192.168.44.129 is not alive! Wed May 23 10:53:48 2018 - [error][/usr/local/share/perl5/MHA/MasterRotate.pm, ln232] Failed to get new master! Wed May 23 10:53:48 2018 - [error][/usr/local/share/perl5/MHA/ManagerUtil.pm, ln178] Got ERROR: at /usr/local/bin/masterha_master_switch line 53. 解決辦法: 解決方法1: 因為10.16.24.109的/etc/masterha/app1.cnf 中的no_master=1限制了它成為新master的可能,標識掉no_master=1後,重新線上切換成功。 解決方案2:
      直接將IP地址替換為主機名後問題解決,不再演示。
       按官方文件描述,引數--dead_master_host=(hostname),而不是可以用IP地址。
       If these parameters are not set, --dead_master_ip will be the result of gethostbyname(dead_master_host), and --dead_master_port will be 3306.
       補充: 如果配置檔案裡hostname=IP地址,則在切換的時候使用IP地址也是可行的



再次報錯“Got Error: Undefined subroutine &main::FIXME_xxx_drop_app_user called at /usr/local/bin/master_ip_online_change line 152” 解決辦法:
這是由於無法找到對FIXME_xxx_drop_app_user定義,由於perl不熟,我暫時註釋掉相關drop user的行或FIXME_xxx等,不會影響其他過程。
其中需要註釋掉的語句為:
FIXME_xxx_drop_app_user($orig_master_handler);
FIXME_xxx_create_app_user($new_master_handler);
再次執行:


Wed May 23 11:05:54 2018 577112 Set read_only on the new master.. ok. Wed May 23 11:05:54 2018 578994 Drpping app user on the orig master.. Got Error: Undefined subroutine &main::FIXME_xxx_drop_app_user called at /usr/local/bin/master_ip_online_change line 148. Wed May 23 11:05:54 2018 - [error][/usr/local/share/perl5/MHA/ManagerUtil.pm, ln178] Got ERROR: at /usr/local/bin/masterha_master_switch line 53. 解決辦法:
在master_ip_online_change 中其中需要註釋掉的語句為:
FIXME_xxx_drop_app_user($orig_master_handler);
FIXME_xxx_create_app_user($new_master_handler);

Wed May 23 13:57:55 2018 - [error][/usr/local/share/perl5/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 May 23 13:57:55 2018 - [error][/usr/local/share/perl5/MHA/ManagerUtil.pm, ln178] Got ERROR: at /usr/local/bin/masterha_master_switch line 53. 解決辦法:
將MHA停掉再進行測試
masterha_stop --conf=/etc/masterha/app1.cnf