mysql数据库复制—双主
时间:2022-03-13 22:54
mysql>grant replication slave on *.* to ‘user2‘@‘172.16.20.%‘ identified by
‘password2‘;
mysql>flush privileges;
3记录二进制日志位置
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 | 253 | | |
+------------------+----------+--------------+------------------+
四、启动复制
1master1启动复制
mysql>CHANGE MASTER TO
MASTER_HOST=‘172.16.20.219‘,
MASTER_USER=‘user2‘,
MASTER_PASSWORD=‘passwd2‘,
MASTER_LOG_FILE=‘master-bin.000002‘,
MASTER_LOG_POS=253;
mysql>start slave;
#或者单独START SLAVE IO_Thread;START SLAVE SQL_Thread;来启动这两个线程
master2启动复制
mysql>CHANGE MASTER TO
MASTER_HOST=‘172.16.20.245‘,
MASTER_USER=‘user‘,
MASTER_PASSWORD=‘passwd‘,
MASTER_LOG_FILE=‘master-bin.000003‘,
MASTER_LOG_POS=353;
mysql>start slave;
#或者单独START SLAVE IO_Thread;START SLAVE SQL_Thread;来启动这两个线程
五、检查
mysql>show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
以上连个进程启动则表示双主复制启动,双主复制安装完成。
本文出自 “” 博客,谢绝转载!
mysql数据库复制—双主,布布扣,bubuko.com