您的位置:首页 > 博客中心 > 数据库 >

Mysql-主主同步

时间:2022-03-14 13:46

主主复制架构


主服:192.168.1.84

副主服:192.168.1.85


1.主服配置文件

在[mysqld]中添加

sync_binlog = 1

任何一个事物提交之后就立即写入到磁盘中的二进制文件

innodb_flush_log_at_trx_commit = 1

任何一个事物提交之后就立即写入到磁盘中的日子文件

2.副主服配置文件

在[mysqld]中添加

skip_slave_start = 1   或配置前执行  mysql > stop slave;

设定从服务器开启的时候,从服务器进程不开启,这样可以使我们有时间对从服务器进行配置

read_only = 1

设定从服务器只能进行读操作,不能进行写操作,保证数据同步(此时用super用户仍能进行写操作)

3.主服配置文件

在[mysqld]中添加

auto-increment-increment = 2

auto-increment-offset = 1

4.副主服配置文件

在[mysqld]中添加

log-bin = mysql-bin

auto-increment-increment = 2

auto-increment-offset = 2

重启主、副主服务器

5.主、从

mysql> grant replication client,replication slave on *.* to repl@‘192.168.1.84‘ identified by ‘123456‘;

mysql> grant replication client,replication slave on *.* to repl@‘192.168.1.85‘ identified by ‘123456‘;


双双配置主从为--主主同步(参考我的博客mysql-主从同步:)


mysql> show slave status\G

如果出现如下两行,则说明工作正常:

Slave_IO_Running: Yes

Slave_SQL_Running: Yes


本文出自 “” 博客,谢绝转载!

本类排行

今日推荐

热门手游