Sitemap
R1CH4RD5

R1CH4RD5

Build a Distributed System with Ubuntu 18.04 and CouchBase

by José Costa (R1CH4RD5) and Dylan Pinto

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 ]

Press enter or click to view image in full size
Press enter or click to view image in full size

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
Press enter or click to view image in full size
Press enter or click to view image in full size

[ 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
Press enter or click to view image in full size
Press enter or click to view image in full size

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

ifconfig
Press enter or click to view image in full size

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.

Press enter or click to view image in full size

[ Install SSH ]

sudo apt install ssh -y
Press enter or click to view image in full size
Press enter or click to view image in full size

Generate a new public/private key:

ssh-keygen -t rsa -P ""
Press enter or click to view image in full size

Add the newly created keys to the authorized_key file:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_key
Press enter or click to view image in full size

[ 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]
Press enter or click to view image in full size
Press enter or click to view image in full size

[ CouchBase ]

Before all, let’s update the Machine1 again:

sudo apt update
Press enter or click to view image in full size
Press enter or click to view image in full size

[ 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
Press enter or click to view image in full size
Press enter or click to view image in full size

Download the meta package:

curl -O https://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-amd64.deb
Press enter or click to view image in full size

Install the meta package:

sudo dpkg -i ./couchbase-release-1.0-amd64.deb
Press enter or click to view image in full size
Press enter or click to view image in full size

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

Get R1CH4RD5’s stories in your inbox

Join Medium for free to get updates from this writer.

Then, reload the local package database:

sudo apt-get update
Press enter or click to view image in full size
Press enter or click to view image in full size

Now, install the latest release of couchbase server community:

sudo apt-get install couchbase-server-community
Press enter or click to view image in full size
Press enter or click to view image in full size

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

sudo apt update -y
Press enter or click to view image in full size
Press enter or click to view image in full size

[ 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.

Press enter or click to view image in full size

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

Press enter or click to view image in full size

Accept the Terms and Conditions for the Community Edition:

Press enter or click to view image in full size

Configure the server:

Press enter or click to view image in full size

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

Press enter or click to view image in full size

[ Samples ]

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

Press enter or click to view image in full size
Press enter or click to view image in full size

[ 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.

Press enter or click to view image in full size

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

Press enter or click to view image in full size

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

Press enter or click to view image in full size

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

Press enter or click to view image in full size
Press enter or click to view image in full size

After the Rebalance, we can status of each node:

Press enter or click to view image in full size

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

Press enter or click to view image in full size

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.

--

--