(Last Updated On: April 22, 2019)

Hey folks!. Our blog guide for today is on how to Install RethinkDB on Ubuntu 18.04 – Bionic Beaver. RethinkDB is the leading Open-source, scalable database for building realtime web applications. It enables you to build amazing realtime applications with dramatically less engineering effort.

RethinkDB is a NoSQL database that stores schemaless JSON documents. It was designed with automatic failover and robust fault tolerance in mind. It exposes a new database access model instead of polling for changes, the developer can tell the database to continuously push updated query results to applications in realtime.

Let’s now dive to the installation of RethinkDB on Ubuntu 18.04.

Option 1: Using RethinkDB Pre-built packages

There are ready .deb packages built by Sam Hughes. Download the one you need.

wget https://github.com/srh/rethinkdb/releases/download/v2.3.6.srh.1/rethinkdb_2.3.6.srh.1.0bionic_amd64.deb

Then install it with dpkg command

$ sudo dpkg -i rethinkdb_2.3.6.srh.1.0bionic_amd64.deb
Selecting previously unselected package rethinkdb.
(Reading database ... 55796 files and directories currently installed.)
Preparing to unpack rethinkdb_2.3.6.srh.1.0bionic_amd64.deb ...
Unpacking rethinkdb (2.3.6.srh.1~0bionic) ...
Setting up rethinkdb (2.3.6.srh.1~0bionic) ...
The RethinkDB startup service is installed but disabled. To enable it,
follow the instructions in the guide located at http://www.rethinkdb.com/docs/guides/startup/
Processing triggers for systemd (237-3ubuntu10.12) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Copy the sample configuration file and use the configuration file documentation as a guide to customize it. (If you don’t have the sample .conf file, you can download it here.)

sudo cp /etc/rethinkdb/default.conf.sample /etc/rethinkdb/instances.d/instance1.conf
sudo vim /etc/rethinkdb/instances.d/instance1.conf

Examples:

Enable http admin console.

...............
### Web options

## Port for the http admin console
## Default: 8080 + port-offset
http-port=8080

Set the name for the server.

......
### Meta

## The name for this server (as will appear in the metadata).
## If not specified, it will be randomly chosen from a short list of names.
server-name=server1

The default Data directory is /var/lib/rethinkdb/ but you can change it.

.....................
### File path options

## Directory to store data and metadata
## Command line default: ./rethinkdb_data
## Init script default: /var/lib/rethinkdb/<name>/ (where <name> is the name of this file without the extension)
directory=/var/lib/rethinkdb/default

Restart systemd service.

