6.2.3 Using MySQL Replication in WebNMS



One of the essential factors to determine the quality of a service is its availability. This is crucial in environments with mission critical applications. In WebNMS, the standby or the secondary server is one of the features that make the application scalable. Besides WebNMS  failover, having a database failover ensures  higher availability. With MySQL providing support for replication, the feature can be best used in WebNMS to optimize its availability and reduce the downtime.




Fair knowledge of database concepts.


High-level Workflow



1. Primary back-end server, BE1 is connected to the database DB1

2. Secondary back-end server, BE2 is connected to the database DB2 (replicated database)

3. A front-end server, FE1 is connected to BE1.

Changes Effected in WebNMS


1. The secondary server, BE2 registers itself as standby with the primary server, BE1

2. The hibernate.cfg.xml file of the standby server, located in <secondary_server home>/classes/hbnlib directory, is copied to the primary server under the <primary_server home>/classes/hbnlib/secondary directory.

3. The same file is again transferred to all the FE servers connected to the primary server



Note: If you start a standalone front-end server after the primary and secondary servers are started, the following entry must be provided in the DownloadFiles.xml present in the <FE Home>/conf directory:

<SERVER-FILES downloadEachTime="true"/>







Reconnecting to Replicated Database


Database reconnection is supported in WebNMS. This feature is used in database replication to reconnect to the secondary database when the primary database goes down. For more details, refer to Accessing Connections section of our documentation:


1. The DB1crashes.

2. BE1 connected to DB1 goes down with the message that connection to the database is lost.

3. The FEs connected to BE1 sense that it is down.

4. The hibernate.cfg.xml of BE2 is copied to the <FEs Home>/classes/hbnlib directory.

5. The FEs then re-connect to DB2.


Database Replication



Different Failover Scenarios


The above workflow is a scenario where the front-end servers reconnect to the secondary database. A few more situations are discussed below:

  1. Setup Details


Primary BE Fails


  1. Setup Details

    1. BE2 is acting as primary and connected to DB2

    1. FE1, FE2 connected to BE2

    1. BE1 is up and running (now as a secondary server)

    1. Now, DB2 fails

      : DB2 Fails

      :  BE2 is shut down saying that connection to the database is lost. BE1 takes over again and starts acting as the primary server. FEs connected to BE2 again reconnect to  BE1.


Secondary Database Fails

  1. Setup Details

    1. BE2 is acting as primary and connected to DB2

    1. FE1 and  FE2 connected to BE2

    1. BE1 is up and running (now as a secondary server)

    1. Now, BE2 fails

      :  BE2 Fails

      : BE1 takes over the functions of BE and starts acting again as the primary server. The FEs will reconnect to BE1.

Secondary Fails



Steps to Set up Replication


To use the MySQL database replication feature in WebNMS, you need to first set up replication in MySQL, and then make the corresponding configuration changes in WebNMS. The details are listed below:

  1. Replicating MySQL:

    The replication feature in MySQL enables copying of databases from one MySQL server to another. One database server acts as a Master and the other as a Slave. In Web NMS, two-way database replication is used, where it is like chained replication servers. That is, the Master and the Slave act as each other's Master and Slave.

    To set up two-way replication in MySQL, follow the steps given in the following document:



    Note: It is mandatory that you have to setup two-way replication, to use this feature in WebNMS.

  2. Following are the configuration changes to be made in WebNMS. The changes must be effected both in BE1, and BE2.



After the above setup is ready, start the primary and secondary servers. Before that ensure that both, the Master and Slave databases are running.





From MySQL

From WebNMS Documentation

Accessing Connections



Copyright © 2013, ZOHO Corp. All Rights Reserved.