How to Install ArangoDB on Ubuntu 20.04

Updated on November 21, 2023
How to Install ArangoDB on Ubuntu 20.04 header image

ArangoDB is an open-source NoSQL database used in modern web applications, which supports models for document, graph, and key-value data. It's managed through a web or command-line interface and uses a declarative query language called AQL (ArangoDB Query Language).

Prerequisites

Install ArangoDB

  1. Import repository key.

     $ curl -fsSL https://download.arangodb.com/arangodb38/DEBIAN/Release.key | sudo apt-key add -
  2. Update the sources list.

     $ echo 'deb https://download.arangodb.com/arangodb38/DEBIAN/ /' | sudo tee /etc/apt/sources.list.d/arangodb.list
     $ sudo apt-get update
  3. Install ArangoDB.

     $ sudo apt-get install arangodb3
  4. Verify the installation was successful.

     $ arangod --version
     server-version: 3.8.x
  5. Start ArangoDB.

     $ sudo systemctl start arangodb3
  6. Monitor the database with status.

     $ sudo systemctl status arangodb3

Hardening Database

Hardening will make blocking unauthorized use of endpoints more strict.

  1. To edit database server settings, navigate and edit the arangod.conf file.

     $ sudo nano /etc/arangodb3/arangod.conf
  2. Under the [server] section, append the following text if it's not already there.

     harden = true
  3. Under the [javascript] section, append the following text.

     harden = true
  4. Restart the database to take effect.

     $ sudo systemctl restart arangodb3
  5. Verify changes were successful by checking for errors in status.

     $ sudo systemctl status arangodb3

Access CLI

To access ArangoDB through the command line, use the arangosh command.

$ arangosh

Access Web Interface

This is meant for development or internal network purposes only. For production applications, continue down the doc for configuring the server through a reverse proxy.

By default, the ArangoDB web interface is only available locally.

  1. To make the server available on the internet, navigate and edit the arangod.conf file.

     $ sudo nano /etc/arangodb3/arangod.conf
  2. Under the [server] section, replace the endpoint URL with your server's IP. For example:

     endpoint = tcp://192.0.2.123:8529
  3. Restart the server.

     $ sudo systemctl restart arangodb3
  4. Verify changes were successful by checking for errors in status.

     $ sudo systemctl status arangodb3
  5. Navigate to your server's IP address at port 8529 in a web browser.

     http://192.0.2.123:8529/

Access Web Interface through Reverse Proxy

For a production application, it is better to host the database locally and access it through a reverse proxy. This makes it easier to manage multiple services, enforce rate-limiting, SSL, and IP-filtering.

  1. Install Nginx.

     $ sudo apt-get install nginx
  2. Delete default Nginx server block.

     $ sudo rm /etc/nginx/sites-enabled/default 
  3. Create a new Nginx server block.

     $ sudo nano /etc/nginx/sites-enabled/arangodb.conf
  4. Add the following text to the file.

     limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
     server {
             listen 80; # Listen on ArangoDB port.
             listen [::]:80; # ipv6 support.
    
             server_name _;
    
             location / {
                     limit_req zone=mylimit burst=20 nodelay; # Basic Rate limiting at 10 requests/sec.
                     proxy_pass http://127.0.0.1:8529;
             }
     }

    > Adjust the rate-limiting rates and zones according to your application and needs.

  5. Restart Nginx for changes to take effect.

     $ sudo systemctl restart nginx
  6. Navigate to your server's IP address in a web browser.

     http://192.0.2.123/

You should see the ArangoDB web interface login menu. As a test, try refreshing the page in rapid succession. Soon, the webpage should respond with a 503 HTTP error, which would indicate a successful rate-limited request.

Conclusion

For more information, refer to the official ArangoDB documentation.