- Configure the master database server to allow replication by adding the following lines to the MySQL configuration file (my.cnf):
server-id=1
log-bin=mysql-bin
binlog-do-db=database_name
- Restart the MySQL service to apply the changes.
- Create a user account on the master database server with replication privileges:
GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%' IDENTIFIED BY 'password';
- Take a snapshot of the master database and copy it to the slave database server.
- Import the snapshot into the slave database server.
- On the slave database server, add the following lines to the MySQL configuration file (my.cnf):
server-id=2
relay-log=mysql-relay-bin
log-slave-updates
- Restart the MySQL service on the slave database server to apply the changes.
- Connect to the slave database server and set it as a slave of the master database server:
CHANGE MASTER TO MASTER_HOST='master_server_ip', MASTER_USER='replication_user', MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=4;
- Start the slave database server replication process:
- Monitor the replication process using the following command: