您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 保山分类信息网,免费分类信息发布

Mysql5.5部署MHA

2024/12/25 8:47:30发布18次查看
mha分管理节点和数据库节点,数据库节点由mysql主从或者主主从构成,当主库挂掉后,管理节点会自动将从节点提升为主节点;管理节点的角色类似于oracle数据库中的
mha分管理节点和数据库节点,香港空间,数据库节点由mysql主从或者主主从构成,当主库挂掉后,管理节点会自动将从节点提升为主节点;管理节点的角色类似于oracle数据库中的fast start failover中的observer,但mha上层可以通过keepalive部署vip,程序连接数据库使用vip,从而实现后台数据库的故障切换透明化
mha节点包含三个脚本,依赖perl模块;
save_binary_logs:保存和复制当掉的主服务器二进制日志;
apply_diff_relay_logs:识别差异的relay log事件,并应用于其他salve服务器;
purge_relay_logs:清除relay log文件;
需要在所有mysql服务器上安装mha节点,网站空间,mha管理服务器也需要安装。mha管理节点模块内部依赖mha节点模块;
mha管理节点通过ssh连接管理mysql服务器和执行mha节点脚本。mha节点依赖perl的dbd::mysql模块;
本文环境介绍,香港服务器,操作系统均为rhel5.4
主库:192.168.123.13/dg53.yang.com
备库:192.168.123.14/dg54.yang.com
管理节点:192.168.123.15/dg55.yang.com
在开始之前,请先配置好服务器间的时间同步和名称解析
一:在数据库节点安装mha node
二:管理节点
1:按照步骤一安装mha node
2:安装mha manager
3:编辑配置文件
4:配置manager节点和node节点以及node节点间的ssh公钥信任
5:测试ssh连接
6:测试主从复制情况,默认使用root用户连接
7:启动管理节点进程
三:测试failover过程
1:当前主库为192.168.123.13,关闭主库
2:在管理节点上观察日志输出
[root@dg55 ~]# tail -f /masterha/app1/manager.log
wed jun  6 14:50:48 2012 - [info]
192.168.123.13 (current master)
 +--192.168.123.14
