欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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

程序员文章站 2022-05-11 08:23:56
...
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
相关标签: mysql 开启