Home / How To / How to install RavenDB NoSQL database on Ubuntu 20.04

How to install RavenDB NoSQL database on Ubuntu 20.04



RavenDB is a free and open source document-oriented NoSQL database designed for .NET / Windows platform. RavenDB supports multiple databases, sharing or partitioning of data across multiple servers. It has the ability to manage hundreds or thousands of databases in the same instance. RavenDB uses JSON to store documents and does not require a schedule to be declared, enabling developers to work with data more naturally.

In this tutorial we will learn how to install RavenDB on the Ubuntu 20.04 server.

Conditions

  • A server running Ubuntu 20.04.
  • A root password is configured on the server.

Install necessary dependencies

Before you begin, you need to install the NET Core runtime in your system. Download and first install the package repository with the following command:

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb

You should get the following output:

Selecting previously unselected package packages-microsoft-prod.
(Reading database ... 91134 files and directories currently installed.)
Preparing to unpack packages-microsoft-prod.deb ...
Unpacking packages-microsoft-prod (1.0-ubuntu20.04.1) ...
Setting up packages-microsoft-prod (1.0-ubuntu20.04.1) ...

Then update the repository with the following command:

apt-get install apt-transport-https -y
apt-get update -y

Once the repository has been updated, install the .Net Core runtime using the following command:

apt-get install aspnetcore-runtime-3.1 -y

Once the installation is complete, you can proceed to the next step.

Install RavenDB

First, download the latest version of RavenDB by running the following command:

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

When the download is complete, extract the downloaded file with the following command:

tar xvjf ravendb.tar.bz2

Then the right access to RavenDB with the following command:

chmod -R 755 ~/RavenDB

Then change the directory to RavenDB and run the installation script shown below:

cd ~/RavenDB
./run.sh

You should s-ee the following output:

./run.sh: line 24: xdg-open: command not found
       _____                       _____  ____ 
      |  __                      |  __ |  _  
      | |__) |__ ___   _____ _ __ | |  | | |_) |
      |  _  // _`   / / _  '_ | |  | |  _ < 
      | |   (_| | V /  __/ | | | |__| | |_) |
      |_|  ___,_| _/ ___|_| |_|_____/|____/ 


      Safe by default, optimized for efficiency

 Build 50005, Version 5.0, SemVer 5.0.0, Commit a8d3f94
 PID 23883, 64 bits, 2 Cores, Phys Mem 1.941 GBytes, Arch: X64
 Source Code (git repo): https://github.com/ravendb/ravendb
 Built with love by Hibernating Rhinos and awesome contributors!
+---------------------------------------------------------------+
Using GC in server concurrent mode retaining memory from the OS.
Could not start browser: System.ComponentModel.Win32Exception (2): No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName, String arguments)
   at Raven.Server.Utils.Cli.BrowserHelper.OpenStudioInBrowser(String url, Action`1 onError) in C:BuildsRavenDB-Stable-5.050005srcRaven.ServerUtilsCliBrowserHelper.cs:line 26
Server available on: http://127.0.0.1:43241
Server started, listening to requests...
TIP: type 'help' to list the available commands.
Running non-interactive.

At this time, RavenDB starts and listens to port 43241. Now press CTRL + C To leave.

Configure RavenDB

By default, RavenDB is only available from localhost. So you need to configure it for remote host access.

You can configure it by editing the settings.json file:

nano ~/RavenDB/Server/settings.json

Add / change the following lines:

{
    "ServerUrl": "http://your-server-ip:8080",
    "Setup.Mode": "Initial",
    "DataDir": "RavenData",
    "Security.UnsecuredAccessAllowed": "PrivateNetwork"

}

Save and close the file when you are done.

Create a Systemd service file for RavenDB

Next, you need to create a systemd service file to manage RavenDB. You can create it with the following command:

nano /etc/systemd/system/ravendb.service

Add the following lines:

[Unit]
Description=RavenDB v4.0
After=network.target

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

[Install]
WantedBy=multi-user.target

Save and close the file. Then reload the systemd daemon with the following command:

systemctl daemon-reload

Then start RavenDB and activate it when restarting the system with the following command:

systemctl start ravendb
systemctl enable ravendb

You can now check the status of RavenDB with the following command:

systemctl status ravendb

You should get the following output:

? ravendb.service - RavenDB v4.0
     Loaded: loaded (/etc/systemd/system/ravendb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-08-01 11:25:12 UTC; 7min ago
   Main PID: 30833 (run.sh)
      Tasks: 32 (limit: 2353)
     Memory: 157.0M
     CGroup: /system.slice/ravendb.service
             ??30833 /bin/bash /root/RavenDB/run.sh
             ??30871 ./Raven.Server --browser

Aug 01 11:30:19 ubuntu2004 run.sh[30871]: Starting shut down...
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: Shutdown completed
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: Restarting Server...
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: Using GC in server concurrent mode retaining memory from the OS.
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: Server available on: http://69.87.218.19:8080
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: Tcp listening on 69.87.218.19:38888
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: Server started, listening to requests...
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: TIP: type 'help' to list the available commands.
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: ravendb> End of standard input detected, switching to server mode...
Aug 01 11:30:21 ubuntu2004 run.sh[30871]: Running non-interactive.

At this point, RavenDB starts and listens to port 8080.

Go to the RavenDB web interface

Now open your browser and enter the URL http: // your server-ip: 8080. You should see the following screen:Advertisement

Advertisement

RavenDB License

click Accept to accept the license agreement. You should see the following screen:

Secure the database

Here are three options for setting up RavenDB. Select Unsecured alternative. You should see the following screen:

Configure database ports

Enter the HTTP port, IP address and click Next button. You should see the following screen:

Configuration complete

click Restart server to restart your system. After a successful restart, you will be redirected to the RavenDB Dashboard as follows:

RavenDB dashboard

click CREATE DATABASE button. You should see the following screen:Advertisement

Configure replication in RavenDB

Enter your database name and click Create button. You should see your newly created database on the following screen:

Create a database in RavenDB

Conclusion

Congratulations! you have successfully installed RavenDB on Ubuntu 20.04. You can now start exploring RavenDB to get acquainted with it. Feel free to ask me if you have any questions.


Source link