基于Docker的阿里云RDS从库部署

点点圈 提交于 2020-01-02 01:25:24

1.获取备份文件,从阿里控制台上可以下载

2.解压

获取解压脚本

wget 'http://oss.aliyuncs.com/aliyunecs/rds_backup_extract.sh?spm=5176.775973700.0.0.n9b8wj&file=rds_backup_extract.sh' -O rds_backup_extract.sh

执行解压

bash rds_backup_extract.sh -f full.tar.gz -C /data/mysql/站点名称

3.启动容器

docker run --name 项目名  -v /data/mysql/站点名:/var/lib/mysql -p 33003:3306 -d percona5.6(为定制后镜像)

4.进入容器数据库执行

truncate table cartier love necklace  mysql.slave_relay_log_info;
truncate table  mysql.slave_master_info;
truncate table  mysql.slave_worker_info;

5.重启容器

docker restart 容器名

6.进入容器数据库设置global gtid

该配置文件位于备份下来的数据文件xtrabackup_slave_info内

7.设定master info

change master to master_host='rds外网地址',master_user='账号',master_port=3306,master_password='密码',master_auto_position=1;

8.检查同步状态

show slave status\G

9.容器内my.cnf配置文件如下

[mysqld]
#skip-grant-tables
user    = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket  = /var/run/mysqld/mysqld.sock
port    = 3306
datadir = /var/lib/mysql
log-bin         = mysql-bin
server-id       = 33001
log-error       = /var/log/mysql/error.log
#relay_log=/data/percona3310/relay-log.000001

master-info-repository=file
relay-log-info_repository=file
binlog-format=ROW
gtid-mode=on
enforce-gtid-consistency=true
read_only = on
binlog-format=ROW
log-bin=mysql-bin                                                                                                                            
log-bin-index=mysql-bin.index                                                                                                                
innodb_file_per_table = 1                                                                                                                    
relay-log = relay-log                                                                                                                        
relay-log-index = relay-log.index
log-slave-updates=true
sync-master-info=1                                                                                                                           
slave-parallel-workers=2                                                                                                                     
binlog-checksum=CRC32                                                                                                                        
master-verify-checksum=1                                                                                                                     
slave-sql-verify-checksum=1                                                                                                                  
binlog-rows-query-log_events=1                                                                                                               
report-port=3306                                                                                                                            
report-host=202.131.80.74                                                                                                                    

innodb_checksum_algorithm=innodb
innodb_log_checksum_algorithm=innodb
innodb_data_file_path=ibdata1:200M:autoextend
innodb_log_files_in_group=2
innodb_log_file_size=1572864000
#innodb_fast_checksum=false
#innodb_page_size=16384
#innodb_log_block_size=512
innodb_undo_directory=.
innodb_undo_tablespaces=0

#rds_encrypt_data=false
#innodb_encrypt_algorithm=aes_128_ecb
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!