How to Install ArangoDB NoSQL Database on Debian 11
ArangoDB is a modern multi-model database system developed by ArangoDB GmbH. it's a free and open-source database system that supports three different data models, documents, graphs, and key/values. ArangoDB is a flexible database system that provides high performance and ACID transactions, also its easy to scale vertically and horizontally.
ArangoDB provides a unified query language called AQL, which allows you to store your data in different data modules. The AQL is a declarative query language that allows the combination of different data access patterns in a single query.
In this tutorial, we will show you how to install and configure ArangoDB the multi-model database system on the Debian 11 server.
- A Linux server Debian 11.
- A non-root user with sudo/root privileges.
By default, ArangoDB provides a binary package for the most popular Linux distribution such as Debian, Ubuntu, and CentOS. This allows developers and administrators easier to install the ArangoDB on their machines or servers.
Before installing ArangoDB, run the apt command below to install the gnupg2 package utility and the apt-transport-https for secure installation through HTTPS connections.
sudo apt install -y gnupg2 apt-transport-https
After installation is completed, download the GPG key of ArangoDB and add it to your Debian system.
curl -OL https://download.arangodb.com/arangodb39/DEBIAN/Release.key
sudo apt-key add - < Release.key
Next, add the ArangoDB repository for the Debian system using the below command.
echo 'deb https://download.arangodb.com/arangodb39/DEBIAN/ /' | sudo tee /etc/apt/sources.list.d/arangodb.list
Update and refresh your Debian repository.
sudo apt update
In the below screenshot you will see the ArangoDB repository is added to the Debian system.
Now install the ArangoDB package using the apt command below.
sudo apt install arangodb3 arangodb3-dbg
During the installation, you will be prompted to set up the root password for the ArangoDB. Input your password and select OK.
Repeat your root password and select OK.
To automatically upgrade the database, select Yes to enable it.
Now you will be prompted to backup the old database data of ArangoDB, which will be stored based on the date in the /var/lib directory. Select Yes to backup the database.
The installation of ArangoDB will now be completed.
Next, start and enable the ArangoDB service using the below command.
sudo systemctl start arangodb3
sudo systemctl enable arangodb3
Lastly, verify the ArangoDb service using the command below.
sudo systemctl status arangodb3
As you can see from the below screenshot, the service arangodb3 is running and enabled. The arangodb3 service will automatically be started at system startup.
Setup System Optimization for ArangoDB Deployment
For the ArangoDB deployment, you will need to optimize your system using some specific configuration, especially to get more performance of ArangoDB.
Now you will be creating a bash script that will automatically execute whenever the system is boot. This script will automatically optimize your Debian system for running ArangoDB.
First, install the sysfsutils package using the apt command below.
sudo apt install sysfsutils -y
After installation is completed, create a new bash script /etc/init.d/arangodb-os-optimization using nano editor.
sudo nano /etc/init.d/arangodb-os-optimization
Add the bash script below to the file.
### BEGIN INIT INFO
# Provides: arangodb-memory-configuration
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Set arangodb kernel parameters
# Description: Set arangodb kernel parameters
### END INIT INFO
# 1 - Raise the vm map count value
sudo sysctl -w "vm.max_map_count=2048000"
# 2 - Disable Transparent Huge Pages
sudo bash -c "echo madvise > /sys/kernel/mm/transparent_hugepage/enabled"
sudo bash -c "echo madvise > /sys/kernel/mm/transparent_hugepage/defrag"
# 3 - Set the virtual memory accounting mode
sudo bash -c "echo 0 > /proc/sys/vm/overcommit_memory"
Save and close the file when you are done.
Now make the script executable by changing the permission to 755 or +x using the below command.
sudo chmod +x /etc/init.d/arangodb-os-optimization
Lastly, add the script to run at boot using the below command.
sudo update-rc.d arangodb-os-optimization defaults
Now you have completed the ArangoDB installation and added an auto-optimize script for running ArangoDB.
Connect to ArangoDB and Create a Database and User
After completing the ArangoDB installation, you will now learn how to log in to the arangoDB using the ArangoDB shell named "arangosh" and create a new database and user for ArangoDB. The arangosh command line allows you to establish a connection to the ArangoDB, it is like the mysql command on MySQL, pgsql of PostgreSQL, or mongosh for MongoDB.
Run the below command to log in to the ArangoDB shell. If you did not specify the username, this will automatically connect based on your system. In this case, the user is the root.
Input the root password of ArangoDB. Once you are connected, you will see the following output. You can see on the following screenshot the detailed connection to the ArangoDb, which is connected as the root user to the default database _system and the ArangoDB server tcp://127.0.0.1:8529.
To create a new user, you will need to load the user module. Run the following query to load the users module and create a new user testuser with the password testpassword.
const users = require('@arangodb/users');
Next, run the below queries to create a new database testdb and grant administrative access (rw - read and write) to the user testuser.
users.grantDatabase('testuser', 'testdb', 'rw');
Type exit to log out from the ArangoDB shell or you can just press Ctrl+c.
Lastly, to verify the test user and testdb database, run the following command to connect to the ArangoDB as user testuser to the database testdb.
sudo arangosh --server.endpoint tcp://127.0.0.1:8529 --server.username testuser --server.database testdb
Input the password for the testuser and you will see the following output.
In the below screenshot, you will see the detailed current connections to the ArangoDB, which is connected as the user testuser to the database testdb on the ArangoDB server tcp://127.0.0.1:8529.
Enable ArangoDB Web Administration Console
One of the main advantages of ArangoDB is that it provides a web-based administration console for managing your ArangoDB deployment. The default administration dashboard is running under the same port 8529 on the localhost or 127.0.0.1.
Now, if you are running the ArangoDB on a server, you will need to change the bind address to your server IP address so you can access the ArangoDB web administration console.
Edit the configuration /etc/arangodb3/arangod.conf using nano editor.
sudo nano /etc/arangodb3/arangod.conf
Change the default endpoint address from 127.0.01 to your server IP address. In this example, the server IP address is 192.168.5.20.
endpoint = tcp://192.168.5.20:8529
Save and close the file when you are done.
Now restart the ArangoDB service to apply new changes to your ArangoDB configuration.
sudo systemctl restart arangodb3
Verify the listening port and IP address on your server using the below command.
As you can see on the following screenshot, the ArangoDB is now running on the server IP address 192.168.5.20 with default port 8529.
Next, turn on your web browser and visit the ArangoDB server IP address with port 8529.
You will see the ArangoDB login page below. Input your database user and password and click Login. This example uses the default root user of ArangoDB.
Select the database that you want to connect to and click the button Select DB: dbname.
Below you can see the ArangoDB administration dashboard.
Next, click on the USERS menu on the left side and you will see the user testuser that you just created.
Lastly, click on the DATABASE menu and you will see the testdb available on the ArangoDB.
Congratulations! You have now completed and learned how to install the ArangoDB on the Debian 11 server. You have also learned how to use the ArangoDB shell for creating a database and user. Lastly, you have also learned how to enable the ArangoDB web administration console for your deployment.