I’ve been working on creating a new master-slave setup out of an existing monolithic database server. I’ve been following Digital Ocean’s guide to replicatoin, but have had to figure out some other steps and caveats.
Random notes:
* relay-log needs to be defined
* if the slave gets into a bad state, you can use ‘RESET SLAVE;’ to get it healthy.
Here are those steps:
- create the backup on the original server:
mysqldump --all-databases -u root -p > ./full-backup-2015.02.03-bak
- import it on the new master:
cat full-backup-2015.02.03-bak | mysql -p
- re-export it with the “master data”:
mysqldump --all-databases --master-data -u root -p > full-backup-2015.02.03-bak
- modify the master data in the backup to include the user/password that will be doing the replication
- make sure ansible ACTUALLY adds the replication user with the correct host
- run START SLAVE on the slave
- if ansible user creation makes it so there are slaves users on both servers, do:
stop slave; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; start slave;
to skip it.