mysql半同步复制配置

1.准备主备库配置文件,创建复制用户
主库server_id = 1 备库  server_id = 2, 重启数据库

GRANT REPLICATION SLAVE ON *.* TO repl@'192.168.137.%' IDENTIFIED BY 'repl123';

2.备份主库
mysqldump -uroot -p123456 --socket=/usr/local/mysql/mysql.sock --single-transaction -A --master-data=1 >all.sql

3.恢复到从库
source all.sql

4.建立复制关系并启动复制
查看binlog位置
CHANGE MASTER TO MASTER_LOG_FILE='binlog.000006', MASTER_LOG_POS=1169;
建立复制关系:
CHANGE MASTER TO MASTER_HOST='192.168.137.5',
MASTER_USER = 'repl',
MASTER_PASSWORD = 'repl123',
MASTER_PORT=3306,
MASTER_LOG_FILE='binlog.000006',
MASTER_LOG_POS=1169;

启动复制:
start slave
show slave status \G;

5.主从库安装半同步插件
show plugins;
主库
install plugin rpl_semi_sync_master SONAME 'semisync_master.so';
从库
install plugin rpl_semi_sync_slave SONAME 'semisync_slave.so';

6.设置主从库参数
主库:
set global rpl_semi_sync_master_enabled = 1;
set global rpl_semi_sync_master_timeout = 10000;

从库:
set global rpl_semi_sync_slave_enabled = 1;

7.重启复制
stop slave ;
start slave;
show global status like '%semi%';

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10972173/viewspace-2216257/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10972173/viewspace-2216257/

你可能感兴趣的:(数据库)