티스토리 뷰

Master server

$ mysql -uroot -p

mysql> GRANT REPLICATION SLAVE ON *.* to 'repl'@'172.%' IDENTIFIED BY 'repl-password-here';

mysql> flush tables with read lock;

mysql> reset master;

# Make note of the file name and file position

mysql> show master status;

$ /etc/init.d/mysql stop

$ xfs_freeze -f /mnt/mysql

# Take AWS EC2 EBS snapshot and when it begins do next step

$ xfs_freeze -u /mnt/mysql

$ /etc/init.d/mysql start

$ mysql -uroot -p

mysql> unlock tables;

Wait for WAS to finish writing the EBS snapshot before proceeding.


Slave server

  1. EBS snapshot is complete
  2. create a new volume from snapshot
  3. umount old volume
  4. umount /data
  5. Detach "/data" volume
  6. Attach new "/data" volume
  7. mount /data
  8. lsblk
  9. sudo dd if=/dev/xvdX of=/dev/null bs=1M
  10. syncing to the master

$ /etc/init.d/mysql start

$ mysql -uroot -p

mysql> CHANGE MASTER TO

 MASTER_HOST='172.x.x.x',

 MASTER_USER='repl',

 MASTER_PASSWORD='repl-password-here',

 MASTER_LOG_FILE = 'mysql-bin.000001',

 MASTER_LOG_POS = 107;

mysql> start slave;

mysql> show slave status \G


Reference

  • https://jrklein.com/2017/03/22/mysql-master-slave-replication-on-aws-ec2-ebs/
  • https://www.tecmint.com/mariadb-master-slave-replication-on-centos-rhel-debian/


댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함