【mysql】【17】主主

1.机器

主机a
192.168.1.25
主机b
192.168.1.26

2.主机192.168.1.25上

server-id=1
log-bin=mysql-bin
auto_increment_offset=1
auto_increment_increment=1
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=test
replicate-ignore-db=mysql,information_schema
slave-skip-errors=all
log-slave-updates
sync_binlog=1
主机上执行
创建复制用户
grant replication slave on *.* to 'copy'@'192.168.1.26' IDENTIFIED BY 'xxxxx';
查看是否可以登录
mysql -h192.168.1.26 -ucopy -p	


查看数据库指针位置
show master status\G;
mysql-bin.000001
107
上锁
flush tables with read lock;
mysql -uroot -pxxx	
停止复制
stop slave;
设置复制位置
change master to master_host='192.168.1.26' ,master_user='copy' ,master_password='xxxxx',master_log_file='mysql-bin.000001',master_log_pos=107;
开始复制
start slave;
查看复制是否成功
show slave status\G;
解锁
unlock tables;

3.192.168.1.26机上配置

server-id=2
log-bin=mysql-bin
auto_increment_offset=1
auto_increment_increment=2
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=test
replicate-ignore-db=mysql,information_schema
slave-skip-errors=all
log-slave-updates
sync_binlog=1
从机上执行
创建复制用户
grant replication slave on *.* to 'copy'@'192.168.1.25' IDENTIFIED BY 'xxxxx';
查看是否可以登录
mysql -h192.168.1.25 -ucopy -pxxx	
show master status\G;
mysql-bin.000001
107
上锁
flush tables with read lock;
查看数据库指针位置

停止复制
stop slave;
设置复制位置
change master to master_host='192.168.1.25' ,master_user='copy' ,master_password='xxxxxx',master_log_file='mysql-bin.000001',master_log_pos=107;
开始复制
start slave;
查看复制是否成功
show slave status\G;
解锁
unlock tables;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值