赞
踩
目录
用作manager(MHA),即mgt
用作master
用作slave1
用作slave2
注:192.168.42.4 | 5 | 6,为node
vim /etc/hosts
192.168.42.3 mgt
192.168.42.4 master
192.168.42.5 slave1
192.168.42.6 slave2
ssh-keygen
for i in 4 5 6;do ssh-copy-id root@192.168.42.$i;done
ssh-keygen
for i in 3 5 6;do ssh-copy-id root@192.168.42.$i;done
ssh-keygen
for i in 4 3 6;do ssh-copy-id root@192.168.42.$i;done
ssh-keygen
for i in 4 5 3;do ssh-copy-id root@192.168.42.$i;done
for i in 3 4 5;do ssh 192.168.42.$i hostname;done
vim /etc/my.cnf
[mysqld]
server-id = 20
log-bin = master-bin
log-slave-updates = true
systemctl restart mariadb
mysql -e "grant replication slave on *.* to 'myslave'@'192.168.42.%' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.42.%' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.42.3' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.42.5' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.42.6' identified by '123.com';"
mysql -e "show master status";
vim /etc/my.cnf
server-id=30
log-bin=master-bin
relay-log=relay-log-bin
relay-log-index=relay-log-bin.index
systemctl restart mariadb
mysql -e "grant replication slave on *.* to 'myslave'@'192.168.42.%' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.42.%' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.42.3' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.42.5' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.42.6' identified by '123.com';"
mysql -e "change master to master_host='192.168.42.4',master_user='myslave',master_password='123.com',master_log_file='master-bin.000003',master_log_pos=1002;"
mysql -e "slave start;"
master
mysql -e "create database ea;"
slave1
mysql -e "show databases;"
slave2
mysql -e "show databases;"
yum install epel-release -y
yum -y install perl-DBD-MySQL perl-ExtUtils-MakeMaker perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-Time-HiRes perl-CPAN
tar xf mha4mysql-node-0.57.tar.gz
cd mha4mysql-node-0.57
perl Makefile.PL && make && make install
cd /usr/local/bin
看到脚本就OK
tar xf mha4mysql-manager-0.57.tar.gz
cd /root/mha4mysql-manager-0.57
perl Makefile.PL && make && make install
cp samples/scripts/master_ip_failover /usr/local/bin/
cp samples/scripts/master_ip_online_change /usr/local/bin/
master_ip_failover 自动切换时 VIP 管理的脚本
master_ip_online_change 在线切换时 vip 的管理
power_manager 故障发生后关闭主机的脚本
send_report 因故障切换后发送报警的脚本
mkdir /etc/masterha
vim /etc/masterha/app1.cnf
mkdir /var/log/masterha/app1
vim /usr/local/bin/master_ip_failover
masterha_check_ssh --conf=/etc/masterha/app1.cnf
masterha_check_repl --conf=/etc/masterha/app1.cnf
nohup masterha_manager --conf=/etc/masterha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/masterha/app1/manager.log 2>&1 &
需要工程手动配置VIP
停用master的mariadb服务
systemctl stop mariadb
切换到slave1上
ip a
成功。
修改app1.cnf启动配置:添加master主机配置信息
分别在slave上重新指定master主机及binlog日志同步信息
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。