×
Community Blog ArangoDB on Alibaba Cloud ECS

ArangoDB on Alibaba Cloud ECS

In this article, we'll cover the initial setup of ArangoDB for it to be able to run on an Alibaba Cloud ECS instance.

By Dassi Orleando, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud's incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Overview

ArangoDB is a native multi-model NoSQL database management system with search capabilities and flexible data models for documents, graphs, and key-values. With ArangoDB, you can build high performance applications using a convenient SQL-like query language or JavaScript extensions.

In this article, we'll cover some initial setup of ArangoDB to be able to run it on an Alibaba Cloud Elastic Compute Service (ECS) instance.

Prerequisites

  1. Basic knowledge of Linux command line
  2. Basic understanding of ECS including server installation and configurations

Install ArangoDB on Alibaba Cloud ECS

Firstly, we need to create an ECS. For this article, I'm using a simple ECS Ubuntu instance with 1 Core and 0.5 GB of memory then you log into via ssh/console as described into the guide.

Next, we need to install the ArangoDB package itself using one of the binary provided into the download page where we see two kind of binary one is the enterprise edition and the other the community with less features (services) of course.

Let's choose the community edition then download the exact binary corresponding to our operating system currently in use.

Note: The docker installation is preferred as it's making quicker the whole installation process and easier the configurations later.

We can either use the Ubuntu single package for quick installation via the server tool (containing the client tool), install it via Package Manager after having updated our repository or even follow the manual installation.

The latest version at the time of writing this article is the 3.4.2-1, let's run the following command to have it on our Ubuntu instance (supposed we're still connected via ssh):

curl https://download.arangodb.com/arangodb34/Community/Linux/arangodb3_3.4.2-1_amd64.deb

Once downloaded we run it knowing we're still in the same directory the file is located:

sudo apt install arangodb3_3.4.2-1_amd64.deb

arangosh is the executable to use in order to run it in command line and therefore being able to perform console commands and access the web interface (called Aardvark) at http://our-ip-address:8529/

Once put it on, we'll see a login screen as following:

1

Arangosh command-line tool can be used for administration of ArangoDB and/or performing quick queries; by default, it'll try to connect to a locally running server on localhost on port 8529 with the username root and an empty password while connecting to the default database _system.

It's possible to run this executable with some options addressing a remote server installation:

  • --server.database : name of the database to connect to
  • --server.endpoint : endpoint to connect to
  • --server.username : database username
  • --server.password : password to use when connecting
  • --server.disable-authentication : disable password prompt and authentication

For example,

arangosh --server.endpoint http://192.168.122.103:8529 --server.username root --server.database databasename --server.disable-authentication false

arangosh will then display a password prompt and perform the explicit connection attempt once the password has been provided.

You can have more details about the ArangoDB shell program here here.

Let's specify our credentials at the login screen to access the next step which is selecting the database to connect to:

2

Let's click on the Select DB button once chosen, the dashboard will be then display as follow:

3

arangosh comes with a set of commands we'll see in the following sections; those can be executed straight from the arangosh prompt.

Arangosh Command-Line Options

Arangosh has multiple options we can specify in the prompt when starting our database server, they are separated into 4 groups as follow:

STANDARD Options:

  • --audit-log : audit log file to save commands and results to
  • --configuration : read configuration file
  • --help: help message
  • --max-upload-size : maximum size of import chunks (in bytes) (default: 500000)
  • --no-auto-complete: disable auto completion
  • --no-colors: deactivate color support
  • --pager : output pager (default: "less -X -R -F -L")
  • --pretty-print: pretty print values
  • --quiet: no banner
  • --temp.path : path for temporary files (default: "/tmp/arangodb")
  • --use-pager: use pager

JAVASCRIPT Options:

  • --javascript.check : syntax check code JavaScript code from file
  • --javascript.execute : execute JavaScript code from file
  • --javascript.execute-string : execute JavaScript code from string
  • --javascript.startup-directory : startup paths containing the JavaScript files
  • --javascript.unit-tests : do not start as shell, run unit tests instead
  • --jslint : do not start as shell, run jslint instead

LOGGING options:

  • --log.level : log level (default: "info")

CLIENT options:

  • --server.connect-timeout : connect timeout in seconds (default: 3)
  • --server.authentication : whether or not to use authentication (default: true)
  • --server.endpoint : endpoint to connect to, use 'none' to start without a server (default: "tcp://127.0.0.1:8529")
  • --server.password : password to use when connecting (leave empty for prompt)
  • --server.request-timeout : request timeout in seconds (default: 300)
  • --server.username : username to use when connecting (default: "root")

Securing Installation

One of the most important thing to do immediately once having your ArangoDB fully installed is to make sure you're (or your users) actually the only one (persons) accessing it the way you want.

As noticed up here, we were connected to our server installation with the root account without any password which is very weak for the purpose of saving our data, most of the time database management system are doing this to allow users quickly experiment the features.

In order to have a fully secured instance, let's run the command arango-secure-installation which will prompt us to provide a password for the root user then restart the server again.

