Once your Diaspora application is successfully deployed and run, let’s go on to the database replication adjusting. The first thing you’ll need to do is to create a separate environment with a slave database for our DB cluster.
1. Click on the same Create environment button and choose just one MySQL instance in the opened frame. State the resource limits for your slave database, edit the name of a new environment (e.g. type diaspora-slave) and click the Create button.
2. In a few moments your environment will be created.
Now let’s proceed directly to the databases configuration.
1. Let’s start with the master database. Click the Config icon next to your MySQL node in the diaspora-cluster environment.
2. Navigate to the my.cnf file in the etc folder and edit the following properties as it is shown below:server-id = 1
log-bin = mysql-bin
3. Save the changes performed and Restart your MySQL server to apply them.
4. Then click Open in browser for your MySQL node and log in to the opened admin panel (with credentials you’ve received via email earlier).
5. Select Add slave replication user option in the Master replication section of the Replication tab.
6. Specify the desired User name (e.g. slave) and Password for your slave replication user. Click the Go button.
7. After that, grant replication client and replication slave privileges for the newly created user and proceed to the Go button in the bottom right corner.
Let’s configure the slave database now.
1. Select the Config icon next to the MySQL server of diaspora-slave environment.
2. Navigate to the my.cnf file inside the etc folder and edit the following parameters: server-id = 2
slave-skip-errors = all
3. In the same way as for the master database perform the following:
- Save changes to the file;
- Restart your slave MySQL node;
- Open it in browser and log in using the credentials Jelastic has sent you during the slave environment creation.
4. Select configure link in the Slave replication section of the Replication tab.
5. Enter User name and Password of your slave replication user. Then specify Host of your master database (its URL without http:// part) and click Go to continue.
6. Now you need to enable the replication. Click on Control slave > Full start option to do that.
7. Finally, let’s ensure master-slave replication works for our databases. To do this, create a new database at your master DB server: go to the Databases tab, specify a new database name (e.g. Jelastic) and click the Create button.
8. Navigate back to your slave server’s admin panel and ensure the newly created database has appeared.