MHA部署实现高可用(1)

环境准备:

三台 CentOS 7 机器  可联网 

永久修改机器名称,断开三台机器xshell重连实现名称的修改

hostnamectl set-hostname c731
hostnamectl set-hostname c732
hostnamectl set-hostname c733

c731 192.168.37.31
c732 192.168.37.32
c733 192.168.37.33

一、以下需要在三台机器上操作

1)三台机器分别操作时间同步

 echo "*/5 * * * * /usr/sbin/netpdate ntp1.aliyun.com >/dev/null 2>&1" >>/var/spool/cron/root 

2)hosts解析

[root@c732 ~]# cat >>/etc/hosts<<EOF
c731    192.168.37.31
c732    192.168.37.32
c733    192.168.37.33
EOF

3)关闭防火墙和selinux

sed -i '/^SELINUX/s#enforcing#disabled#g' /etc/selinux/config

4)互相配置ssh免密码登录   (相互,最好不要禁止密码登录)

#!/bin/bash
yum -y install sshpass &> /dev/null
read -p "请输入服务器密码:" passwd
UserName=root
IP="192.168.37."
#创建密钥
ssh-keygen -t dsa -f ~/.ssh/id_dsa -P "" &>/dev/null
#分发公钥
for i in 31 32 33
  do
    sshpass -p "$passwd" ssh-copy-id -i ~/.ssh/id_dsa.pub -p 22 -o StrictHostKeyChecking=no $UserName@$IP$i &>/dev/null
done

二、mysql主从配置

1)安装yum  repo

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

2)启动mysql并修改密码

systemctl restart mysql

update mysql.user set password=password('123456') where user='root' and host='localhost';

 

 

posted @ 2020-02-13 18:27  Security  阅读(286)  评论(0编辑  收藏  举报