基於Docker的阿里雲RDS從庫部署

1.獲取備份文件,從阿里控制檯上能夠下載

2.解壓

獲取解壓腳本mysql

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

執行解壓sql

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內docker

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
相關文章
相關標籤/搜索