12.3. Using the Sample Applications to Demonstrate Replication

Documentation

Home » Documentation » Using VoltDB

12.3. Using the Sample Applications to Demonstrate Replication

One way to familiarize yourself with replication is to try it with an existing application. VoltDB comes with several sample applications. You can use any of the samples to test or demonstrate replication.

The following sections show how to create a replicated database, using the voter application as an example. The first section explains how to use the Enterprise Manager for the demonstration and the second uses the VoltDB shell commands. Both examples assume you have three servers:

  • ServerA as the master

  • ServerB as the replica

  • ServerC as the agent

It is also possible to perform this demonstration on two nodes by using ServerB for both the replica and the DR agent.

12.3.1. Replicating the Voter Sample Using the Enterprise Manager

First, using the command line, run the voter sample once to create the application catalog. Then, using the Enterprise Manager:

  1. Create two new databases, Voter Master and Voter Replica, using the voter application catalog for both of them.

  2. Add ServerA to the Voter Master database.

  3. Add ServerB to the Voter Replica database.

  4. Start both databases, using the create action for Voter Master and create and replica for Voter Replica.

From the command line on ServerC, start the DR agent using the following command:

$ dragent master serverA replica serverB

Finally, from the command line on ServerA, run the sample client application:

$ cd examples/voter
$ ./run.sh client

You should see the client inserts on the master database replicated on the replica. Note that you can also start the client application before the DR agent, to show that replication can be started on an existing, active database.

12.3.2. Replicating the Voter Sample Using the Command Line

In the current release, the scripts for running the sample applications do not add the necessary command line arguments for starting a master or replica database by default. However, you can use the voltdb convenience command to solve this problem:

  1. On both ServerA and ServerB, run the voter sample once to build the application catalog:

    $ cd examples/voter
    $ ./run.sh catalog
  2. On ServerA, use the voltdb command to start the master database:

    $ voltdb create voter.jar \
       -d deployment.xml -H localhost \
       -l ../../voltdb/license.xml
  3. On ServerB, use the voltdb command to start the replica database:

    $ voltdb create --replica voter.jar \
       -d deployment.xml -H localhost \
       -l ../../voltdb/license.xml
  4. On ServerC, use the dragent command to start the DR agent:

    $ dragent master serverA replica serverB
  5. On ServerB, start the voter client application:

    $ ./run.sh client

Note that you can also start the client application (step #5) before the DR agent (step #4), to show that replication can be started on an existing, active database.