Run Couchbase Server on Linode: Part 1

Linode offers cloud hosting for virtual Linux servers in more than a few spots around the world.  I installed the latest Couchbase Server on a single VM, affectionately called a Linode, to get a feel for the install process and try out the new Couchbase Server 5.0 that introduces role-based access control.

This article, in three parts, walks through the steps to install Couchbase Server 5.0 Enterprise Edition on a Linux VM or Linode running Ubuntu 16.04 LTS. Here are the steps:
  1. Create a Linode
  2. Deploy an Image
  3. Boot and Connect to the Linode
  4. Configure the Operating System
  5. Install Couchbase Server
  6. Verify the Installation
This post describes steps 1 through 4, how to prepare a Linode for Couchbase. Part 2 will cover installing the Couchbase Server. Part 3 will show how to verify the installation.

Create a Linode

Linodes come in many sizes.  I picked the smallest multi-CPU option, a two CPU instance with 4 GB of RAM. 

From the Linode Manager, press the Add a Linode link. Locate the instance type you want, select it and press the Add this Linode! button.

Linode 4096 - $20/mo ($.03/hr)

2 CPU Cores
4 GB RAM
48 GB SSD Storage
3 TB Transfer
40 Gbps Network In

1000 Mbps Network Out 



Tip: A more typical Couchbase node would have four to six CPUs and at least 16 GB of RAM.  And a single node does not make a cluster. Add some more Linodes if you're doing more than just experimenting. See the Recommended Specifications

Deploy an Image

A variety of Linux distributions are available for your Linode. I picked Ubuntu 16.04 LTS. For a list of Couchbase supported distributions see Supported Platforms.

From the Linode Manager with its list of nodes, click on the newly created node, e.g., linode4190314. The Server Status will read Brand New.  

Find the Deploy an Image link and click it. Pick the desired image, supply a Root Password.


Press Deploy to create the Linode.

Tip: If you're installing an older Couchbase Server version, check the list of supported distros: 4.6, 4.5, etc....

Boot and Connect to the Linode

Once the Linode is created and the status says Powered Off, press Boot to start the VM. When that completes you'll have a running host that you can SSH into.

Find the new Linode's IP address on Remote Access tab.

Tip: If the Linode is recently rebuilt the remote host keys may have changed. Revoke the key for that IP address: 

ssh-keygen -R 12.34.56.789

Connect using SSH:

> ssh root@12.34.56.789 

Configure the Operating System

Install Updates

First things first.  Install updates to your distribution.

> apt-get update && apt-get upgrade 

Set Hostname
Name the host to help keep track of which host is which, especially if you creating multiple nodes.

echo linode-cb1 > /etc/hostname
> hostname -F /etc/hostname 

Tip: Add host information to /etc/hosts to avoid messages later on when using sudo: "sudo: unable to resolve host linode-cb1".  Add line to /etc/hosts:

127.0.1.1    linode-cb1

Set the Timezone

> dpkg-reconfigure tzdata


Swappiness

Configure Linux kernel swappiness either to 0 or at most 1.

> echo 0 > /proc/sys/vm/swappiness

      or

> sysctl vm.swappiness=0

Make the setting permanent by adding the following snippet to /etc/sysctl.conf

########################
#  Couchbase
########################

vm.swappiness = 0 

 
Tip: For more information on Swappiness form a Couchcbase perspective see Swap Space and Kernel Swappiness

Disable Transparent Huge Pages (THP)

Well, you don't have to do this for Ubuntu 16 LTS.

Tip: For other distributions you will need to disable THP. See Disabling Transparent Huge Pages (THP)

Confirm available RAM

> free -mh



Confirm Disk Space and File System Type

Confirm disk space available is greater than 10 GB

> fdisk -l

Check file system type

> df -Th

Secure the server

Sudo User

Add a user with sudo privileges

> adduser cbadmin
> adduser cbadmin sudo

Now logout and log back in as cbadmin.

> ssh cbadmin@12.34.56.789

Harden SSH Access

Your new Linode is hanging out on the wide open internet, so you want to keep the unwanted riffraff from gaining a foothold there.  Here are some countermeasures to make it more difficult for those folks.

Create an Authentication Key-pair.  

First check to see if a key-pair already exists

> ls ~/.ssh/id_rsa*


If one does not exist, create one. See Create an Authentication Key-pair.



    Now copy the public key to the remote machine:
    • From remote machine

      > mkdir -p ~/.ssh && sudo chmod -R 700 ~/.ssh/
    • From your local computer:

      >  scp ~/.ssh/id_rsa.pub   \
             cbadmin@12.34.56.789:~/.ssh/authorized_keys
    Login to remote machine using key. On MacOs Keychain login popup will appear, maybe only if you have a passphrase.

    Once you're logged in as the new user, disallow root login via SSH.  Edit sshd_config

    > sudo vi /etc/ssh/sshd_config

    Add this line to the Authentication section

    PermitRootLogin no

    Disable unused IP protocol for SSH. Listen on only one internet protocol.
    • AddressFamily inet to listen only on IPv4.
    • AddressFamily inet6 to listen only on IPv6.
    > echo 'AddressFamily inet' | sudo tee -a /etc/ssh/sshd_config

    Restart the SSH service to load the new configuration.

    > sudo systemctl restart sshd

    Tip: For more details on securing your server see the Linode documentation on this topic

    See Part 2 for Couchbase Server installation instructions.

    More Tips

    Here are a few more tips for you before installing Couchbase Server.

    Block Storage

    You may wish to configure multiple volumes on multiple disks. For example, a production setup should configure three separate volumes: 
    • one for the Linux OS
    • one diskgroup per bucket for the data files and
    • one diskgroup per index for the index files.
    Linode offers block storage in some of its data centers: How to Use Block Storage with Your Linode

    The Right Number of Nodes

    Why a one node cluster isn’t recommended: Single Node Deployments

    Comments

    Popular posts from this blog

    Run Couchbase Server on Linode: Part 2

    Run Couchbase Server on Linode: Part 3