MySQL-主从复制


拓扑结构为:A (master)-B(A的slave,同时作为C的master)-C(B的slave)

A:3308
[mysqld]
server-id=111

GRANT REPLICATION SLAVE ON *.* TO 'backup'@'localhost' IDENTIFIED BY '';    //backup user

GRANT ALL ON *.* TO 'proxy1'@'localhost' IDENTIFIED BY '112233';    //数据库操作

show master status;    // 查看master状态,为slave提供数据

B:3309
[mysqld]
server-id=222
log_slave_updates=1    #当有数据更新时会写binarylog,从而写入到C

GRANT REPLICATION SLAVE ON *.* TO 'backup'@'localhost' IDENTIFIED BY '';    //backup user

GRANT ALL ON *.* TO 'proxy1'@'localhost' IDENTIFIED BY '112233';    //数据库操作

change master to
master_host='localhost',
master_port=3308,
master_user='backup',
master_password='',
master_log_file='--',    // 3308 master status
master_log_pos=--;    // 3308 master status

start slave;    // 执行同步进程
show slave status\G    //主从同步检查
//slave 进程正常状态 --Slave_IO_Running: Yes Slave_SQL_Running: Yes


show master status;

C:3310
[mysqld]
server-id=333

change master to
master_host='localhost',
master_port=3309,
master_user='backup',
master_password='',
master_log_file='--',    // 3309 master status
master_log_pos=--;    // 3309 master status

start slave;    // 执行同步进程
show slave status\G    //主从同步检查


PS:
这三个数据库都创建相同的用户proxy1/112233,为后续做读写分离准备

转链接:http://freeloda.blog.51cto.com/2033581/1282329

猜你喜欢

转载自bena.iteye.com/blog/2164908