Friday, November 15, 2024
Google search engine
HomeData Modelling & AIInstall RavenDB NoSQL database on Ubuntu 22.04|20.04

Install RavenDB NoSQL database on Ubuntu 22.04|20.04

NoSQL databases are quite different from the Relational Database Management Systems. NoSQL are non tabular, and store data differently than relational tables. Based on their data model NoSQL databases come in a variety of types. The main ones include document, key-value, wide-column, and graph. One beautiful feature about them is that they provide flexible schemas and scale easily with large amounts of data and high user loads.

World Class RavenDB Document Database is one of these databases that looks for better ways to process information to power a robust 21st century application. Before we embark on getting RavenDB installed, let us have a look at its features in a nutshell:

  • Cluster-wide ACID Transactions
  • Pull Replication: Pull Replication makes it easy to keep even the remotest edge units updated.
  • Graph API: Look into the future and become predictive with your data.
  • Distributed Counters: RavenDB’s distributed counters let multiple servers handle aggregated load.
  • Revert Revisions – The database time machine: Fix a database-scope mistake with ease.
  • Multi-model Architecture
  • Multi-platform
  • High Availability
  • Advanced Query Engine
  • Database Management Studio
  • Integrated with RDBMS
  • Ease of Use

System requirements

RavenDB is written in .NET Core so it requires the same set of prerequisites as .NET Core.
Updated server

It is time now that we start installing RavenDB.

Step 1: Install .NET Core Runtime

We will start the installation of RavenDB by getting all the requirements catered for. Since it requires .NET Core, let us go ahead and install it on our Ubuntu real quick.

Add the Microsoft package signing key to your list of trusted keys and add the package repository. Open a terminal and run the following commands:

sudo apt update && sudo apt upgrade
source /etc/lsb-release
wget https://packages.microsoft.com/config/ubuntu/$DISTRIB_RELEASE/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

Install .NET runtime

The .NET Core Runtime allows you to run apps that were made with .NET Core and didn’t include the runtime. The commands below install the ASP.NET Core Runtime.

sudo apt update
sudo apt install vim bzip2 apt-transport-https aspnetcore-runtime-7.0

Step 2: Download and Install RavenDB

Download RavenDB’s latest stable using wget or the you can head over to RavenDB Download page and grab the Linux version from the list of platforms. We will use wget in this guide as shown below

cd ~
wget -O ravendb.tar.bz2 https://hibernatingrhinos.com/downloads/RavenDB%20for%20Linux%20x64/latest

Extract the Archive

Run the tar command below to extract the compressed file

tar xvjf ravendb.tar.bz2

Extracting the file above creates a folder (RavenDB) that contains the setup files. At this point, you can start the Setup Wizard by running the run.ps1 (or run.sh) script

$ cd ~/RavenDB
$ ./run.sh
Use Ctrl + c to Exit it

Step 3: Configure RavenDB

Let’s edit the settings.json file so that we can perform the setup remotely using the browser. Notice that when we run the server for the first time, settings.json is created from settings.default.json. So if settings.json doesn’t exist, edit settings.default.json instead.
Set ServerUrl including the port you would wich RavenDB to listen from as well as Security.UnsecuredAccessAllowed to either PrivateNetwork, PublicNetwork or LocalNetwork to allow Unsecured Access without SSL.

$ vim ~/RavenDB/Server/settings.json
{
    "ServerUrl": "http://172.21.83.113:8080",
    "Setup.Mode": "Initial",
    "DataDir": "RavenData",
    "Security.UnsecuredAccessAllowed": "PrivateNetwork"
}

Replace 172.21.83.113 with your Server IP address.

All values that can be used for Security.UnsecuredAccessAllowed are:

  • None
  • Local
  • PrivateNetwork
  • PublicNetwork

In case your server is on Public cloud such as AWS,GCP or Azure, add more lines to the configuration so that you can be able to access your RavenDB remotely from a browser. An example is shown below:

{
    "ServerUrl": "http://172.21.83.113:443",
    "Setup.Mode": "Initial",
    "DataDir": "RavenData",
    "PublicServerUrl": "<Enter  Public DNS URL for your cloud>",
    "Security.UnsecuredAccessAllowed": "PublicNetwork"
}

