MySQL master热备份 开启主从复制_MySQL
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