You could earn up to $300 by adding new articles!

Get Started Now

How to Install and Configure OrientDB Community Edition on CentOS 7

Published on: Tue, Oct 31, 2017 at 6:32 pm EST

OrientDB is a next-gen multi-model open source NoSQL DBMS. With support for multiple data models, OrientDB can provide more functionality and flexibility in a scalable, high-performance operational database.

In this tutorial, I will demonstrate how to install OrientDB Community Edition on a CentOS 7 server instance.

Prerequisites

  • A Vultr CentOS 7 server instance with sufficient memory. 2GB or more of memory recommended. Say its IP address is 203.0.113.1.
  • You have logged into the server instance as a sudo user.
  • The server instance has been updated to the latest stable status.

Step 1: Install OpenJDK 8 packages

OrientDB requires Java 1.7 or greater. In this tutorial, I choose to install OpenJDK 8 packages as follows:

sudo yum install -y java-1.8.0-openjdk-devel

Having OpenJDK 8 installed, use the below command to verify the result:

java -version

If nothing goes wrong, the output should resemble:

openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)

Next, you need to setup the JAVA_HOME environment variable:

echo "JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")" | sudo tee -a /etc/profile
source /etc/profile

Step 2: Install OrientDB

Download OrientDB 2.2.26 GA Community Edition for Linux, the latest stable release of OrientDB Community Edition at the time of this article was written, from the official OrientDB download page:

cd
wget https://bit.ly/orientdb-ce-imps-2-2-26-linux -O orientdb-community-importers-2.2.26.tar.gz

Decompress the downloaded archive to the /opt directory:

sudo tar -zxvf orientdb-community-importers-2.2.26.tar.gz -C /opt

Create a soft link in order to simplify daily use and future updates:

sudo ln -s /opt/orientdb-community-importers-2.2.26/ /opt/orientdb

Step 3 (optional): Configure OrientDB Community Edition to use less memory

Although smoothly running OrientDB Community Edition requires that your machine has 2GB or more of memory, you can still deploy it on a server with less memory to start with.

To do that, use the vi text editor to open the /opt/orientdb/bin/server.sh file:

sudo vi /opt/orientdb/bin/server.sh

Find the line:

ORIENTDB_OPTS_MEMORY="-Xms2G -Xmx2G"

As you see, the Xms and Xmx parameters specify the initial and maximum memory allocation pool for the Java Virtual Machine when running OrientDB. In order to decrease memory usage of OrientDB, you can modify this line as below:

 ORIENTDB_OPTS_MEMORY="-Xms256m -Xmx512m"

Note: The value of Xms should not be less than 128m, or the OrientDB server won't start up.

Save and quit:

:wq!

Step 4: Start the OrientDB server manually

You can manually start the OrientDB server by executing the /opt/orientdb/bin/server.sh script in your SSH terminal window:

sudo /opt/orientdb/bin/server.sh

Since it is the first time you run the OrientDB server, the script will ask you to setup a password for the OrientDB root user, say it is yourpasswordhere. If you leave the password field blank, the script will automatically generate a password for the OrientDB root user. The credentials created here will be used for authentication when you logging in using a binary connection (OrientDB console) or a web connection (OrientDB Studio) later.

If the OrientDB server gets started properly, you will see a message line which assembles:

2017-08-22 04:02:09:065 INFO  OrientDB Server is active v2.2.26 (build ae9fcb9c075e1d74560a336a96b57d3661234c7b). [OServer]

Any time you'd like to quit, Press Ctrl-C to stop the OrientDB server.

Step 5: Connect to the OrientDB server

When the OrientDB server is up and running, it will listen on port 2424 (for binary connections) and port 2480 (for HTTP connections). That means you can connect to a running OrientDB server using not only an OrientDB console but also a web browser.

Option 1: use an OrientDB console

Keep the SSH connection in which the server.sh script is running alive, and then establish a second SSH connection to the same server instance.

In the second SSH console window, use the following command to start the OrientDB console on the server:

sudo /opt/orientdb/bin/console.sh

In the console's shell, connect to the OrientDB server as below:

orientdb> connect remote:127.0.0.1 root yourpasswordhere

If you successfully connect to the OrientDB server, you will see the output below:

Connecting to remote Server instance [remote:127.0.0.1] with user 'root'...OK
orientdb {server=remote:127.0.0.1/}>

After finishing your job, type exit to quit the OrientDB console.

Note: You can also use a local console.sh (on Linux) or console.bat (on Windows) script to connect the OrientDB server. In that case, you need to allow inbound traffic on the server's 2424 port.

sudo firewall-cmd --zone=public --permanent --add-port=2424/tcp
sudo firewall-cmd --reload
Option 2: via a web browser

A more intuitive method to connect the OrientDB server is to use a web browser.

First of all, you need to open the 2480 port of the OrientDB server as below:

sudo firewall-cmd --zone=public --permanent --add-port=2480/tcp
sudo firewall-cmd --reload

Next, point your favorite web browser to http://203.0.113.1:2480, and then you will be redirected into a page which is called OrientDB Studio. On this page, you can use the root user's credentials you setup earlier to log in.

On the OrientDB Studio web interface, you can do almost all the things you can do in the OrientDB console. Feel free to navigate the system and test your queries.

Step 6: Configure OrientDB as service

In step 2, we have installed OrientDB in the /opt/orientdb-community-importers-2.2.26 directory. But up till now, all these files are just a bunch of scripts that can only be executed manually. In order to setup an operational server, it is necessary to configure OrientDB as a system-level daemon which get started on system boot.

1) Press Ctrl-C in the first terminal window to stop the OrientDB server.

2) Create a dedicated user orientdb which belongs to the orientdb group for running the OrientDB server:

sudo useradd -r orientdb -s /sbin/nologin

3) Change the ownership of the OrientDB directory:

sudo chown -R orientdb:orientdb /opt/orientdb-community-importers-2.2.26

4) Use the vi editor to open the /opt/orientdb/bin/orientdb.sh file:

sudo vi /opt/orientdb/bin/orientdb.sh

Find the following lines:

ORIENTDB_DIR="YOUR_ORIENTDB_INSTALLATION_PATH"
ORIENTDB_USER="USER_YOU_WANT_ORIENTDB_RUN_WITH"

Replace them with:

ORIENTDB_DIR="/opt/orientdb"
ORIENTDB_USER="orientdb"

Save and quit:

:wq!

5) In order to prevent unauthorized access to OrientDB's configurations, you need to modify permissions to that config file as follows:

sudo chmod 640 /opt/orientdb/config/orientdb-server-config.xml

6) Create a systemd startup script to manage the OrientDB service:

sudo cp /opt/orientdb/bin/orientdb.service /etc/systemd/system

Use the vi editor to open this file:

sudo vi /etc/systemd/system/orientdb.service

Find the following lines:

User=ORIENTDB_USER
Group=ORIENTDB_GROUP
ExecStart=$ORIENTDB_HOME/bin/server.sh

Replace them with:

User=orientdb
Group=orientdb
ExecStart=/opt/orientdb/bin/server.sh

Save and quit:

:wq!

Start and enable the OrientDB service:

sudo systemctl daemon-reload
sudo systemctl start orientdb.service
sudo systemctl enable orientdb.service

That's it. In this fashion, the OrientDB will automatically start up on system boot. And this concludes the tutorial. Thanks for reading.

Want to contribute ?

You could earn up to $300 by adding new articles!

Get started in the SSD Cloud!