We set the Security.UnsecuredAccessAllowed field to PublicNetwork which will allow you to connect remotely. In order to use RavenDB on port 443, run the command below to allow RavenDB to use port 443 (non-root process):

sudo setcap CAP_NET_BIND_SERVICE=+eip ./Server/Raven.Server

Set directory permissions

RavenDB requires write permissions to the following locations:

  • The folder where RavenDB server is running
  • The data folder
  • The logs folder

Modify firewall to allow the new RavenDB port

If you have a firewall running, consider adding the port that you configred RavenDB to be listening from.

sudo ufw allow 8080

Step 4: Create RavenDB systemd service

Move RavenDB directory to /opt

cd ~/
sudo mv RavenDB /opt

Now we will setup and start the RavenDB service.

Open a terminal and create the file /etc/systemd/system/ravendb.service, using super user permissions with the contents below:

$ sudo vim /etc/systemd/system/ravendb.service
[Unit]
Description=RavenDB
After=network.target

[Service]
LimitCORE=infinity
LimitNOFILE=65536
LimitRSS=infinity
LimitAS=infinity
User=root
Restart=on-failure
Type=simple
ExecStart=/opt/RavenDB/run.sh

[Install]
WantedBy=multi-user.target

Where:

  • root is replaced the user you would wish to run the service
  • /opt/RavenDB/run.sh is the path where your run.sh is found here

After adding the new file, reload the daemon, start and enable ravendb service like so:

sudo systemctl daemon-reload
sudo systemctl enable ravendb.service
sudo systemctl restart ravendb.service

Check its status:

$ systemctl status ravendb.service
● ravendb.service - RavenDB v4.0
     Loaded: loaded (/etc/systemd/system/ravendb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-07-19 20:31:36 EAT; 5min ago
   Main PID: 43408 (run.sh)
      Tasks: 23 (limit: 1035)
     Memory: 39.7M
     CGroup: /system.slice/ravendb.service
             ├─43408 /bin/bash /opt/RavenDB/run.sh
             └─43435 ./Raven.Server --browser

Step 5: Run the RavenDB Setup Wizard

By now, everything should be working fine and we are ready to run the RavenDB Setup Wizard. Point your browser to the URL you configured in Step 3. In this guide, we shall use http://172.21.83.113:8080. Follow the screenshots that follow to get RavenDB

RavenDB End-User License Agreement

Scroll through the license agreement to the end then click on “Accept

RavenDB 1 End User License Agreement

RavenDB Setup Wizard

Here we have 3 options depending on our desired level of security. The first is setting up using LetsEncrypt certificate, the second is by providing our own certificate and the third is without any certificate. Since I have no certificates at the moment, we shall proceed with the Unsecured option. Note that in case you would wish to add a new node to create a cluster, there is a “Cluster Setup” option as well. Select the security option that best addresses your needs here.

RavenDB 2 RavenD Setup Wizard unsecured

Unsecured mode setup

Enter the ports you would wish to access Studio from as well as the IP address. Accept the risk then click “Next

RavenDB 3 RavenDB Setup Wizard unsecured mode setup

Restart Server

Configuration should be complete by now. Click on “Restart server

RavenDB 4 RavenDB Setup Wizard unsecured mode setup complete

Access the Studio

If everything went well you should be redirected to the studio. If you used your own certificates, your browser will ask you for them for authentication.

RavenDB 5 RavenDB Inside

Step 6: Create a database

Once we are inside RavsnDB, we can easily create a sample database. Click on “Databases

RavenDB 6 RavenDB Inside create database

Then “New Database

RavenDB 8 RavenDB Inside database created

Conclusion

There is so much more that you can do whilst in RavenDB. Talk of creating documents, adding data, encryption, creating a cluster, and hooking it up with your APIs. RavenDBs documentation is a wonderful place to get all the details. They even provide sample data that you can use to test it with your applications. It is pretty cool and the interface is amazing as well. Food for thought:

“Yesterday is gone. Tomorrow has not yet come. We have only today. Let us begin.”
Mother Theresa

If you are interested with other NoSQL setups, check out below:

How To Install MongoDB 4 on Debian 10 (Buster)

How To Install MongoDB 4 on RHEL 8 / CentOS 8

How to Install MongoDB 4 on CentOS 7

Monitoring MySQL and MongoDB with Prometheus and Grafana – PMM

RELATED ARTICLES

Most Popular

Recent Comments