-
环境筹备
- 192.168.32.130 – 主库
- 192.168.32.131 – 从库
- 主库 my.cnf 减少以下配置
log-bin=mysql-bin
server-id=123
- 从库 my.cnf 减少以下配置
server-id=124
- 主库上执行 SQL
CREATE USER 'repl'@'192.168.32.%' IDENTIFIED BY '123456';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.32.%';
SHOW MASTER STATUS;
- 从库上执行 SQL
CHANG MASTER TO MASTER_HOST='192.168.128.130', MASTER_USER='repl', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=10368;
START SLAVE;
SHOW SLAVE STATUS;
- 验证主从同步性能