The Riak MDC Quick Start will walk through the process of configuring Riak MDC replication to perform bidirectional replication between two exemplar Riak clusters in separate networks. Bidirectional replication is accomplished by setting up unidirectional replication in both directions between the clusters.
###Scenario Configure Riak MDC to perform bidirectional replication, given the following two (2) three-node Riak EE Clusters:
####Cluster 1
name | ip | nodename |
---|---|---|
node1 | 172.16.1.11 | riak@172.16.1.11 |
node2 | 172.16.1.12 | riak@172.16.1.12 |
node3 | 172.16.1.13 | riak@172.16.1.13 |
####Cluster 2
name | ip | nodename |
---|---|---|
node4 | 192.168.1.21 | riak@192.168.1.21 |
node5 | 192.168.1.22 | riak@192.168.1.22 |
node6 | 192.168.1.23 | riak@192.168.1.23 |
NOTE: The addresses used in the example clusters are contrived, non-routable addresses; however, in real world applications these addresses would need to be routable over the public Internet.
On a node in Cluster1, node1
for example, identify the nodes that will be listening to connections from replication clients with riak-repl add-listener <nodename> <listen_ip> <port>
for each node that will be listening for replication clients.
riak-repl add-listener riak@172.16.1.11 172.16.1.11 9010
riak-repl add-listener riak@172.16.1.12 172.16.1.12 9010
riak-repl add-listener riak@172.16.1.13 172.16.1.13 9010
On a node in Cluster2, node4
for example, inform the clients where the Source Leaders are listening with riak-repl add-site <ipaddr> <portnum> <sitename>
. Use the IP addresses and ports you configured in the earlier step. For sitename
enter Cluster2.
riak-repl add-site 172.16.1.11 9010 Cluster2
riak-repl add-site 172.16.1.12 9010 Cluster2
riak-repl add-site 172.16.1.13 9010 Cluster2
Verify the replication configuration using riak-repl status
on a Cluster1 node and a Cluster2 node. A full description of the riak-repl status
command's output can be found at the riak-repl status output documentation
On the Cluster1 node, verify that there are listener_<nodename>
s for each listening node, and that leader
, and server_stats
are populated. They should look similar to the following:
listener_riak@172.16.1.11: "172.16.1.11:9010"
listener_riak@172.16.1.12: "172.16.1.12:9010"
listener_riak@172.16.1.13: "172.16.1.13:9010"
leader: 'riak@172.16.1.11'
server_stats: [{<8051.3939.0>,
{message_queue_len,0},
{status,[{site,"Cluster2"},
{strategy,riak_repl_keylist_server},
{fullsync_worker,<8051.3940.0>},
{dropped_count,0},
{queue_length,0},
{queue_byte_size,0},
{state,wait_for_partition}]}}]
On the Cluster2 node, verify that Cluster2_ips
. leader
, and client_stats
are populated. They should look similar to the following:
Cluster2_ips: "172.16.1.11:9010, 172.16.1.12:9010, 172.16.1.13:9010"
leader: 'riak@192.168.1.21'
client_stats: [{<8051.3902.0>,
{message_queue_len,0},
{status,[{site,"Cluster2"},
{strategy,riak_repl_keylist_client},
{fullsync_worker,<8051.3909.0>},
{put_pool_size,5},
{connected,"172.16.1.11",9010},
{state,wait_for_fullsync}]}}]
On a node in Cluster2, node1
for example, identify the nodes that will be listening to connections from replication clients with riak-repl add-listener <nodename> <listen_ip> <port>
for each node that will be listening for replication clients.
riak-repl add-listener riak@192.168.1.21 192.168.1.21 9010
riak-repl add-listener riak@192.168.1.22 192.168.1.22 9010
riak-repl add-listener riak@192.168.1.23 192.168.1.23 9010
On a node in Cluster1, node4
for example, inform the clients where the Source Leaders are listening with riak-repl add-site <ipaddr> <portnum> <sitename>
. Use the IP addresses and ports you configured in the earlier step. For sitename
enter Cluster1.
riak-repl add-site 192.168.1.21 9010 Cluster1
riak-repl add-site 192.168.1.22 9010 Cluster1
riak-repl add-site 192.168.1.23 9010 Cluster1
Verify the replication configuration using riak-repl status
on a Cluster1 node and a Cluster2 node. A full description of the riak-repl status
command's output can be found at the riak-repl status output documentation
On the Cluster1 node, verify that Cluster1_ips
. leader
, and client_stats
are populated. They should look similar to the following:
Cluster1_ips: "192.168.1.21:9010, 192.168.1.22:9010, 192.168.1.23:9010"
leader: 'riak@172.16.1.11'
client_stats: [{<8051.3902.0>,
{message_queue_len,0},
{status,[{site,"Cluster1"},
{strategy,riak_repl_keylist_client},
{fullsync_worker,<8051.3909.0>},
{put_pool_size,5},
{connected,"192.168.1.21",9010},
{state,wait_for_fullsync}]}}]
On the Cluster2 node, verify that there are listener_<nodename>
s for each listening node, and that leader
, and server_stats
are populated. They should look similar to the following:
listener_riak@192.168.1.21: "192.168.1.21:9010"
listener_riak@192.168.1.22: "192.168.1.22:9010"
listener_riak@192.168.1.23: "192.168.1.23:9010"
leader: 'riak@192.168.1.21'
server_stats: [{<8051.3939.0>,
{message_queue_len,0},
{status,[{site,"Cluster1"},
{strategy,riak_repl_keylist_server},
{fullsync_worker,<8051.3940.0>},
{dropped_count,0},
{queue_length,0},
{queue_byte_size,0},
{state,wait_for_partition}]}}]
##Testing MDC Realtime Replication You can use the following script to perform PUTs and GETs on both sides of the replication and verify that those changes are replicated to the other side.
#!/bin/bash
VALUE=`date`
CLUSTER_1_IP=172.16.1.11
CLUSTER_2_IP=192.168.1.21
curl -s -X PUT -d "${VALUE}" http://${CLUSTER_1_IP}:8098/riak/replCheck/c1
CHECKPUT_C1=`curl -s http://${CLUSTER_1_IP}:8098/riak/replCheck/c1`
if [ "${VALUE}" = "${CHECKPUT_C1}" ]; then
echo "C1 PUT Successful"
else
echo "C1 PUT Failed"
exit 1
fi
curl -s -X PUT -d "${VALUE}" http://${CLUSTER_2_IP}:8098/riak/replCheck/c2
CHECKPUT_C2=`curl -s http://${CLUSTER_2_IP}:8098/riak/replCheck/c2`
if [ "${VALUE}" = "${CHECKPUT_C2}" ]; then
echo "C2 PUT Successful"
else
echo "C2 PUT Failed"
exit 1
fi
CHECKREPL_C1_TO_C2=`curl -s http://${CLUSTER_2_IP}:8098/riak/replCheck/c1`
CHECKREPL_C2_TO_C1=`curl -s http://${CLUSTER_1_IP}:8098/riak/replCheck/c2`
if [ "${VALUE}" = "${CHECKREPL_C1_TO_C2}" ]; then
echo "C1 to C2 consistent"
else
echo "
C1 to C2 inconsistent
C1:${CHECKPUT_C1}
C2:${CHECKREPL_C1_TO_C2}
"
exit 1
fi
if [ "${VALUE}" = "${CHECKREPL_C2_TO_C1}" ]; then
echo "C2 to C1 consistent"
else
echo "
C2 to C1 inconsistent
C2:${CHECKPUT_C2}
C1:${CHECKREPL_C2_TO_C1}
"
exit 1
fi
exit 0
If you run this script and things are working as expected, you will get the following output:
C1 PUT Successful
C2 PUT Successful
C1 to C2 consistent
C2 to C1 consistent