MySQL Replication - TSRI/viperdb3 GitHub Wiki
So you want to set up MySQL replication? Let's begin.
Let's start by making sure that the master is ready for replication.
On the master, enter the mysql shell (mysql -u root -p
), and run the following command to enable the "replication" privilege for a given user. THIS SHOULD ONLY BE RUN ON THE MASTER
GRANT REPLICATION SLAVE ON *.* TO ‘<insert_slave_name_here>’@'%’ IDENTIFIED BY ‘<insert_slave_password_here>’;
Now you can exit, and we can start looking at the configuration files.
We want to take a look at the my.cnf
file that is located (usually) at /etc/my.cnf
.
- VIPERdb Location:
/etc/my.cnf
- Adeno Location:
/etc/mysql/my.cnf
For both the master and the slave, we want to establish unique server_ids in this file. You'll find a line somewhere in this my.cnf
file that says server-id=1
. It may or may not be commented out, in this case we want to make sure its not commented out. Specify a unique server-id for master, and also make sure to make one (different from master) on the slave machine.
On the master machine only, add or the change the following line: log_bin = /var/log/mysql/mysql-bin.log
Still on the master machine, we want to make sure the slaves start at the correct data point, so we need to make sure that we load up all the master data onto the slave machine. We can dump