MYSQL Chaining

This describes setting up a new chain with mysql replication.
This is the basic layout. (M master, S1 slave of master, S2 slave of S1)
M <- S1 <- S2
Creating a chain:
  1. On S1:
stop slave; systemctl disable mysqld; show slave status\G # COPY THIS TO TEXT FILE show mater status\G # COPY THIS TO TEXT FILE
service mysqld stop;
  1. Create an image of S1, this will be S2. In GCP go to the VM instance of S1, click on its disk, click create Image.
========================================
Log into your new image, S2:
  1. edit /etc/my.cnf, add a way to skip the start of a slave.
[mysqld] skip-slave-start
  1. Remove the old UUID, this needs to be unique, so delete it,
rm -f /var/lib/mysql/auto.cnf
  1. change the server-id to anything unique
vi /etc/my.cnf, find "server-id" change it to something unique EG ** server-id=1552009061
  1. systemctl enable mysqld; #ensure mysql will start on boot
  2. service mysqld start;
  3. reset slave;
  4. Set the new master position. These should be the numbers from step 1.
CHANGE MASTER TO MASTER_HOST='10.128.0.120', MASTER_USER='epic', MASTER_PASSWORD='p@p1c', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000031', MASTER_LOG_POS=100096113, MASTER_CONNECT_RETRY=10;
  1. start slave;
  2. remove, from /etc/my.cnf the skipping of a slave
[mysqld] skip-slave-start ← remove
12 from /etc/my.cnf , ensure read-only = true

  1. go to S1; systemctl enable mysqld; service mysqld start;

Comments

Popular posts from this blog

All the pitfalls I met in the first month