Build a Distributed System with Ubuntu 18.04 and CouchBase

by José Costa (R1CH4RD5) and Dylan Pinto

R1CH4RD5
7 min readJun 1, 2021

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

[ CouchBase ]

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.

[ Update Both Machines ]

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

sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y

[ Install Net-Tools ]

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

sudo apt install net-tools -y

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

ifconfig

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

Now let’s ping both machines to each other.

[ Install SSH ]

sudo apt install ssh -y

Generate a new public/private key:

ssh-keygen -t rsa -P ""

Add the newly created keys to the authorized_key file:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_key

[ Machine 1 ]

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

ssh-copy-id [2n_machine_username]@[2n_machine_ip]

[ CouchBase ]

Before all, let’s update the Machine1 again:

sudo apt update

[ Install Curl ]

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.

sudo apt install curl lsb-release gnupg

Download the meta package:

curl -O https://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-amd64.deb

Install the meta package:

sudo dpkg -i ./couchbase-release-1.0-amd64.deb

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:

sudo apt-get update

Now, install the latest release of couchbase server community:

sudo apt-get install couchbase-server-community

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

sudo apt update -y

[ CouchBase Server Cluster ]

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:

[ Samples ]

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,

José Costa & Dylan Pinto.

--

--