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.
First, using the command line, run the voter sample once to create the application catalog. Then, using the Enterprise Manager:
Create two new databases, Voter Master and Voter Replica, using the voter application catalog for both of them.
Add ServerA to the Voter Master database.
Add ServerB to the Voter Replica database.
Start both databases, using the
action for Voter Master and and 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.
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:
On both ServerA and ServerB, run the voter sample once to build the application catalog:
$ cd examples/voter $ ./run.sh catalog
On ServerA, use the voltdb command to start the master database:
$ voltdb create voter.jar \ -d deployment.xml -H localhost \ -l ../../voltdb/license.xml
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
On ServerC, use the dragent command to start the DR agent:
$ dragent master serverA replica serverB
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.