- This is a tutorial for setting up a master-slave replication of the OpenMRS database.
- This tutorial uses the AMPATH Medical Record System (AMRS) implementation of OpenMRS as an example.
- Change names accordingly to suit your use.
- The host name of our Master Server is called AMRSPROD (as set by an alias in the host file).
- The host name of our Slave Server is called AMRSRESEARCH.
- It is recommended to use the same name for the replicated OpenMRS database on the Master as for the slave.
- Our replicated database is called 'amrs' on both AMRSPROD and AMRSRESEARCH.
- MySQL Reference Manual Chapter on Replication
- (I used this when setting up AMRS replication.)
- Conference 2008 Replication Tutorial
- (I used MySQL Replication Tutorial Presentation (pdf) from here when setting up AMRS replication.)
- MySQL Conference 2009 Replication Tutorial
- Ensure that each mysql have bind the host ip adddress
- Create a replication user on the master database.
- Stop the mysqld on the master server (AMRSPROD).
- Edit my.cnf (or my.ini in Windows) on the master server (AMRSPROD):
- Restart mysqld on master (AMRSPROD).
- Obtain the master replication information (AMRSPROD).
- Lock tables so no one can write to them.
- Then the replication information:
- Create the backup of the master (AMRSPROD).
- *Either stop mysqld on master and manually copy the data files (not covered here) or...
- Create a mysqldump file (takes longer than copying data files):
- Restore the backup onto the slave (AMRSRESEARCH)
- If you chose the mysqldump route, then run this on the slave:
- Depending on the size of the database, it may be a good time for lunch.
- Grant the OpenMRS webapp_user for the slave server (AMRSRESEARCH) read-only access to all database tables except those that will not be replicated.
- Stop the mysqld on the slave server (AMRSRESEARCH)
- Edit my.cnf (or my.ini in Windows) on the slave server (AMRSRESEARCH):
- Restart the mysqld on the slave (AMRSRESEARCH).
- Configure the slave (AMRSRESEARCH):
info| IMPORTANT: Change the master_log_file and master_log_pos to the values copied from the master (AMRSPROD).
- Start the slave process.
- Check the slave status.
- On master (AMRSPROD) unlock tables so they can be written.