部署运维

阿里云RDS Mysql 5.6 ECS自建从库(不锁表,不重启

2018-09-13  本文已影响2人  运维小吴

注意:你的备份的时间应该在你的binlog保存时间范围内

环境: 
主库: 阿里云RDS Mysql 5.6
从库: ECS机器上自建从库  Centos 7.4
参考链接:
备份: https://help.aliyun.com/document_detail/26206.html
恢复: https://help.aliyun.com/knowledge_detail/41817.html
[mysqld]
datadir=/opt/mysql-data ## 指定数据文件,根据setp 2的恢复操作
basedir=/opt/mysql

innodb_checksum_algorithm=innodb
innodb_data_file_path=ibdata1:200M:autoextend
innodb_log_files_in_group=2
innodb_log_file_size=572864000
innodb_undo_directory=.
innodb_undo_tablespaces=0
server-id               =  723456789   ## 这里只需要跟主库不一样就行了  
log_bin                 =  /opt/mysql-binlog/mysql-bin.log
expire_logs_days        =  7
max_binlog_size         =  100M
replicate-do-db         =  test     ## 此处为需要同步的库
replicate-ignore-db     =  mysql   ## 此处为不需要同步的库
gtid_mode=on
enforce_gtid_consistency=on
binlog_format=row                                     ## 阿里云RDS开启ROW(默认就是)
relay_log=/opt/mysql-relay-data/relay.log
log-slave-updates=1
可能会遇到的问题:
[ERROR] Error creating master info: Error removing old repository.
[ERROR] Failed to create or recover replication info repository.
解决:
use mysql
drop table mysql.innodb_index_stats;
 drop table mysql.innodb_table_stats;
 drop table mysql.slave_master_info;
 drop table mysql.slave_relay_log_info;
 drop table mysql.slave_worker_info;
source /opt/mysql/share/mysql_system_tables.sql
在具体的数据目录(就是你恢复备份的文件夹)
/opt/mysql-data/xtrabackup_info
找到以下这行,取最后一条 c619dfe7-04aa-11e8-dbf4-6c92bf3fe77d:1-325898712,
e3f32949-04ac-11s8-bbw5-0425c5dcs34b:1-207283


binlog_pos = filename 'mysql-bin.001477', position 87871098, GTID of the last change 'c619dfe7-04aa-11e8-dbf4-6c92bf3fe77d:1-325898712,
e3f32949-04ac-11s8-bbw5-0425c5dcs34b:1-207283'
进入mysql
reset slave;
reset master;
change master to master_auto_position=1;
SET @@GLOBAL.GTID_PURGED='c619dfe7-04aa-11e8-dbf4-6c92bf3fe77d:1-325898712,
e3f32949-04ac-11s8-bbw5-0425c5dcs34b:1-207283';
change master to master_host = 'RDS地址' ,master_port = 3306, master_user = 'RDS用户',master_password='RDS密码';

启动slave

start slave;
上一篇下一篇

猜你喜欢

热点阅读