日期:2014-05-16  浏览次数:20384 次

mysql数据库同步热备(双向以及单向)

环境:

Master server: 10.224.194.239

Slave??? server: 10.224.194.237

步骤:

1.分别在Master/Slaver mysql db 创建backup user:

GRANT FILE ON *.* TO backup@10.224.194.239 IDENTIFIED BY 'pass';

GRANT REPLICATION SLAVE ON *.* TO backup@10.224.194.239 IDENTIFIED BY 'pass';

?

GRANT FILE ON *.* TO backup@10.224.194.237 IDENTIFIED BY 'pass';

GRANT REPLICATION SLAVE ON *.* TO backup@10.224.194.237 IDENTIFIED BY 'pass';

2.在Master server配置/etc/my.cf 文件:

log-bin

server-id = 1

binlog-do-db=test

binlog-ignore-db = mysql

//只保存7天的log-bin日志

expire-logs-days = 7

?

replicate-do-db=test

replicate-ignore-db = mysql

?

master-host=10.224.194.237

master-user=backup

master-password=pass