mysql主主+keepalived高可用
--------------------------db1操作:-------------------------- mysql -uroot -p123456mysql> grant replication slave on *.* to 'rep'@'172.16.1.52'> mysql> flush privileges;
mysql> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000015
Position: 234
Binlog_Do_DB:
Binlog_Ignore_DB: mysql,information_schema,performance_schema,amh
Executed_Gtid_Set: 79a90ed3-fa86-11e7-ac66-000c29542a93:1-3,
9238586c-fa86-11e7-acab-000c29f6ed58:1-5
1 row in set (0.00 sec)
###【这一步需要自己查看主库最新mysql-bin和pos,下面有查看】
mysql> change master to
> master_host='172.16.1.52',
> master_user='rep',
> master_password='123456',
> master_log_file='mysql-bin.000024', #这个地方是主库的最新mysql-bin
> master_log_pos='234'; #主库的最新pos
mysql> start slave;
mysql> show slave status\G
###生产环境如果要修改数据库架构不建议这么做,适合新部署,开启gtid功能
###mysql> stop slave;
###mysql> change master to MASTER_AUTO_POSITION=1;
--------------------------db2操作:----------------------------
mysql> grant replication slave on *.* to 'rep'@'172.16.1.51'> mysql> flush privileges;
mysql> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000024
Position: 234
Binlog_Do_DB:
Binlog_Ignore_DB: mysql,information_schema,performance_schema,amh
Executed_Gtid_Set: 79a90ed3-fa86-11e7-ac66-000c29542a93:1-3,
9238586c-fa86-11e7-acab-000c29f6ed58:1-5
1 row in set (0.00 sec)
###【这一步需要自己查看主库最新mysql-bin和pos,上面有查看】
mysql> change master to
> master_host='172.16.1.51',
> master_user='rep',
> master_password='123456',
> master_log_file='mysql-bin.000015',
> master_log_pos='234';
mysql> start slave;
mysql> show slave status\G
###生产环境不建议这么做,开启gtid功能
###mysql> stop slave;
###mysql> change master to MASTER_AUTO_POSITION=1;
页:
[1]