服务器A. 配置文件:
server-id=1
log-bin="mysql-bin"
binlog-do-db=replicatietest
replicate-do-db=replicatietest
relay-log="mysql-relay-log"
auto-increment-increment = 2
auto-increment-offset = 1
命令:
CREATE USER 'replicator'@'%' IDENTIFIED BY 'Slave123';
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%' IDENTIFIED BY 'Slave123';
SHOW MASTER STATUS;
--> mysql-bin.000003 397 replicatietest
STOP SLAVE;
CHANGE MASTER TO MASTER_HOST = 'Server A IP Address', MASTER_USER = 'replicator', MASTER_PASSWORD = 'Slave123', MASTER_LOG_FILE = 'mysql-bin.000003', MASTER_LOG_POS = 397;
START SLAVE;
--> OK
服务器B. 配置文件:
server-id=2
log-bin="mysql-bin"
binlog-do-db=replicatietest
replicate-do-db=replicatietest
relay-log="mysql-relay-log"
auto-increment-increment = 2
auto-increment-offset = 2
命令
CREATE USER 'replicator'@'%' IDENTIFIED BY 'Slave123';
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%' IDENTIFIED BY 'Slave123';
SHOW MASTER STATUS;
--> mysql-bin.000001 154 replicatietest
STOP SLAVE;
CHANGE MASTER TO MASTER_HOST = 'Server B IP Address', MASTER_USER = 'replicator', MASTER_PASSWORD = 'Slave123', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS = 154;
START SLAVE;
--> OK
我可以ping ip地址。但是当我在replicatietest中更改服务器A中的某些内容时,我在服务器B中看不到任何内容。
服务器A和B都有方案replicatietest。