Skip to main content

初始主节点master配置:

yum install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-CPAN

yum install perl-Mail-Sender yum install perl-Log-Dispatch

非常简单,只要加上一个--force (强制) 和--nodeps(不查找依赖关系)就可以了

如:rpm -vih httpd-2.2.3-6.el5.i386.rpm --force --nodeps

https://downloads.mariadb.com/MHA/

https://downloads.mariadb.com/MHA/mha4mysql-node-0.56.tar.gz

https://downloads.mariadb.com/MHA/mha4mysql-manager-0.56.tar.gz

tar xf mha4mysql-manager-0.57.tar.gz cd mha4mysql-manager-0.57 perl Makefile.PL make && make install

https://m.aliyun.com/yunqi/articles/57845

创建监控用户

grant all privileges on . to 'mha'@'%' identified by '123456';

mkdir -p /etc/mha 建立配置目录

mkdir -p /home/mysql_mha 建立工作目录

vi /etc/mha/mysql_mha.cnf

[server default]

user=mha

password=123456

manager_workdir=/home/mysql_mha

manager_log=/home/mysql_mha/manager.log

remote_workdir=/home/mysql_mha

ssh_user=root

repl_user=slave

repl_password=123456

ping_interval=1

master_binlog_dir=/var/lib/mysql

master_ip_failover_script=/usr/local/bin/master_ip_failover

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

candidate_master=1

[server2]

hostname=192.168.111.202

candidate_master=1

[server3]

hostname=192.168.111.203

no_master=1

运行监测程序

监测SSH连接

masterha_check_ssh --conf=/etc/mha/mysql_mha.cnf

监测mysql的连接

masterha_check_repl --conf=/etc/mha/mysql_mha.cnf

nohup masterha_manager --conf=/etc/mha/mysql_mha.cnf &

去master服务上配置虚拟ip

ifconfig eth1:1 192.168.111.180/24

masterha_check_status --conf=/etc/mha/mysql_mha.cnf