wed jun  6 14:50:48 2012 - [warning] master_ip_failover_script is not defined.
wed jun  6 14:50:48 2012 - [warning] shutdown_script is not defined.
wed jun  6 14:50:48 2012 - [info] set master ping interval 1 seconds.
wed jun  6 14:50:48 2012 - [warning] secondary_check_script is not defined. it is highly recommended setting it to check master reachability from two or more routes.
wed jun  6 14:50:48 2012 - [info] starting ping health check on 192.168.123.13(192.168.123.13:3306)..
wed jun  6 14:50:48 2012 - [info] ping succeeded, sleeping until it doesn't respond..
wed jun  6 14:51:32 2012 - [warning] got error on mysql ping: 2006 (mysql server has gone away)
wed jun  6 14:51:32 2012 - [info] healthcheck: ssh to 192.168.123.13 is reachable.
wed jun  6 14:51:33 2012 - [warning] got error on mysql connect: 2013 (lost connection to mysql server at 'reading initial communication packet', system error: 111)
wed jun  6 14:51:33 2012 - [warning] connection failed 1 time(s)..
wed jun  6 14:51:34 2012 - [warning] got error on mysql connect: 2013 (lost connection to mysql server at 'reading initial communication packet', system error: 111)
wed jun  6 14:51:34 2012 - [warning] connection failed 2 time(s)..
wed jun  6 14:51:35 2012 - [warning] got error on mysql connect: 2013 (lost connection to mysql server at 'reading initial communication packet', system error: 111)
wed jun  6 14:51:35 2012 - [warning] connection failed 3 time(s)..
wed jun  6 14:51:35 2012 - [warning] master is not reachable from health checker!
wed jun  6 14:51:35 2012 - [warning] master 192.168.123.13(192.168.123.13:3306) is not reachable!
wed jun  6 14:51:35 2012 - [warning] ssh is reachable.
wed jun  6 14:51:35 2012 - [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..
wed jun  6 14:51:35 2012 - [warning] global configuration file /etc/masterha_default.cnf not found. skipping.
wed jun  6 14:51:35 2012 - [info] reading application default configurations from /etc/masterha/app1.cnf..
wed jun  6 14:51:35 2012 - [info] reading server configurations from /etc/masterha/app1.cnf..
wed jun  6 14:51:35 2012 - [info] dead servers:
wed jun  6 14:51:35 2012 - [info]   192.168.123.13(192.168.123.13:3306)
wed jun  6 14:51:35 2012 - [info] alive servers:
wed jun  6 14:51:35 2012 - [info]   192.168.123.14(192.168.123.14:3306)
wed jun  6 14:51:35 2012 - [info] alive slaves:
wed jun  6 14:51:35 2012 - [info]   192.168.123.14(192.168.123.14:3306)  version=5.5.25-log (oldest major version between slaves) log-bin:enabled
wed jun  6 14:51:35 2012 - [info]     replicating from 192.168.123.13(192.168.123.13:3306)
wed jun  6 14:51:35 2012 - [info]     primary candidate for the new master (candidate_master is set)
wed jun  6 14:51:35 2012 - [info] checking slave configurations..
wed jun  6 14:51:35 2012 - [warning]  read_only=1 is not set on slave 192.168.123.14(192.168.123.14:3306).
wed jun  6 14:51:35 2012 - [warning]  relay_log_purge=0 is not set on slave 192.168.123.14(192.168.123.14:3306).
wed jun  6 14:51:35 2012 - [info] checking replication filtering settings..
wed jun  6 14:51:35 2012 - [info]  replication filtering check ok.
wed jun  6 14:51:35 2012 - [info] master is down!
wed jun  6 14:51:35 2012 - [info] terminating monitoring script.
wed jun  6 14:51:35 2012 - [info] got exit code 20 (master dead).
wed jun  6 14:51:35 2012 - [info] mha::masterfailover version 0.52.
wed jun  6 14:51:35 2012 - [info] starting master failover.
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] * phase 1: configuration check phase..
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] dead servers:
wed jun  6 14:51:35 2012 - [info]   192.168.123.13(192.168.123.13:3306)
wed jun  6 14:51:35 2012 - [info] checking master reachability via mysql(double check)..
wed jun  6 14:51:35 2012 - [info]  ok.
wed jun  6 14:51:35 2012 - [info] alive servers:
wed jun  6 14:51:35 2012 - [info]   192.168.123.14(192.168.123.14:3306)
wed jun  6 14:51:35 2012 - [info] alive slaves:
wed jun  6 14:51:35 2012 - [info]   192.168.123.14(192.168.123.14:3306)  version=5.5.25-log (oldest major version between slaves) log-bin:enabled
wed jun  6 14:51:35 2012 - [info]     replicating from 192.168.123.13(192.168.123.13:3306)
wed jun  6 14:51:35 2012 - [info]     primary candidate for the new master (candidate_master is set)
wed jun  6 14:51:35 2012 - [info] ** phase 1: configuration check phase completed.
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] * phase 2: dead master shutdown phase..
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] forcing shutdown so that applications never connect to the current master..
wed jun  6 14:51:35 2012 - [warning] master_ip_failover_script is not set. skipping invalidating dead master ip address.
wed jun  6 14:51:35 2012 - [warning] shutdown_script is not set. skipping explicit shutting down of the dead master.
wed jun  6 14:51:35 2012 - [info] * phase 2: dead master shutdown phase completed.
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] * phase 3: master recovery phase..
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] * phase 3.1: getting latest slaves phase..
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] the latest binary log file/position on all slaves is mysql-bin.000021:107
wed jun  6 14:51:35 2012 - [info] latest slaves (slaves that received relay log files to the latest):
wed jun  6 14:51:35 2012 - [info]   192.168.123.14(192.168.123.14:3306)  version=5.5.25-log (oldest major version between slaves) log-bin:enabled
wed jun  6 14:51:35 2012 - [info]     replicating from 192.168.123.13(192.168.123.13:3306)
wed jun  6 14:51:35 2012 - [info]     primary candidate for the new master (candidate_master is set)
wed jun  6 14:51:35 2012 - [info] the oldest binary log file/position on all slaves is mysql-bin.000021:107
wed jun  6 14:51:35 2012 - [info] oldest slaves:
wed jun  6 14:51:35 2012 - [info]   192.168.123.14(192.168.123.14:3306)  version=5.5.25-log (oldest major version between slaves) log-bin:enabled
wed jun  6 14:51:35 2012 - [info]     replicating from 192.168.123.13(192.168.123.13:3306)
wed jun  6 14:51:35 2012 - [info]     primary candidate for the new master (candidate_master is set)
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] * phase 3.2: saving dead master's binlog phase..
wed jun  6 14:51:35 2012 - [info]
wed jun  6 14:51:35 2012 - [info] fetching dead master's binary logs..
wed jun  6 14:51:35 2012 - [info] executing command on the dead master 192.168.123.13(192.168.123.13:3306): save_binary_logs --command=save --start_file=mysql-bin.000021  --start_pos=107 --binlog_dir=/mydata --output_file=/var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.52
  creating /var/tmp if not exists..    ok.
 concat binary/relay logs from mysql-bin.000021 pos 107 to mysql-bin.000021 eof into /var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog ..
  dumping binlog format description event, from position 0 to 107.. ok.
  dumping effective binlog data from /mydata/mysql-bin.000021 position 107 to tail(126).. ok.
 concat succeeded.
wed jun  6 14:51:36 2012 - [info] scp from root@192.168.123.13:/var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog to local:/masterha/app1/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog succeeded.
wed jun  6 14:51:36 2012 - [info] healthcheck: ssh to 192.168.123.14 is reachable.
wed jun  6 14:51:37 2012 - [info]
wed jun  6 14:51:37 2012 - [info] * phase 3.3: determining new master phase..
wed jun  6 14:51:37 2012 - [info]
wed jun  6 14:51:37 2012 - [info] finding the latest slave that has all relay logs for recovering other slaves..
wed jun  6 14:51:37 2012 - [info] all slaves received relay logs to the same position. no need to resync each other.
wed jun  6 14:51:37 2012 - [info] searching new master from slaves..
wed jun  6 14:51:37 2012 - [info]  candidate masters from the configuration file:
wed jun  6 14:51:37 2012 - [info]   192.168.123.14(192.168.123.14:3306)  version=5.5.25-log (oldest major version between slaves) log-bin:enabled
wed jun  6 14:51:37 2012 - [info]     replicating from 192.168.123.13(192.168.123.13:3306)
wed jun  6 14:51:37 2012 - [info]     primary candidate for the new master (candidate_master is set)
wed jun  6 14:51:37 2012 - [info]  non-candidate masters:
wed jun  6 14:51:37 2012 - [info]  searching from candidate_master slaves which have received the latest relay log events..
wed jun  6 14:51:37 2012 - [info] new master is 192.168.123.14(192.168.123.14:3306)
wed jun  6 14:51:37 2012 - [info] starting master failover..
wed jun  6 14:51:37 2012 - [info]
from:
192.168.123.13 (current master)
 +--192.168.123.14
保山分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录