How to Install Riak on Debian 10: A Step-by-Step Tutorial

In this tutorial, we will show you how to install Riak on Debian 10, and how to perform some basic operations with Riak.

Posted on

Riak is a distributed, fault-tolerant, and scalable NoSQL database that can store various types of data, such as key-value pairs, documents, and graphs. Riak is designed to handle high availability, concurrency, and data replication across multiple nodes. In this tutorial, we will show you how to install Riak on Debian 10, and how to perform some basic operations with Riak.

Prerequisites

Before you start, you need to have the following:

  • A Debian 10 server with at least 2 GB of RAM and 4 GB of disk space.
  • A sudo user or root access to the server.
  • A stable internet connection.

Step 1: Update the System

The first step is to update the system and install some necessary packages. To do this, run the following commands:

sudo apt update -y
sudo apt install -y wget curl

Step 2: Download and Install Riak

The next step is to download and install Riak from the official website. To do this, run the following commands:

wget http://s3.amazonaws.com/downloads.basho.com/riak/2.2/2.2.6/debian/10/riak_2.2.6-1_amd64.deb
sudo dpkg -i riak_2.2.6-1_amd64.deb

This will install Riak in the /usr/sbin directory, and create a riak user and group.

Step 3: Configure Riak

The next step is to configure Riak according to your needs. Riak uses a configuration file called riak.conf located in the /etc/riak directory. You can edit this file with your favorite text editor, such as nano or vi.

Some of the important parameters that you can configure are:

  • nodename: The name of the node, which should be unique in the cluster. The default format is riak@<IP address>, but you can also use a hostname or a fully qualified domain name (FQDN).
  • listener.http.internal: The port and IP address that Riak listens on for HTTP requests. The default value is 127.0.0.1:8098, which means that Riak only accepts HTTP requests from the local machine. You can change this to 0.0.0.0:8098 or any other IP address and port that you want Riak to listen on.
  • listener.protobuf.internal: The port and IP address that Riak listens on for Protocol Buffers requests. The default value is 127.0.0.1:8087, which means that Riak only accepts Protocol Buffers requests from the local machine. You can change this to 0.0.0.0:8087 or any other IP address and port that you want Riak to listen on.
  • buckets.default.allow_mult: The flag that determines whether Riak allows multiple values for the same key. The default value is false, which means that Riak only allows one value for each key. You can change this to true if you want Riak to support multiple values for the same key, which can be useful for conflict resolution.

For more details on the configuration options, you can refer to the official documentation.

After you finish editing the configuration file, save and exit the editor.

Step 4: Start Riak

The next step is to start Riak and check its status. To do this, run the following commands:

sudo systemctl start riak
sudo systemctl status riak

You should see something like this:

● riak.service - Riak
   Loaded: loaded (/lib/systemd/system/riak.service; disabled; vendor preset: enabled)
   Active: active (running) since Tue 2023-12-19 10:05:37 CET; 5s ago
  Process: 1234 ExecStart=/usr/sbin/riak start (code=exited, status=0/SUCCESS)
  Process: 1230 ExecStartPre=/usr/lib/riak/riak-cluster.sh (code=exited, status=0/SUCCESS)
 Main PID: 1240 (beam.smp)
    Tasks: 23 (limit: 4915)
   Memory: 80.9M
   CGroup: /system.slice/riak.service
           ├─1240 /usr/lib/riak/erts-8.3.5.3/bin/beam.smp -K true -A 64 -W w -P 13107...
           ├─1264 erl_child_setup 1048576
           ├─1289 sh -s disksup
           ├─1290 /usr/lib/riak/lib/os_mon-2.4.1/priv/bin/memsup
           └─1291 /usr/lib/riak/lib/os_mon-2.4.1/priv/bin/cpu_sup

Dec 19 10:05:37 debian10 systemd[1]: Starting Riak...
Dec 19 10:05:37 debian10 riak[1234]: !! WARNING: ulimit -n is 1024; 65536 is the recommended minimum.
Dec 19 10:05:37 debian10 riak[1234]: Riak started
Dec 19 10:05:37 debian10 systemd[1]: Started Riak.

This means that Riak is running and listening on the ports that you configured.

Step 5: Test Riak

The next step is to test Riak and see if it works as expected. To do this, you can use the curl command to send HTTP requests to Riak.

For example, you can store a key-value pair in Riak by using the PUT method and specifying the bucket name, the key name, and the value. To store the value Hello, world! with the key greeting in the bucket test, run the following command:

curl -XPUT http://localhost:8098/buckets/test/keys/greeting -d 'Hello, world!'

You should see something like this:

{"success":true}

This means that Riak has successfully stored the key-value pair.

You can retrieve the value by using the GET method and specifying the bucket name and the key name. To retrieve the value of the key greeting in the bucket test, run the following command:

curl -XGET http://localhost:8098/buckets/test/keys/greeting

You should see something like this:

Hello, world!

This means that Riak has successfully retrieved the value.

You can delete the key-value pair by using the DELETE method and specifying the bucket name and the key name. To delete the key greeting in the bucket test, run the following command:

curl -XDELETE http://localhost:8098/buckets/test/keys/greeting

You should see something like this:

{"success":true}

This means that Riak has successfully deleted the key-value pair.

You can also use the riak-admin command to perform some administrative tasks, such as joining a cluster, leaving a cluster, checking the status, etc. For more details on the riak-admin command, you can refer to the official documentation.

Conclusion

In this tutorial, we have shown you how to install Riak on Debian 10, and how to perform some basic operations with Riak. Riak is a powerful and flexible NoSQL database that can handle various types of data and scenarios. You can explore more features and functionalities of Riak by visiting the official website and the official documentation.