Build a Distributed System with Ubuntu 18.04 and CouchBase

As a Distributed Systems 2020–21 Class project, in this article we will create a distributed system using ORACLE VirtualBox.

Couchbase Server is a distributed system that is built from the ground up for easy scale out and management.

Originally known as Membase, is an open-source, distributed (shared-nothing architecture) multi-model NoSQL document-oriented database software package optimized for interactive applications. These applications may serve many concurrent users by creating, storing, retrieving, aggregating, manipulating and presenting data.

In support of these kinds of application needs, Couchbase Server is designed to provide easy-to-scale key-value or JSON document access with low latency and high sustained throughput. It is designed to be clustered from a single machine to very large-scale deployments spanning many machines.

[ Getting Started ]

In this article we will initially configure both machines at the same time, where then we will work individually in them. Having already created two virtual machines, let’s proceed.

Before hand, let’s update the machines newly created:

To be able to check our network, let’s install net-tools so it can allow us to use the ifconfig command:

By using the ifconfig, check the IP of each machine:

As we have see it on the output above, the Machine1 ’s IP is and the Machine2 ’s IP is

Now let’s ping both machines to each other.

Generate a new public/private key:

Add the newly created keys to the authorized_key file:

[ Machine 1 ]

Now, on the Machine1 let’s copy the Machine2 's key to allow us the access to it:

Before all, let’s update the Machine1 again:

The command curl is a tool to download or transfer files/data from or to a server using FTP, HTTP, HTTPS, SCP, SFTP, SMB and other supported protocols on Linux or Unix-like system.

These tools are used by some of the core Couchbase Server packages.

Download the meta package:

Install the meta package:

The meta package installs the necessary information for apt to be able to retrieve all of the necessary Couchbase Server installation packages and dependencies.

Then, reload the local package database:

Now, install the latest release of couchbase server community:

Reload the local package database only to be sure that we have the 6.6.0 version:

If everything is correctly done until this point, you can go to the localhost address with the port 8091 to the the CouchBase Server page.

Click Setup New Cluster and field the asked fields like the name of the new cluster and the Admin credentials to it:

Accept the Terms and Conditions for the Community Edition:

Configure the server:

Then, you will be redirected to the Dashboard of the server:

Before proceeding to the Machine2, we will add a sample to the server in a to test our newly cluster.

[ Machine 2 ]

For the Machine2, repeat the installation of the CouchBase done in the Machine1.

[ Adding a Node into the Cluster ]

There are two ways to adding a node to a existing cluster. After installing the CouchBase on the node to be added (Machine2), you can open the localhost:8091 on it and click Join Existing Cluster and insert the IP of the existing cluster (Machine1) or you can go to the machine where the Cluster exists (Machine1), go to the Servers’s section of the Cluster page and click Add Server. In this article we will use the 2nd method.

Click Add Server, and insert the IP of the new node (Machine2):

After adding the new node, we will see the all the cluster nodes:

Click Rebalance to re-distributing data and indexes among the available nodes.

After the Rebalance, we can status of each node:

As we added the travel-sample to the cluster, we can check the dashboard to get a overview of the working cluster.

And that’s it.

Extra: [ Using Two Physical Machines With VM’s ]

To use a second physical machine with other virtual machines we can reproduce the steps above but to work properly we need to use a bridge mode adapter on the VirtualBox and set static IP’s on each virtual machine. In this tutorial we did use the VirtualBox network.

We hope that you like this article and comment as you like, best regards,