Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couchbase XDCR in a Docker container

I need to have local Couchbase cluster and replicate data from our prod cluster onto it, can't have it installed directly on OS X (because of vbuckets incompatibility - prod cluster is on linux).

Docker for the rescue. I've managed to create Dockerfile, you can see it here.

Now, the cluster runs, it is reachable within LAN, all necessary ports are forwarding - I used tricks described here

I successfully created cluster reference in XDCR tab, yet whenever I try to replicate bucket's data - it changes my cluster's hostname to some non-sensical ip address and creates a log entry:

Updated remote cluster `mycluster` hostname to "172.17.0.5:8091" 
because old one ("mylaptop.company.com:8091") 
is not part of the cluster anymore

I know Couchbase is very sensitive to ip addresses, as you can see, instead I'm using hostname of my machine (host of the docker container). I tried changing container's host name using docker run -h, that didn't seem to help.

Anyone, have you guys set XDCR with a cluster running in a docker container?

like image 793
iLemming Avatar asked May 15 '15 16:05

iLemming


People also ask

What is XDCR in Couchbase?

XDCR is a highly performant replication technology used to replicate data between two Couchbase clusters. This is complementary to the intra-cluster replication. XDCR provides asynchronous replication and maintains data consistency across sites via eventual consistency.

How does replication work on Couchbase?

Each replication targets a bucket on a different cluster, known as the destination cluster or target cluster, in which the data will be replicated. To create a replication, you must have the Project Owner role for the projects that contain both the source and destination clusters.

How does Couchbase support high availability?

So far, we have learned how Couchbase achieves high availability by leveraging replication and failover mechanisms in its distributed environment. In addition to that, Cross-Data Center Replication (XDCR) replicates data between clusters that protects against data center failure.


2 Answers

The cluster wont accept your node as part of it, so it gets knocked out. Seems like you haven't got your networking set up right.

Could be that you need some more ports opened up: (all node-to-node ports) http://docs.couchbase.com/couchbase-manual-2.5/cb-install/#network-ports

Also, how do you start your container? Putting expose in the dockerfile wont open up the ports, you also need to put -P in your command to really expose the ports

like image 184
RoyB Avatar answered Oct 23 '22 05:10

RoyB


I ended up figuring this out. The first step is to set your couchbase hostname to something accessible from the master cluster. The second thing that you have to do is update the hosts file on the slave cluster, replacing the current 127.0.0.1 definition to where COUCHBASE_HOSTNAME is the hostname used above, I was unable to use public IP addresses, and had to use a domain name with DNS records pointing to the slave:

127.0.0.1 COUCHBASE_HOSTNAME

like image 24
jmiraglia Avatar answered Oct 23 '22 03:10

jmiraglia