首页 >数据库 >mysql教程 >MySQL master热备份 开启主从复制_MySQL

MySQL master热备份 开启主从复制_MySQL

WBOY
WBOY原创
2016-06-01 13:44:071225浏览

bitsCN.com

 

1 开启binlog

mysql

server-id                       = 151

log-bin                         =/opt/soft/mysql/binlog/mysql-bin

binlog_format                    = MIXED

2 获得基础备份

/opt/soft/mysql/bin/mysqldump -p123456 --single-transaction --master-data=2 AdDataCenter | gzip >AdDataCenter.sql.gz

3 开通用于binlog 复制的 用户

GRANT REPLICATION SLAVE ON *.* TO'repat152'@'192.168.%'  IDENTIFIED BY'123456';

4到从机上恢复数据库

gzip –cd AdDataCenter.sql.gzip | opt/soft/mysql/bin/mysql –p123456 AdDataCenter

5 设置复制库选项

gzip -cd AdDataCenter.sql.gz | grep -i"CHANGE MASTER TO"

得到binlog 文件和binlog pos

CHANGEMASTER TO MASTER_HOST='master_host_name',MASTER_USER='replication_user_name',MASTER_PASSWORD='replication_password',MASTER_LOG_FILE='recorded_log_file_name',ASTER_LOG_POS=recorded_log_position;

6 开启从库复制

Start slave

 

摘自 ylqmf的专栏

bitsCN.com
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn