Mysql 异步复制
下载mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
tar xf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
Server1:172.25.13.1 主master
Server2:172.25.13.2 备slave
yum install mysql-community-client-5.7.28-1.el7.x86_64.rpm mysql-community-common-5.7.28-1.el7.x86_64.rpm mysql-community-devel-5.7.28-1.el7.x86_64.rpm mysql-community-libs-5.7.28-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm mysql-community-server-5.7.28-1.el7.x86_64.rpm -y
systemctl start mysqld 开启服务
cat /var/log/mysqld.log | grep password 查看首次启动生成的密码安全初始化
mysql_secure_installation 安全初始化
server2的配置和server1一样安装软件安全初始化修改密码
Server1:vim /etc/my.cnf
log-bin=mysql-bin
server-id=1
systemctl restart mysqld
Server2:vim /etc/my.cnf
server-id=2
systemctl restart mysqld
server2:
mysql -h 172.25.27.1 -urepl -pWestos+001
能登陆则说明server1配置成功
server2:
Mysql -ueoot -pRedhat=123
mysql>change master to master_host='172.25.13.1',master_user='repl',master_password='Redhat=123',master_log_file='mysql-bin.000001',master_log_pos=447;
mysql>start slave; #开启复制
smysql>how slave status\G; #查看状态
server1:
mysql> create database westos;
mysql> use wetsos
mysql>create table redhat(
-> username varchar(10) not null,
-> password varchar(10) not null);
mysql> insert into redhat values ('user1','123');
server2:查看
GTID复制
Server1 and server2
Vim /etc/my.cnf 添加
gtid_mode=ON
enforce-gtid-consistency=true
重新启动两台主机服务
systemctl restart mysqld
Server2:
mysql> stop slave;
mysql> change master to master_host='172.25.13.1',master_user='repl',master_password='Redhat=123',master_auto_position=1;
mysql> start slave;
Server1;写入数据
mysql> use westos;
mysql> insert into redhat values ('user2''123');
mysql> select * from redhat;
Server2:查看