Couchbase 4.0 provides lots of features that allows you to develop with agility and operate at any scale. Some of the features that allow you to operate at any scale are:
- Elastic Scalability
- Consistent High Performance
- Always-On Availability
- Multi-Data Center Deployment
- Simple and Powerful Administration
- Enterprise-grade Security
Learn more about these enterprise features at couchbase.com/operate-at-any-scale.
A complete overview is available in Couchbase Server 4.0 datasheet.
This blog will explain how you can easily setup a 3-node Couchbase Cluster using Docker Compose.
The source code and latest instructions are available at github.com/arun-gupta/docker-images/tree/master/couchbase-cluster.
Create Couchbase Nodes
Couchbase cluster can be easily created using the following Docker Compose file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
couchbase1:
image: couchbase/server
volumes:
- ~/couchbase/node1:/opt/couchbase/var
couchbase2:
image: couchbase/server
volumes:
- ~/couchbase/node2:/opt/couchbase/var
couchbase3:
image: couchbase/server
volumes:
- ~/couchbase/node3:/opt/couchbase/var
ports:
- 8091:8091
- 8092:8092
- 8093:8093
- 11210:11210
|
This file has service definition for three Couchbase nodes. Admin ports are exposed for only one node as other nodes will talk to each other use Docker-internally assigned IP addresses.
- Create three directories
~couchbase/node1
,~couchbase/node2
,~couchbase/node3
– one for each node. - Start three Couchbase nodes as using the
docker-compose.yml
shown earlier:
1234567891011121314151617181920212223242526> docker-compose up -dPulling couchbase1 (couchbase/server:latest)...latest: Pulling from couchbase/server70618b6e8070: Pull complete05820377a11a: Pull complete8de88a91bde5: Pull complete61994089e28e: Pull completebc191c81777b: Pull complete939d0c2514c9: Pull completefa75256f7885: Pull complete7bc9fb79dd30: Pull completee4c99c5f6106: Pull complete307ac999aa30: Pull complete24eeb78ce9ab: Pull completec4180973b487: Pull complete6e0c54ca80e7: Pull completec6d69cc874d9: Pull complete31485a5bae7a: Pull complete31c8df734d6b: Pull completeDigest: sha256:0e983929897ae9bd396533ff7875f30027290c6acf164a66c967ca8884507381Status: Downloaded newer image for couchbase/server:latestCreating couchbasecluster_couchbase1_1Creating couchbasecluster_couchbase3_1Creating couchbasecluster_couchbase2_1 - Check status of the nodes:
1234567> docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES07ff4f1823a4 couchbase/server "/entrypoint.sh couch" 5 minutes ago Up 5 minutes 8091-8093/tcp, 11207/tcp, 11210-11211/tcp, 18091-18092/tcp couchbasecluster_couchbase2_118f7bf07134a couchbase/server "/entrypoint.sh couch" 5 minutes ago Up 5 minutes 0.0.0.0:8091-8093->8091-8093/tcp, 11207/tcp, 11211/tcp, 0.0.0.0:11210->11210/tcp, 18091-18092/tcp couchbasecluster_couchbase3_14db3e1280776 couchbase/server "/entrypoint.sh couch" 5 minutes ago Up 5 minutes 8091-8093/tcp, 11207/tcp, 11210-11211/tcp, 18091-18092/tcp couchbasecluster_couchbase1_1
12345678910111213141516> docker-compose psName Command State Ports-----------------------------------------------------------------------------------------------------------------------------------------------------------------couchbasecluster_couchbase1_1 /entrypoint.sh couchbase-s ... Up 11207/tcp, 11210/tcp, 11211/tcp,18091/tcp, 18092/tcp, 8091/tcp,8092/tcp, 8093/tcpcouchbasecluster_couchbase2_1 /entrypoint.sh couchbase-s ... Up 11207/tcp, 11210/tcp, 11211/tcp,18091/tcp, 18092/tcp, 8091/tcp,8092/tcp, 8093/tcpcouchbasecluster_couchbase3_1 /entrypoint.sh couchbase-s ... Up 11207/tcp, 0.0.0.0:11210->11210/tcp,11211/tcp, 18091/tcp, 18092/tcp,0.0.0.0:8091->8091/tcp,0.0.0.0:8092->8092/tcp,0.0.0.0:8093->8093/tcp - Check logs of the nodes:
1234567> docker-compose logsAttaching to couchbasecluster_couchbase2_1, couchbasecluster_couchbase3_1, couchbasecluster_couchbase1_1couchbase2_1 | Starting Couchbase Server -- Web UI available at http://<ip>:8091couchbase3_1 | Starting Couchbase Server -- Web UI available at http://<ip>:8091couchbase1_1 | Starting Couchbase Server -- Web UI available at http://<ip>:8091
Configure Couchbase Cluster
Lets configure these nodes to be part of a cluster now.
- Find IP address of the Docker Machine:
1234> docker-machine ip default192.168.99.104 - Access Couchbase Admin Console at http://<DOCKER_MACHINE_IP:8091. This is http://192.168.99.104:8091 in our case. It will show the output as:
- Each container is given an internal IP address by Docker, and each of these IPs is visible to all other containers running on the same host. We need to use these internal IP address when adding a new node to the cluster.Find IP address of the first container:
1234> docker inspect --format '{{ .NetworkSettings.IPAddress }}' couchbasecluster_couchbase3_1172.17.0.2
Use this IP address to change the Hostname field:
- Click on “Next”. Adjust the RAM if necessary. Read more about Couchbase Cluster Settings.
- Pick a sample bucket that you’d like to get installed, and click on Next.
- Change Per Node RAM Quota from 400 to 100. This is required as we’ll add other nodes later.
- Click on Next, accept T&C, and click on Next.
- Enter a password that you can remember as we’ll need this later to add more nodes.
Default view of the cluster looks like as shown:
Add More Couchbase Nodes
Now, lets add the other two nodes that were created earlier by Docker Compose.
- Click on “Server Nodes” to see the default view as:
- Find IP address of one of the remaining nodes:
1234docker inspect --format '{{ .NetworkSettings.IPAddress }}' couchbasecluster_couchbase1_1172.17.0.1
- Click on “Add Server”, specify the IP address:
- Repeat the previous two steps with the server name
couchbasecluster_couchbase2_1
.
Couchbase Cluster Rebalance
A cluster needs to be rebalanced to ensured that the data is well distributed amongst the newly added or removed nodes. Read more about Couchbase Cluster Rebalance.
Clicking on “Pending Rebalance” tab shows the nodes that have been added to the cluster but are not rebalanced yet:
Click on “Rebalance” and this will automatically rebalance the cluster:
You just deployed a Couchbase cluster using Docker Compose, enjoy!
Some more references:
- Couchbase 4 Administration Guide
- Couchbase 4 Server Architecture
- Couchbase 4 Cluster Setup