AWS上搭建MySQL主从-配置半自动异步复制策略

1、准备机器

worker-smarthome     主  172.31.76.147
worker-oss                 从  172.31.80.14

2、rpm安装msql yum源
这里安装MySQL5.7版本,MySQL5.7版本

$ wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'
$ sudo rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
$ yum repolist all | grep mysql

3、安装数据库

$ yum install -y mysql-community-server

4、启动mysql,并查看mysql状态

$ systemctl enable mysqld
$ systemctl start  mysqld
$ systemctl status mysqld

5、查看mysql临时密码

$ grep "password" /var/log/mysqld.log


2018-07-19T09:26:49.073788Z 1 [Note] A temporary password is generated for root@localhost: &&s%n)XXXX

6、修改密码并允许远程登录

$ mysql -uroot -p


  输入初始密码,此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库:

mysql> set global validate_password_policy=0;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

允许远程连接:

mysql> CREATE USER 'slave'@'localhost' IDENTIFIED BY '123456';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'new password' WITH GRANT OPTION;
mysql>flush privileges;


 
6、永久关闭selinux

$ vim /etc/selinux/config


将SELINUX=enforcing改为SELINUX=disabled,保存后退出

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

7、重启
此时获取当前selinux防火墙的安全策略仍为Enforcing,配置文件并未生效。

$ getenforce

Enforcing


重启机器

$ reboot
验证

$ /usr/sbin/sestatus
SELinux status:                 disabled
$ getenforce
Disabled

8、创建软链接:

$ mv /var/lib/
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值