环境:四台主机
manager,master,slave1,slave2
1 准备
selinux ,iptables ,time
四个主机实现ssh key验证
2 在manager节点
yum install mha4mysql-manager-0.56-0.el6.noarch.rpm mha4mysql-node-0.56-0.el6.noarch.rpm
vim /etc/mastermha/app1.cnf
[server default]
user=mhauser
password=magedu
manager_workdir=/data/mastermha/app1/
manager_log=/data/mastermha/app1/manager.log
remote_workdir=/data/mastermha/app1/
ssh_user=root
repl_user=repluser
repl_password=magedu
ping_interval=1
[server1]
hostname=192.168.8.17
candidate_master=1
[server2]
hostname=192.168.8.27
candidate_master=1
[server3]
hostname=192.168.8.37
3在master,slave1,slave2
yum install mha4mysql-node-0.56-0.el6.noarch.rpm
4 在master
vim /etc/my.cnf
[mysqld]
log-bin
server_id=1
skip_name_resolve=1
mysql>show master logs
mysql>grant replication slave on *.* to repluser@'192.168.8.%' identified by ‘magedu';
mysql>grant all on *.* to mhauser@‘192.168.8.%’ identified by ‘magedu‘;
5在slave1和slave2上
vim /etc/my.cnf
[mysqld]
server_id=2 不同节点此值各不相同
log-bin
read_only
relay_log_purge=0
skip_name_resolve=1
mysql>CHANGE MASTER TO MASTER_HOST=‘MASTER_IP', MASTER_USER='repluser', MASTER_PASSWORD=‘magedu', MASTER_LOG_FILE='mariadb-bin.000001', MASTER_LOG_POS=245;
6 在manager节点上
masterha_check_ssh --conf=/etc/mastermha/app1.cnf 检测
masterha_check_repl --conf=/etc/mastermha/app1.cnf 检测
masterha_manager --conf=/etc/mastermha/app1.cnf 启动mha