ArangoDB is a popular and powerful open-source NoSQL database that supports a wide range of data models, including documents, graphs, and key-value pairs. It is written in C++ and provides high performance, scalability, and reliability.
In this tutorial, we will show you how to install and set up ArangoDB on Debian 11. We will assume that you have already installed Debian 11 on your system.
Prerequisites
Before you begin, you will need the following:
- A system running Debian 11
- A user with administrative privileges on your system
Installing the ArangoDB Package
To install ArangoDB on Debian 11, you need to add the ArangoDB package repository to your system.
First, add the GPG key of the ArangoDB package repository using the following command:
curl <https://download.arangodb.com/arangodb33/DEBIAN/Release.key> | sudo apt-key add -
Then, add the ArangoDB package repository to the apt
sources list using the following command:
echo 'deb <https://download.arangodb.com/arangodb33/DEBIAN/> /' | sudo tee /etc/apt/sources.list.d/arangodb.list
After adding the package repository, update the package index using the following command:
sudo apt update
Finally, install the ArangoDB package using the following command:
sudo apt install arangodb3
This will install the latest version of ArangoDB on your system.
Configuring ArangoDB
After installing ArangoDB, you need to configure the database to allow remote access.
To do this, edit the ArangoDB configuration file using your favorite text editor. For example, to edit the file using nano
, run the following command:
sudo nano /etc/arangodb3/arangod.conf
In the configuration file, find the endpoint
option and change its value to tcp://0.0.0.0:8529
. This will allow ArangoDB to listen on all network interfaces and accept incoming connections on port 8529
.
Then, find the authentication
option and change its value to true
. This will enable authentication for ArangoDB, and require users to enter a username and password when connecting to the database.
After modifying the configuration file, save the changes and exit the text editor.
Starting the ArangoDB Service
After configuring ArangoDB, you need to start the ArangoDB service to apply the changes and make the database available.
To start the ArangoDB service, use the systemctl
command with the start
option and the arangodb3
unit:
sudo systemctl start arangodb3
This will start the ArangoDB service, and the database will be ready to accept connections.
To verify that the ArangoDB service is running, you can use the systemctl
command with the status
option and the arangodb3
unit:
sudo systemctl status arangodb3
Creating an ArangoDB User
After starting the ArangoDB service, you need to create an ArangoDB user to access the database.
To create an ArangoDB user, open a web browser and navigate to the following URL:
http://YOUR_SERVER_IP:8529
Replace YOUR_SERVER_IP
with the IP address of your server.
This will open the ArangoDB web interface. In the web interface, click the Create Database
button.
In the Create Database
dialog, enter a database name and click the Create
button. This will create a new database in ArangoDB.
After creating the database, click the Users
tab and then click the Add User
button.
In the Add User
dialog, enter a username and password for the new user, and select the database that you created earlier. Then, click the Save
button.
This will create a new ArangoDB user with access to the specified database.
Connecting to ArangoDB
After creating an ArangoDB user, you can connect to the database from your applications or from the command line.
To connect to ArangoDB from the command line, you can use the arangosh
command. The arangosh
command is a JavaScript shell for ArangoDB that allows you to interact with the database using JavaScript commands.
To connect to ArangoDB using arangosh
, run the following command:
arangosh --server.username USERNAME --server.password PASSWORD
Replace USERNAME
and PASSWORD
with the username and password of the ArangoDB user that you created earlier.
This will connect to the ArangoDB server and open the arangosh
shell. You can then run JavaScript commands to interact with the database.
For example, to create a new document in the test
collection, you can run the following command in the arangosh
shell:
db._create("test");
db.test.save({ _key: "testdoc", value: "Hello, ArangoDB!" });
This will create a new document in the test
collection with the _key
and value
properties.
To retrieve the document from the test
collection, you can run the following command:
db.test.document("testdoc");
This will return the document that you created earlier.
Conclusion
In this tutorial, you learned how to install and configure ArangoDB on Debian 11. You learned how to start the ArangoDB service, create an ArangoDB user, and connect to the database from the command line.
With ArangoDB, you can store and manage your data using a wide range of data models, and gain high performance, scalability, and reliability.