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到從機上恢復數據庫 www.2cto.com
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的專欄