配置MHA的配置文件
cp /root/mha4mysql-manager-0.56/samples/scripts/* /usr/local/bin/
mkdir -p /etc/masterha
cp /root/mha4mysql-manager-0.56/samples/conf/app1.cnf /etc/masterha/
修改脚本的内容 vi /etc/masterha/app1.cnf
[server default]
user=root
password=
manager_workdir=/var/log/masterha/app1.log
manager_log=/var/log/masterha/app1/manager.log
master_binlog_dir=/var/lib/mysql
master_ip_failover_script=/usr/local/bin/master_ip_failover
master_ip_online_change_script=/usr/local/bin/master_ip_online_change
ssh_user=root
repl_user=slave
repl_password=123456
ping_interval=1
remote_workdir=/var/lib/mysql
secondary_check_script=/usr/local/bin/masterha_secondary_check -s 192.168.111.201 -s 192.168.111.202 -s 192.168.111.203
[server1]
hostname=192.168.111.201
port=3306
[server2]
hostname=192.168.111.202
port=3306
candidate_master=1
check_repl_delay=0
[server3]
hostname=192.168.111.203
port=3306
文件里面设置虚拟IP(添加到my(....);后面)
my $vip = '192.168.111.180/24';
my $key = "1";
my $ssh_start_vip = "/sbin/ifconfig eth1:$key $vip";
my $ssh_stop_vip = "/sbin/ifconfig eth1:$key down";
给主数据库服务器添加虚拟ip
网卡上增加一个IP:
ifconfig eth1:1 192.168.111.180/24 netmask 255.255.255.0
删除网卡的第二个IP地址:
ip addr del 192.168.111.180 dev eth1