$ sudo systemctl restart rethinkdb.service 
$ systemctl status rethinkdb.service
● rethinkdb.service - LSB: This starts a set of rethinkdb server instances.
Loaded: loaded (/etc/init.d/rethinkdb; generated)
Active: active (running) since Mon 2019-04-22 10:08:23 CEST; 7s ago
Docs: man:systemd-sysv-generator(8)
Process: 23585 ExecStop=/etc/init.d/rethinkdb stop (code=exited, status=0/SUCCESS)
Process: 23713 ExecStart=/etc/init.d/rethinkdb start (code=exited, status=0/SUCCESS)
Tasks: 74 (limit: 4915)
CGroup: /system.slice/rethinkdb.service
├─23840 /usr/bin/rethinkdb --daemon --config-file /etc/rethinkdb/instances.d/instance1.conf --runuser rethinkdb --rungroup rethinkdb --p
├─23842 /usr/bin/rethinkdb --daemon --config-file /etc/rethinkdb/instances.d/instance1.conf --runuser rethinkdb --rungroup rethinkdb --p
└─23919 /usr/bin/rethinkdb --daemon --config-file /etc/rethinkdb/instances.d/instance1.conf --runuser rethinkdb --rungroup rethinkdb --p
Apr 22 10:08:23 ubuntu2 systemd[1]: Starting LSB: This starts a set of rethinkdb server instances….
Apr 22 10:08:23 ubuntu2 rethinkdb[23713]: rethinkdb: instance1: Starting instance. (logging to `/var/lib/rethinkdb/instance1/data/log_file')
Apr 22 10:08:23 ubuntu2 rethinkdb[23713]: Recursively removing directory /var/lib/rethinkdb/instance1/data/tmp
Apr 22 10:08:23 ubuntu2 systemd[1]: Started LSB: This starts a set of rethinkdb server instances..

Access RethinkDB Web console on the Server IP and port 8080.

You’re on your way to database bliss!. Check out the RethinkDB docs and ReQL API. The ten-minute guide will also help you learn how to use the client drivers, get more in-depth information on basic commands, and start writing real applications with RethinkDB.

Here are the quick links to official and third party drivers.

Option 2: Build from source

Let’s start from a freshly installed and upgraded Ubuntu 18.04 system.

sudo apt update
sudo apt -y upgrade

Let’s do a reboot to work on a updated system.

sudo reboot

Install Build Tools

As of this writing, there is no official APT repository for Ubuntu 18.04 RethinkDB packages. We will, however, build it ourselves from source. Install required build dependencies by running commands below on your terminal.

sudo apt -y install git build-essential protobuf-compiler python \
    libprotobuf-dev libcurl4-openssl-dev libboost-all-dev \
    libncurses5-dev libjemalloc-dev wget m4 g++

Generally, you will need

  • GCC or Clang
  • Protocol Buffers
  • jemalloc
  • Ncurses
  • Boost
  • Python 2
  • libcurl
  • libcrypto (OpenSSL)

Build RethinkDB on Ubuntu 18.04

We’re now ready to build RethinkDB on Ubuntu 18.04.

Download and extract the archive:

wget https://download.rethinkdb.com/dist/rethinkdb-latest.tgz
tar xvf rethinkdb-latest.tgz

Change your working directory to RethinkDB source.

cd rethinkdb-*/

Makes sure all of the dependencies for the build and installation are available

$ ./configure --allow-fetch

* Reading arguments from 'configure.default'
* Prepending the following arguments: --fetch re2 --fetch gtest --fetch v8 --fetch jemalloc
* Detecting system configuration
Bash:                           4.4.19(1)-release
Use ccache:                     no
C++ Compiler:                   GCC 7.3.0 (/usr/bin/c++)
Host System:                    x86_64-linux-gnu
Build System:                   Linux 4.15.0-47-generic x86_64
Cross-compiling:                no
Host Operating System:          Linux
Build Architecture:             x86_64
C++11:                          ok
Precompiled web assets:         yes
Protobuf compiler:              /usr/bin/protoc
python:                         python 2.7.15
Node.js package manager:        external/node_0.12.2
coffee:                         external/coffee-script_1.10.0
Browserify:                     external/browserify_13.1.0
bluebird:                       external/bluebird_2.9.32
web UI dependencies:            external/admin-deps_2.0.3
wget:                           /usr/bin/wget
curl:                           /usr/bin/curl
Google Test:                    external/gtest_1.7.0
termcap:                        -ltermcap
boost_system:                   -lboost_system
protobuf:                       -lprotobuf
v8 javascript engine:           external/v8_3.30.33.16-patched2
RE2:                            external/re2_20140111
z:                              -lz
crypto:                         external/openssl_1.0.1t
ssl:                            external/openssl_1.0.1t
curl:                           -lcurl
malloc:                         jemalloc
jemalloc:                       external/jemalloc_4.1.0
Test protobuf:                  ok
Test boost:                     ok
Test OpenSSL:                   external/openssl_1.0.1t
Installation prefix:            /usr/local
Configuration prefix:           /usr/local/etc
Runtime data prefix:            /usr/local/var
* Wrote configuration to config.mk

Once configure has done its job, invoke make command to build RethinkDB.

make

To build a .deb package:

sudo apt -y install debhelper fakeroot libssl-dev
make build-deb UBUNTU_RELEASE=bionic

Wait for the build to finish then install the software.

sudo make install

This will copy RethinkDB binary to a directory on yourPATH, and manual pages to a directory on your MANPATH. The process may take a while depending on the number of CPU cores available in your system.

Configure and Start RethinkDB

Follow RethinkDB configuration and startup guide to finish your installation of RethinkDB from source on Ubuntu 18.04.