Home >Database >Mysql Tutorial >MySQL master热备份 开启主从复制_MySQL

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

WBOY
WBOYOriginal
2016-06-01 13:44:071223browse

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
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn