Saturday, March 11, 2017

Create Couchbase Cluster using Docker

This post walks you through steps to setup Couchbase cluster using Docker. Post expects that you already have Docker installed in your machine (Either of Linux, Mac or Windows)

Before starting the real work, make sure that Docker daemon is up and running.
$ sudo docker info
If daemon is NOT up; you will have something like below on your console:
Cannot connect to the Docker daemon. Is the docker daemon running on this host ?

If daemon is up, then you will have the details like Containers, OS, CPU, OS Name, docker root directory etc printed on the console.

To start Docker daemon (ref)
$ sudo service docker start

Run Couchbase as Dockerized Container

$ sudo docker run -d --name cb1 couchbase
On some of the platforms (like Mac) you need to specify the port mapping as well.
$ sudo docker run -d --name cb1 -p 8091-8094:8091-8094 -p 11210:11210 couchbase:enterprise-4.6.3

Above command runs Couchbase in detached mode (-d) and name is cb1.
$ sudo docker inspect cb1
Above command list all metadata of the cluster in JSON format. One of the important details to look for is IP address (with key IPAddress) of the couchbase server.

To launch couchbase in your browser use URL: http://<<ip_address>>:8091

Lanuch URL and then customize/configure couchbase server. To make it usable, you need to provide details like bucket, RAM, services which you want to run (if it supports multi dimensional scaling). Also, check the radio button 'Start a New Cluster' on CONFIGURE SERVER page.
This way, you will be able to successfully configure your first node.

Create Couchbase Cluster

Above step successfully launched one instance of Couchbase. To create a cluster you need to have minimum two instances of couchbase. 

Create another instance with a different name cb2. And then launch url as discussed in above step. But, be careful this time to Join a cluster (instead of start a new cluster). In the table, give your first instance IP address and then username and password.

Once, the new node is joined to the previous node your cluster is created. As, a final step go ahead and Rebalance your Couchbase to distribute data among nodes. 


---
happy learning !


No comments:

Post a Comment