MHA的介绍
环境准备
1.准备三台服务器
2.修改主机名(两种方式)
方便区分每台服务器
方式一
hostnamectl set-hostname 要修改的名字 //然后重新连接xshell就可以了
方式二
vim /etc/hostname //编辑配置文件,里面填写为修改后的名字,这个有一个注意的地方就是要重启服务器
3.三台机器都做相同的操作
1.时间同步
echo "*/5 * * * * /usr/sbin/ntpade ntp1.aliyun.com >/del/null 2>&1" >>/var/spool/cron/root
2.hosts解析
vim /etc/hosts ##加入以下内容
chen1 10.0.0.41
chen2 10.0.0.42
chen3 10.0.0.43
3.关闭防火墙和SELinux
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
4.互相配置ssh免密登录 我这里是用脚本实现的可以参考
https://blog.csdn.net/weixin_46164213/article/details/103901670
5.安装MySQL5.6以上的版本
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-server 安装
systemctl start mysqld 开启服务
6.修改MySQL的密码
mysql> update mysql.user set password=password('123456') where user='root' and host='localhost';
mysql> flush privileges;