User Management

Now, let's manage our user as an administrator. Giving access with some permissions is something we always do when we want to access a database from an application we're building or a third party.

The quicker way to do this is to access the Users management area from the dashboard on the left menu, accessible with a link like: http://our-ip-address:8529/_db/_system/_admin/aardvark/index.html - users:

4

We then have the possibility to define user's details and their permissions within our ArangoDB server installation.

5

From the screenshot above, the root user has the administrator permission on the default _system database.

Other Executables

Arangosh isn't the only executable shipped with the ArangoDB installation, there are also:

  • arangodump: a command-line tool to create backups of the data and structures stored in ArangoDB. Dump are meant to be restored with arangorestore
  • arangorestore: command-line tool to restore backups created by arangodump.
  • arangoexport: export your data for external programs to formats like JSON or CSV.
  • arangoimp: as the opposite of arangoexport, it ingests data from JSON or CSV file to be saved into ArangoDB servers.
  • arangobench: it's the benchmark tool using for performance and functional testing, supporting parallel querying and batch requests.
  • arangoinspect: a command-line tool that collects information of any ArangoDB server setup to facilitate troubleshooting for the ArangoDB support.
  • Arango-dfdb
  • Foxx CLI: Foxx CLI is command line tool for managing and developing ArangoDB Foxx services. It's an optional tool which requires Node.js and can be installed via the package managers NPM and Yarn.

Scalability

ArangoDB is a distributed database supporting multiple data models, and can thus be scaled horizontally as it can be deployed on a cluster (by using many servers). This approach not only provides performance as well as capacity increases, but also achieves resilience by means of replication and automatic fail-over.

Databases, Collections and Documents

NoSQL databases are so common in their way to manage content to be saved, either it's by using Graph or Document but as stated up here ArangoDB is special because it's a Multi-Model NoSQL database meaning it can simultaneously manage time key/values, documents and graphs data.

A Database is a set of collections and Collections stores records (talking about documents), the collections are equivalent to tables in relational database area and documents to rows in table just that attributes (columns) are dynamic in that particular case.

Data Modeling

Data model refers to how the data are being saved into the database. In ArangoDB documents are saved following almost the JSON format with a document containing 0 or many attributes, each of these attributes having a value that can either be an atomic type (number, string, boolean or null) or a compound type (array or embedded document/object).

There are two types of collections that can be used for our database, the document collection (referred as vertex in the context of graphs) as well as edge collections. Edge collections store documents too, but they include two special attributes, _from and _to, which are used to create relations between documents. Usually, two documents (vertices) stored in document collections are linked by a document (edge) stored in an edge collection.

More details will be described here.

Create Database / Collection

The database creation could be simply made either by hitting a command or by using the graphical interface as shown below:

6

Then we click on Add Database button that allows us to fill the database's details like the name and the owner (existing database user):

7

We now have an empty database where we can start adding one or more collections on it, let's go into the Collections menu item:

8

From that area every single collection created will belongs to the current database we're connected to which is the default one called _system, to be able to add collections to the one we've just created up here we'll need to switch as at this level all is contextual.

From the top menu, click on the currently edited database to have the database selection UI again where we can select the desired database as illustrated in the following screen:

9

Data Retrieval

As any other database management system, query is the operations used to filter, count, update, list, delete, create and find our data.

ArangoDB's queries need to be written in a specific format they've built for the purpose called ArangoDB Query Language.

For many data as output could be long, a cursor is always returned allowing to iterate over the results of queries instead of getting one big hunk.

Arangosh Commands

Instead of accessing our database/collections from the cleaner graphical interface, another option to know as database administrator is to use the command line approach which consists of following a specified syntax once running arangosh in your terminal, here we have:

  • The db object: to manipulate database
  • The collection object: addressing and performing collections actions

Here are some commands to use as examples:

  • db._databases(): return the list of all existing databases, _system included.
  • db._useDatabase(name): change the database in use by specifying another by its name.
  • db.createDatabase(name, options, user): to create a new database specifying its name, options and the owner (an existing database user). Read more about on the guide.
  • db._dropDatabase(name): to delete an existing database specified by name, the _system database cannot be dropped. Extended details of this action are here.
  • collection.exists(object): checks whether a document exists, given an object containing the _id or _key attribute.

The following image is illustrating how the command line result looks like:

10

Drivers

It's very essential for a database management system to have many interfaces the programmers can use to access their databases from outside of the server. As for now we've seen how to access and perform some operations in our database from the graphical interface and with some commands.

Driver helps us to do these same operations with a specific programming languages as ArangoDB has a rest interface; currently it does supports plenty of platforms like: NodeJs, PHP, Java, Javascript, .NET, Go, Python, Scala, Ruby, F# and more. The full list is accessible on their website.

Conclusion

In this long article, we've seen how to install ArangoDB (server + client) and performing basics queries and management tasks into an Ubuntu powered by ECS.

0 0 0
Share on

Alibaba Clouder

2,599 posts | 763 followers

You may also like

Comments