Prepared four servers
First: c7m01 10.0.0.12 mysql-master
Second stage: c7s02 10.0.0.13 mysql-slave (standby master) slave01
Third stage: c7s03 10.0.0.14 mysql-slave slave02
Radio 4: c7a04 10.0.0.15 mha + atlas
vip 10.0.0.100 bound to mysql-master
Four servers to perform the same operation, time synchronization
[root@ localhost ~]# echo "*/5* * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1" >>/var/spool/cron/root
Modify the host name of the four servers
mysql-master main
[root@ localhost ~]# vim /etc/hostname
c7m01
mysql-slave from (standby master)
[root@ localhost ~]# vim /etc/hostname
c7s02
mysql-slave from
[root@ localhost ~]# vim /etc/hostname
c7s03
mha + atlas (separate read and write)
[root@ localhost ~]# vim /etc/hostname
c7a04
Note: The host name changes need to reboot after completion, it will not take effect
Configure the hosts in the mysql-master mysql-slave resolve (the host name to the host name and their correspondence)
[root@ c7m01 ~]# vim /etc/hostEOF C7m01 10.0 . 0.12 C7s02 10.0 . 0.13 C7s03 10.0 . 0.14
Turn off the firewall and selinux (four servers to perform the same operation)
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
[root@ c7m01 ~]# sed -i ' /^SELINUX/s#enforcing#disabled#g' /etc/selinux/config
Configure a free confidential login (four servers have to perform, here I wrote a shell script)
[root@ c7a04 ~]# vim ssh.sh #!/bin/bash yum -y install sshpass &> / dev / null the Read -p " Enter the server password: " passwd UserName=root IP="10.0.0." # Create the key ssh-keygen -t dsa -f ~/.ssh/id_dsa -P "" &>/dev/null # Distribute a public key for I in 12 is 13 is 14 15 # where the loom to change their IP do sshpass -p " $ the passwd " SSH-Copy-ID -i ~ / .ssh / id_dsa.pub -p 22 is -o $ StrictHostKeyChecking UserName = NO IP & $ i $ @> / dev / null DONE
Execute scripts (four servers must execute the script), and then try to connect one of the servers, if there is no secret free login, that is success
mysql installation yum repo (three servers performing the same operation c7m01, c7s02, c7s03)
[root@ c7m01 ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm [root@ c7m01 ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm [root@ c7m01 ~]# yum -y install mysql-server
Start MySQL, c7m01, c7s02, c7s03 three servers to perform the same operation