设为首页 收藏本站
查看: 628|回复: 0

[经验分享] MySQL-MHA 安装配置及遇到的问题

[复制链接]

尚未签到

发表于 2018-10-1 13:48:37 | 显示全部楼层 |阅读模式
  在192.168.17.199(manager)上 tailf /etc/masterha/app1/manager.log
  然后停止192.168.17.199的3306 mysql实例,并查看manager.log
  ]# tail -f /masterha/app1/manager.log
  192.168.17.199 (current master)
  +--192.168.17.200
  +--192.168.17.201
  Tue Nov 19 00:32:04 2013 - [warning] master_ip_failover_script is not defined.
  Tue Nov 19 00:32:04 2013 - [warning] shutdown_script is not defined.
  Tue Nov 19 00:32:04 2013 - [info] Set master ping interval 1 seconds.
  Tue Nov 19 00:32:04 2013 - [warning] secondary_check_script is not defined. It is highly recommended setting it to check master reachability from two or more routes.
  Tue Nov 19 00:32:04 2013 - [info] Starting ping health check on 192.168.17.199(192.168.17.199:3306)..
  Tue Nov 19 00:32:04 2013 - [info] Ping(SELECT) succeeded, waiting until MySQL doesn't respond..
  Tue Nov 19 17:59:07 2013 - [warning] Got error on MySQL select ping: 2006 (MySQL server has gone away)
  Tue Nov 19 17:59:07 2013 - [info] Executing SSH check script: save_binary_logs --command=test --start_pos=4 --binlog_dir=/data/mydb/db01/logs/binlog/ --output_file=/var/tmp/save_binary_logs_test --manager_version=0.54 --binlog_prefix=mysql-bin
  Tue Nov 19 17:59:08 2013 - [info] HealthCheck: SSH to 192.168.17.199 is reachable.
  Tue Nov 19 17:59:08 2013 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
  Tue Nov 19 17:59:08 2013 - [warning] Connection failed 1 time(s)..
  Tue Nov 19 17:59:09 2013 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
  Tue Nov 19 17:59:09 2013 - [warning] Connection failed 2 time(s)..
  Tue Nov 19 17:59:10 2013 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
  Tue Nov 19 17:59:10 2013 - [warning] Connection failed 3 time(s)..
  Tue Nov 19 17:59:10 2013 - [warning] Master is not reachable from health checker!
  Tue Nov 19 17:59:10 2013 - [warning] Master 192.168.17.199(192.168.17.199:3306) is not reachable!
  Tue Nov 19 17:59:10 2013 - [warning] SSH is reachable.
  Tue Nov 19 17:59:10 2013 - [info] Connecting to a master server failed. Reading configuration file /etc/masterha_default.cnf and /etc/masterha/app1.cnf again, and trying to connect to all servers to check server status..
  Tue Nov 19 17:59:10 2013 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
  Tue Nov 19 17:59:10 2013 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
  Tue Nov 19 17:59:10 2013 - [info] Reading server configurations from /etc/masterha/app1.cnf..
  Tue Nov 19 17:59:10 2013 - [info] Dead Servers:
  Tue Nov 19 17:59:10 2013 - [info]   192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:10 2013 - [info] Alive Servers:
  Tue Nov 19 17:59:10 2013 - [info]   192.168.17.200(192.168.17.200:3306)
  Tue Nov 19 17:59:10 2013 - [info]   192.168.17.201(192.168.17.201:3306)
  Tue Nov 19 17:59:10 2013 - [info] Alive Slaves:
  Tue Nov 19 17:59:10 2013 - [info]   192.168.17.200(192.168.17.200:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:10 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:10 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:10 2013 - [info]   192.168.17.201(192.168.17.201:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:10 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:10 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:10 2013 - [info] Checking slave configurations..
  Tue Nov 19 17:59:10 2013 - [info]  read_only=1 is not set on slave 192.168.17.200(192.168.17.200:3306).
  Tue Nov 19 17:59:10 2013 - [warning]  relay_log_purge=0 is not set on slave 192.168.17.200(192.168.17.200:3306).
  Tue Nov 19 17:59:10 2013 - [info]  read_only=1 is not set on slave 192.168.17.201(192.168.17.201:3306).
  Tue Nov 19 17:59:10 2013 - [warning]  relay_log_purge=0 is not set on slave 192.168.17.201(192.168.17.201:3306).
  Tue Nov 19 17:59:10 2013 - [info] Checking replication filtering settings..
  Tue Nov 19 17:59:10 2013 - [info]  Replication filtering check ok.
  Tue Nov 19 17:59:10 2013 - [info] Master is down!
  Tue Nov 19 17:59:10 2013 - [info] Terminating monitoring script.
  Tue Nov 19 17:59:10 2013 - [info] Got exit code 20 (Master dead).
  Tue Nov 19 17:59:10 2013 - [info] MHA::MasterFailover version 0.54.
  Tue Nov 19 17:59:10 2013 - [info] Starting master failover.
  Tue Nov 19 17:59:10 2013 - [info]
  Tue Nov 19 17:59:10 2013 - [info] * Phase 1: Configuration Check Phase..
  Tue Nov 19 17:59:10 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] Dead Servers:
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info] Checking master reachability via mysql(double check)..
  Tue Nov 19 17:59:11 2013 - [info]  ok.
  Tue Nov 19 17:59:11 2013 - [info] Alive Servers:
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.200(192.168.17.200:3306)
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.201(192.168.17.201:3306)
  Tue Nov 19 17:59:11 2013 - [info] Alive Slaves:
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.200(192.168.17.200:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:11 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.201(192.168.17.201:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:11 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:11 2013 - [info] ** Phase 1: Configuration Check Phase completed.
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 2: Dead Master Shutdown Phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] Forcing shutdown so that applications never connect to the current master..
  Tue Nov 19 17:59:11 2013 - [warning] master_ip_failover_script is not set. Skipping invalidating dead master ip address.
  Tue Nov 19 17:59:11 2013 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.
  Tue Nov 19 17:59:11 2013 - [info] * Phase 2: Dead Master Shutdown Phase completed.
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 3: Master Recovery Phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 3.1: Getting Latest Slaves Phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] The latest binary log file/position on all slaves is mysql-bin.000009:2386

  Tue Nov 19 17:59:11 2013 - [info] Latest slaves (Slaves that received>  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.200(192.168.17.200:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:11 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.201(192.168.17.201:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:11 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:11 2013 - [info] The oldest binary log file/position on all slaves is mysql-bin.000009:2386
  Tue Nov 19 17:59:11 2013 - [info] Oldest slaves:
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.200(192.168.17.200:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:11 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.201(192.168.17.201:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:11 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 3.2: Saving Dead Master's Binlog Phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] Fetching dead master's binary logs..
  Tue Nov 19 17:59:11 2013 - [info] Executing command on the dead master 192.168.17.199(192.168.17.199:3306): save_binary_logs --command=save --start_file=mysql-bin.000009  --start_pos=2386 --binlog_dir=/data/mydb/db01/logs/binlog/ --output_file=/var/tmp/saved_master_binlog_from_192.168.17.199_3306_20131119175910.binlog --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.54
  Creating /var/tmp if not exists..    ok.
  Concat binary/relay logs from mysql-bin.000009 pos 2386 to mysql-bin.000009 EOF into /var/tmp/saved_master_binlog_from_192.168.17.199_3306_20131119175910.binlog ..
  Dumping binlog format description event, from position 0 to 107.. ok.
  Dumping effective binlog data from /data/mydb/db01/logs/binlog//mysql-bin.000009 position 2386 to tail(2405).. ok.
  sh: mysqlbinlog: command not found
  Failed to save binary log: /var/tmp/saved_master_binlog_from_192.168.17.199_3306_20131119175910.binlog is broken!
  at /usr/local/bin/save_binary_logs line 170
  Tue Nov 19 17:59:11 2013 - [error][/usr/local/share/perl5/MHA/MasterFailover.pm, ln577] Failed to save binary log events from the orig master. Maybe disks on binary logs are not accessible or binary log itself is corrupt?
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 3.3: Determining New Master Phase..
  Tue Nov 19 17:59:11 2013 - [info]

  Tue Nov 19 17:59:11 2013 - [info] Finding the latest slave that has all>
  Tue Nov 19 17:59:11 2013 - [info] All slaves received>  Tue Nov 19 17:59:11 2013 - [info] Searching new master from slaves..
  Tue Nov 19 17:59:11 2013 - [info]  Candidate masters from the configuration file:
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.200(192.168.17.200:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:11 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:11 2013 - [info]   192.168.17.201(192.168.17.201:3306)  Version=5.5.33-rel31.1-log (oldest major version between slaves) log-bin:enabled
  Tue Nov 19 17:59:11 2013 - [info]     Replicating from 192.168.17.199(192.168.17.199:3306)
  Tue Nov 19 17:59:11 2013 - [info]     Primary candidate for the new Master (candidate_master is set)
  Tue Nov 19 17:59:11 2013 - [info]  Non-candidate masters:

  Tue Nov 19 17:59:11 2013 - [info]  Searching from candidate_master slaves which have received the latest>  Tue Nov 19 17:59:11 2013 - [info] New master is 192.168.17.200(192.168.17.200:3306)
  Tue Nov 19 17:59:11 2013 - [info] Starting master failover..
  Tue Nov 19 17:59:11 2013 - [info]
  From:
  192.168.17.199 (current master)
  +--192.168.17.200
  +--192.168.17.201
  To:
  192.168.17.200 (new master)
  +--192.168.17.201
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 3.3: New Master Diff Log Generation Phase..
  Tue Nov 19 17:59:11 2013 - [info]

  Tue Nov 19 17:59:11 2013 - [info]  This server has all>  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 3.4: Master Log Apply Phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] *NOTICE: If any error happens from this phase, manual recovery is needed.
  Tue Nov 19 17:59:11 2013 - [info] Starting recovery on 192.168.17.200(192.168.17.200:3306)..

  Tue Nov 19 17:59:11 2013 - [info]  This server has all>  Tue Nov 19 17:59:11 2013 - [info]   done.

  Tue Nov 19 17:59:11 2013 - [info]  All>  Tue Nov 19 17:59:11 2013 - [info] Getting new master's binlog name and position..
  Tue Nov 19 17:59:11 2013 - [info]  mysql-bin.000008:2606
  Tue Nov 19 17:59:11 2013 - [info]  All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.17.200', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000008', MASTER_LOG_POS=2606, MASTER_USER='repl', MASTER_PASSWORD='xxx';
  Tue Nov 19 17:59:11 2013 - [warning] master_ip_failover_script is not set. Skipping taking over new master ip address.
  Tue Nov 19 17:59:11 2013 - [info] ** Finished master recovery successfully.
  Tue Nov 19 17:59:11 2013 - [info] * Phase 3: Master Recovery Phase completed.
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 4: Slaves Recovery Phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 4.1: Starting Parallel Slave Diff Log Generation Phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] -- Slave diff file generation on host 192.168.17.201(192.168.17.201:3306) started, pid: 38557. Check tmp log /masterha/app1/192.168.17.201_3306_20131119175910.log if it takes time..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] Log messages from 192.168.17.201 ...
  Tue Nov 19 17:59:11 2013 - [info]

  Tue Nov 19 17:59:11 2013 - [info]  This server has all>  Tue Nov 19 17:59:11 2013 - [info] End of log messages from 192.168.17.201.

  Tue Nov 19 17:59:11 2013 - [info] -- 192.168.17.201(192.168.17.201:3306) has the latest>
  Tue Nov 19 17:59:11 2013 - [info] Generating>  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 4.2: Starting Parallel Slave Log Apply Phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] -- Slave recovery on host 192.168.17.201(192.168.17.201:3306) started, pid: 38559. Check tmp log /masterha/app1/192.168.17.201_3306_20131119175910.log if it takes time..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] Log messages from 192.168.17.201 ...
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] Starting recovery on 192.168.17.201(192.168.17.201:3306)..

  Tue Nov 19 17:59:11 2013 - [info]  This server has all>  Tue Nov 19 17:59:11 2013 - [info]   done.

  Tue Nov 19 17:59:11 2013 - [info]  All>  Tue Nov 19 17:59:11 2013 - [info]  Resetting slave 192.168.17.201(192.168.17.201:3306) and starting replication from the new master 192.168.17.200(192.168.17.200:3306)..
  Tue Nov 19 17:59:11 2013 - [info]  Executed CHANGE MASTER.
  Tue Nov 19 17:59:11 2013 - [info]  Slave started.
  Tue Nov 19 17:59:11 2013 - [info] End of log messages from 192.168.17.201.
  Tue Nov 19 17:59:11 2013 - [info] -- Slave recovery on host 192.168.17.201(192.168.17.201:3306) succeeded.
  Tue Nov 19 17:59:11 2013 - [info] All new slave servers recovered successfully.
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] * Phase 5: New master cleanup phase..
  Tue Nov 19 17:59:11 2013 - [info]
  Tue Nov 19 17:59:11 2013 - [info] Resetting slave info on the new master..
  Tue Nov 19 17:59:12 2013 - [info]  192.168.17.200: Resetting slave info succeeded.
  Tue Nov 19 17:59:12 2013 - [info] Master failover to 192.168.17.200(192.168.17.200:3306) completed successfully.
  Tue Nov 19 17:59:12 2013 - [info]
  ----- Failover Report -----
  app1: MySQL Master failover 192.168.17.199 to 192.168.17.200 succeeded
  Master 192.168.17.199 is down!
  Check MHA Manager logs at rhel-king-01:/masterha/app1/manager.log for details.
  Started automated(non-interactive) failover.

  The latest slave 192.168.17.200(192.168.17.200:3306) has all>  Selected 192.168.17.200 as a new master.
  192.168.17.200: OK: Applying all logs succeeded.

  192.168.17.201: This host has the latest>
  Generating>  192.168.17.201: OK: Applying all logs succeeded. Slave started, replicating from 192.168.17.200.
  192.168.17.200: Resetting slave info succeeded.
  Master failover to 192.168.17.200(192.168.17.200:3306) completed successfully.


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-607184-1-1.html 上篇帖子: mysql字符串转数字小计 下篇帖子: Linux中的MySql数据库远程连接
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表