注意:mha-manager暂时不支持centos8版本,避免踩坑
注意:mha-manager暂时不支持centos8版本,避免踩坑
注意:mha-manager暂时不支持centos8版本,避免踩坑
ssh-keygen -t rsa
ssh-copy-id 192.168.220.131
cat /root/.ssh/authorized_keys
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
scp /root/.ssh/authorized_keys root@192.168.220.128:/root/.ssh/authorized_keys
scp /root/.ssh/authorized_keys root@192.168.220.129:/root/.ssh/authorized_keys
scp /root/.ssh/authorized_keys root@192.168.220.130:/root/.ssh/authorized_keys
ssh 192.168.220.128
exit
ssh 192.168.220.129
exit
ssh 192.168.220.130
exit
mha-manager(mha-manager的机器):
https://github.com/yoshinorim/mha4mysql-manager/releases/tag/v0.58
mha-node(3台mysql的机器):
https://github.com/yoshinorim/mha4mysql-node/releases/tag/v0.58
yum install perl-DBD-MySQL -y
wget https://github.com/yoshinorim/mha4mysql-node/releases/download/v0.58/mha4mysql-node-0.58-0.el7.centos.noarch.rpm
rpm -ivh mha4mysql-node-0.58-0.el7.centos.noarch.rpm
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager -y
wget https://github.com/yoshinorim/mha4mysql-manager/releases/download/v0.58/mha4mysql-manager-0.58-0.el7.centos.noarch.rpm
rpm -ivh mha4mysql-manager-0.58-0.el7.centos.noarch.rpm
mkdir -p /var/log/mha/app1
touch /var/log/mha/app1/manager.log
在三台mysql库下执行以下命令
create user 'mha'@'%' identified with mysql_native_password by '123456';
grant all privileges on *.* to 'mha'@'%' with grant option;
flush privileges;
vim /etc/masterha_default.cnf
[server default]
user=mha
password=123456
port=3306
ssh_user=root
repl_user=root
repl_password=123456
port=3306
ping_interval=1
secondary_check_script=masterha_secondary_check -s 192.168.220.128 -s 192.168.220.129 -s 192.168.220.130
mkdir -p /etc/mha
vim /etc/mha/app1.cnf
[server default]
manager_workdir=/var/log/mha/app1
manager_log=/var/log/mha/app1/manager.log
[server1]
hostname=192.168.220.128
candidate_master=1
master_binlog_dir="/usr/local/mysql/data"
[server2]
hostname=192.168.220.129
candidate_master=1
master_binlog_dir="/usr/local/mysql/data"
[server3]
hostname=192.168.220.130
candidate_master=1
master_binlog_dir="/usr/local/mysql/data"
ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
masterha_check_ssh --conf=/etc/mha/app1.cnf
masterha_check_repl --conf=/etc/mha/app1.cnf
nohup masterha_manager --conf=/etc/mha/app1.cnf --remove_dead_master_conf -- ignore_last_failover < /dev/null > /var/log/mha/app1/manager.log 2>&1 &
masterha_check_status --conf=/etc/mha/app1.cnf
tail -f /var/log/mha/app1/manager.log
tail -200f /var/log/mha/app1/manager.log
service mysql stop