How to Install RethinkDB on CentOS 8

The RethinkDB is a free and open-source database for building realtime web applications. It's a distributed document-oriented database, easy to scale, high availability database with automatic failover and robust fault-tolerance.

In this tutorial, we will show you how to install and configure RethinkDB on CentOS 8 server.

Prerequisites

For this guide, we will install the RethinkDB with the latest CentOS 8 server with 2GB of RAM and 2CPUs.

What we will do:

  • Add RethinkDB Repository for CentOS 8
  • Install and Configure RethinkDB
  • Install RethinkDB Client Driver for Python
  • Access the RethinkDB Dashboard

Step 1 - Add RethinkDB Repository for CentOS 8

First, we will add the RethinkDB repository to the CentOS 8 server.

Download the RethinkDB repository to the '/etc/yum.repos.d' directory using the command below.

sudo wget https://download.rethinkdb.com/centos/8/`uname -m`/rethinkdb.repo \
-O /etc/yum.repos.d/rethinkdb.repo

Now check all available CentOS repository on the system.

dnf reposlist

And you will get the result as below.

As a result, you've added the RethinkDB repository for CentOS 8 system.

Step 2 - Install and Configure RethinkDB

In this step, we will install the RethinkDB package and configure its bind-address and server-name.

Install the rethinkDB package using the dnf command below.

sudo dnf install rethinkdb

Once the installation is complete, go to the '/etc/rethinkdb' directory and copy the sample configuration 'default.conf.sample' to the 'instances.d/instance1.conf'.

cd /etc/rethinkdb/
cp default.conf.sample instances.d/instance1.conf

Now edit the configuration 'instances.d/instance1.conf' using the vim editor.

vim instances.d/instance1.conf

Uncomment the 'bind' configuration and change the value with your local IP address.

bind = 10.5.5.45

On the bottom of the line, uncomment the 'server-name' and change the value with your server hostname.

Gambarserver-name = instance1

Save and close.

Next, reload the systemd manager.

systemctl daemon-reload

Then start the RethinkDB service and add it to the system boot.

systemctl start rethinkdb
systemctl enable rethinkdb

The RethinkDB service is up and running on the CentOS 8 server. Check it using the command below.

systemctl status rethinkdb
netstat -plntu

And you will get the result as below.

As a result, the Rethink DB is running on the CentOS 8 server.

It's running three different ports, the port '28015' is used for client driver, port '8080' for the HTTP admin dashboard, and port '29015' for the cluster port.

Step 3 - Install RethinkDB Client Driver

The RethinkDB provides multiple client drivers for different programming languages such as Python, JavaScript, Ruby, etc.

In this step, we will install the RethinkDB client driver for Python3 and show you the basic usages of it.

First, install the python3 and python3-pip packages to the system.

sudo dnf install python3 python3-pip

After that, install the RethinkDb client driver for Python 3 using the pip3 command below.

pip3 install rethinkdb

As a result, you've installed the RethinkDB client driver for Python3.

Next, run the python3 shell.

python3

Import the RethinkDB module.

from rethinkdb import r

- Connect to RethinkDB

Connect to the RethinkDB system on port '28015'.

conn = r.connect(host='localhost', port=28015)

- Create Database

Now create a new database 'dbtest'.

r.db_create('dbtest').run(conn)

- Check List Databases

After that, check the list of databases.

r.db_list().run(conn)

And you will get the result as below.

As a result, you've created a new database 'dbtest'.

- Create Table

Next, we will create a new table and insert the sample data to the 'users' database.

Create a new table 'users' on the database 'dbtest'.

r.db('dbtest').table_create('users').run(conn)

- Insert Data to RethinkDB

Insert new data to the table 'users'.

r.db('dbtest').table("users").insert({
"id": 1,
"name": "Hakase-Labs",
"site": "hakase-labs.local"
}).run(conn)

- Extract Data

Now show all data on the 'users' table.

r.db('dbtest').table('users').run(conn)

And you will get the data that you just inserted on top.

As a result, you've successfully connected to the RethinkDB server, created a new database and insert data into it using the Python client driver.

Step 4 - Access the RethinkDB Dashboard

By default, the RethinkDB provides a dashboard for managing its installation and configuration. The dashboard is running on default port '8080'.

First, we will open the port '8080' (used by the RethinkDB dashboard) on the firewalld.

Add the port '8080' to firewalld using the 'firewall-cmd' command below.

firewall-cmd --add-port=8080/tcp --permanent

Now reload the firewalld configuration service.

firewall-cmd --reload

And you've added the port '8080' to the firewalld.

Next, open your web browser and type the RethinkDB server IP address with port '8080'.

http://10.5.5.45:8080/

Now you will get the RethinkDB dashboard as below.

Click the 'Tables' menu on top to get a list of databases and tables.

Now click on the table name to get data on it.

As a result, you get the data that just inserted on top.

Finally, the installation of RethinkDB on CentOS 8 Server has been completed successfully.

Share this page:

0 Comment(s)