DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • The Evolution of Scalable and Resilient Container Infrastructure
  • Scaling Microservices With Docker and Kubernetes on Production
  • Docker Model Runner: Streamlining AI Deployment for Developers
  • A Guide to Container Runtimes

Trending

  • Prioritizing Cloud Security Risks: A Developer's Guide to Tackling Security Debt
  • How Kubernetes Cluster Sizing Affects Performance and Cost Efficiency in Cloud Deployments
  • Optimizing Serverless Computing with AWS Lambda Layers and CloudFormation
  • Next Evolution in Integration: Architecting With Intent Using Model Context Protocol
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Couchbase Cluster Using Docker Compose

Couchbase Cluster Using Docker Compose

How to easily set up a 3-node Couchbase cluster using Docker Compose that will let you scale Couchbase with solid performance.

By 
Arun Gupta user avatar
Arun Gupta
·
Oct. 26, 15 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
9.5K Views

Join the DZone community and get the full member experience.

Join For Free

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.

Docker Couchbase Cluster

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:

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.

  1. Create three directories ~couchbase/node1, ~couchbase/node2, ~couchbase/node3 – one for each node.
  2. Start three Couchbase nodes as using the docker-compose.yml shown earlier:
    > docker-compose up -d
    Pulling couchbase1 (couchbase/server:latest)...
    latest: Pulling from couchbase/server
    70618b6e8070: Pull complete
    05820377a11a: Pull complete
    8de88a91bde5: Pull complete
    61994089e28e: Pull complete
    bc191c81777b: Pull complete
    939d0c2514c9: Pull complete
    fa75256f7885: Pull complete
    7bc9fb79dd30: Pull complete
    e4c99c5f6106: Pull complete
    307ac999aa30: Pull complete
    24eeb78ce9ab: Pull complete
    c4180973b487: Pull complete
    6e0c54ca80e7: Pull complete
    c6d69cc874d9: Pull complete
    31485a5bae7a: Pull complete
    31c8df734d6b: Pull complete
    Digest: sha256:0e983929897ae9bd396533ff7875f30027290c6acf164a66c967ca8884507381
    Status: Downloaded newer image for couchbase/server:latest
    Creating couchbasecluster_couchbase1_1
    Creating couchbasecluster_couchbase3_1
    Creating couchbasecluster_couchbase2_1

    This command is given on a Docker Machine.
  3. Check status of the nodes:
    > docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                               NAMES
    07ff4f1823a4        couchbase/server    "/entrypoint.sh couch"   5 minutes ago       Up 5 minutes        8091-8093/tcp, 11207/tcp, 11210-11211/tcp, 18091-18092/tcp                                          couchbasecluster_couchbase2_1
    18f7bf07134a        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_1
    4db3e1280776        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

    Docker Compose can also show the status:
    > docker-compose ps
                     Name                                   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/tcp                     
    couchbasecluster_couchbase2_1            /entrypoint.sh couchbase-s ...           Up                                       11207/tcp, 11210/tcp, 11211/tcp,       
                                                                                                                               18091/tcp, 18092/tcp, 8091/tcp,        
                                                                                                                               8092/tcp, 8093/tcp                     
    couchbasecluster_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
  4. Check logs of the nodes:
    > docker-compose logs
    Attaching to couchbasecluster_couchbase2_1, couchbasecluster_couchbase3_1, couchbasecluster_couchbase1_1
    couchbase2_1 | Starting Couchbase Server -- Web UI available at http://<ip>:8091
    couchbase3_1 | Starting Couchbase Server -- Web UI available at http://<ip>:8091
    couchbase1_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.

  1. Find IP address of the Docker Machine:
    > docker-machine ip default
    192.168.99.104
  2. 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: Docker Couchbase Cluster Setup

    Click on “Setup”.
  3. 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:
    > docker inspect --format '{{ .NetworkSettings.IPAddress }}' couchbasecluster_couchbase3_1
    172.17.0.2
    Use this IP address to change the Hostname field:Docker Couchbase Cluster Node 1
  4. Click on “Next”. Adjust the RAM if necessary. Read more about Couchbase Cluster Settings.
  5. Pick a sample bucket that you’d like to get installed, and click on Next.
  6. Change Per Node RAM Quota from 400 to 100. This is required as we’ll add other nodes later.Docker Couchbase Cluster Per Node RAM Quota
  7. Click on Next, accept T&C, and click on Next.
  8. 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:

Docker Couchbase Cluster Default View

Add More Couchbase Nodes

Now, lets add the other two nodes that were created earlier by Docker Compose.

  1. Click on “Server Nodes” to see the default view as: Docker Couchbase Cluster Server Nodes Default View
  2. Find IP address of one of the remaining nodes:
    docker inspect --format '{{ .NetworkSettings.IPAddress }}' couchbasecluster_couchbase1_1
    172.17.0.1
  3. Click on “Add Server”, specify the IP address: Docker Couchbase Cluster Add Server Node1
    and click on “Add Server”.
  4. 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:

Docker Couchbase Cluster Pending Rebalance

Click on “Rebalance” and this will automatically rebalance the cluster:

Docker Couchbase Cluster Rebalanced

You just deployed a Couchbase cluster using Docker Compose, enjoy!

Docker (software)

Published at DZone with permission of Arun Gupta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • The Evolution of Scalable and Resilient Container Infrastructure
  • Scaling Microservices With Docker and Kubernetes on Production
  • Docker Model Runner: Streamlining AI Deployment for Developers
  • A Guide to Container Runtimes

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!