Introduction
OrientDB is a multi-model NoSQL database that supports graph and document databases. It is a Java application that can run on any operating system. It also fully supports ACID and supports multi-master replication.
In this article, you will learn how to install and configure the latest community edition of OrientDB on an Ubuntu 14.04 server.
To follow this tutorial, you need to have the following conditions:
sudo
command and the firewall is turned on. Students who don’t have a server can buy it from here, but I personally recommend you to use the free Tencent Cloud Developer Lab for experimentation, and then buy server after learning to install.)OrientDB is a Java application and requires Java 1.6 or higher. Because it is much faster than Java 6 and 7, Java 8 is strongly recommended. This is the Java version we will install in this step.
To install the Java JRE, add the following personal package archive (PPA):
sudo add-apt-repository ppa:webupd8team/java
Update the package database:
sudo apt-get update
Then install Oracle Java. Installing it with this particular package will not only install it, it will also make it the default Java JRE. When prompted, accept the license agreement:
sudo apt-get install oracle-java8-set-default
After installation, verify that it is now the default Java JRE:
java -version
The expected output is as follows (the exact version may vary):
java version "1.8.0_60"Java(TM) SE Runtime Environment(build 1.8.0_60-b27)
Java HotSpot(TM)64-Bit Server VM(build 25.60-b23, mixed mode)
In this step, we will download and install the latest OrientDB Community Edition. At the time of this publication, OrientDB Community 2.1.3 was the latest version. If a newer version has been released, please change the version number to match:
wget https://orientdb.com/download.php?file=orientdb-community-2.1.3.tar.gz
The downloaded tarball contains the pre-compiled binaries you need to run OrientDB on your system, so all you need to do is unzip it to a suitable directory. Since this /opt
is the traditional location of third-party programs on Linux, let us interpret it there:
sudo tar -xf download.php?file=orientdb-community-2.1.3.tar.gz -C /opt
These files are extracted into a directory named orientdb-community-2.1.3
. To make it easier to use, let's rename it:
sudo mv /opt/orientdb-community-2.1.3/opt/orientdb
Now that the binary is in place, you can start the server and connect to the console. Before that, navigate to the installation directory:
cd /opt/orientdb
Then start the server:
sudo bin/server.sh
In addition to generating a bunch of output, when you start the server for the first time, you will be prompted to specify a password for the root user account. This is an internal OrientDB account used to access the server. For example, it is a username and password combination for accessing OrientDB Studio, which is a web-based interface for managing OrientDB. If you do not specify a password, a password will be automatically generated. However, it is best to specify one yourself and do so when prompted.
Part of the output generated by starting the server tells you the port that the server and OrientDB Studio are listening on:
2015- 10- 1211:27:45:095 INFO Databases directory:/opt/orientdb/databases [OServer]2015-10-1211:27:45:263 INFO Listening binary connections on 0.0.0.0:2424(protocol v.32, socket=default)[OServerNetworkListener]2015-10-1211:27:45:285 INFO Listening http connections on 0.0.0.0:2480(protocol v.10, socket=default)[OServerNetworkListener]
...
2015- 10- 1211:27:45:954 INFO OrientDB Server v2.1.3(build UNKNOWN@r;2015-10-0410:56:30+0000) is active.[OServer]
Since OrientDB is now running in a terminal window, in the second terminal window of the same Droplet, confirm that the server is listening on ports 2424 (for binary connections) and 2480 (for HTTP connections). To confirm that it is listening for binary connections, execute:
sudo netstat -plunt | grep 2424
The output should be similar to
tcp6 00:::2424:::* LISTEN 1617/java
To confirm that it is listening for HTTP connections, execute:
sudo netstat -plunt | grep 2480
The expected output is as follows:
tcp6 00:::2480:::* LISTEN 1617/java
Now that the server is running, you can connect to it using the console (i.e. command line interface):
sudo /opt/orientdb/bin/console.sh
You will see the following:
OrientDB console v.2.1.3(build UNKNOWN@r;2015-10-0410:56:30+0000) www.orientdb.com
Type 'help' to display all the supported commands.
Installing extensions for GREMLIN language v.2.6.0
orientdb>
Now, connect to the server instance. The required password is the one you specified when you started the server earlier:
connect remote:127.0.0.1 root root-password
If it is connected, the output should be:
Connecting to remote Server instance [remote:127.0.0.1]with user 'root'...OK
orientdb {server=remote:127.0.0.1/}>
Type exit
to exit:
exit
So you just installed OrientDB, start it manually and connect to it. All this is fine. However, it also means that you can start it manually when you restart the server. This is not good. In the next steps, we will configure and set up OrientDB to run like any other daemon on the server.
Type CTRL-C
in the terminal window and OrientDB is still running to stop it.
OrientDB is installed on your system at this time, but it is just a bunch of scripts on the server. In this step, we will modify the configuration file and configure it to run as a daemon on the system. This involves modifying the /opt/orientdb/bin/orientdb.sh
script and the /opt/orientdb/config/orientdb-server-config.xml
configuration file.
Let's first modify the /opt/orientdb/bin/orientdb.sh
script to tell OrientDB who should run it and point it to the installation directory.
So, first, create the system user you want OrientDB to run. This command will also create the orientdb group:
sudo useradd -r orientdb -s /bin/false
Grant ownership of OrientDB directories and files to the newly created OrientDB users and groups:
sudo chown -R orientdb:orientdb /opt/orientdb
Now let's make some changes to the orientdb.sh
script. We first open it in the following way:
sudo nano /opt/orientdb/bin/orientdb.sh
First, we need to point it to the correct installation directory, and then tell it which user it should run. Therefore, look for the following two lines at the top of the file:
# You have to SET the OrientDB installation directory here
ORIENTDB_DIR="YOUR_ORIENTDB_INSTALLATION_PATH"
ORIENTDB_USER="USER_YOU_WANT_ORIENTDB_RUN_WITH"
And change them to:
# You have to SET the OrientDB installation directory here
ORIENTDB_DIR="/opt/orientdb"
ORIENTDB_USER="orientdb"
Now, let's enable system users to run the script sudo
.
Further down, under the Start function of the script, find the following line and comment it out by adding the characters before #
. It must look like this:
# su -c "cd \"$ORIENTDB_DIR/bin\"; /usr/bin/nohup ./server.sh 1>../log/orientdb.log 2>../log/orientdb.err &"- $ORIENTDB_USER
Copy and paste the following line immediately after the line you just commented out:
sudo -u $ORIENTDB_USER sh -c "cd \"$ORIENTDB_DIR/bin\"; /usr/bin/nohup ./server.sh 1>../log/orientdb.log 2>../log/orientdb.err &"
Under the Stop function, look for the following line and comment it out. It must be as shown in the picture.
# su -c "cd \"$ORIENTDB_DIR/bin\"; /usr/bin/nohup ./shutdown.sh 1>>../log/orientdb.log 2>>../log/orientdb.err &"- $ORIENTDB_USER
Copy and paste the following line immediately after the line you just commented out:
sudo -u $ORIENTDB_USER sh -c "cd \"$ORIENTDB_DIR/bin\"; /usr/bin/nohup ./shutdown.sh 1>>../log/orientdb.log 2>>../log/orientdb.err &"
Save and close the file.
Next, open the configuration file:
sudo nano /opt/orientdb/config/orientdb-server-config.xml
We will modify the storages tag, and optionally add another user to the users tag. Therefore, scroll to the storages element and modify it so that it reads as shown below. The username and password are your login credentials, which are those you use to log in to your server:
/opt/orientdb/config/orientdb-server-config.xml<storages><storage path="memory:temp" name="temp" userName="username" userPassword="password" loaded-at-startup="true"/></storages>
If you scroll to the users tab, you should see the username and password of the root user that you specified when you first started the OrientDB server in step 3. The guest account is also listed. You don't have to add any other users, but you can add the username and password used to log in to the DigitalOcean server if you want. The following is an example of how to add users in the users tag:
/opt/orientdb/config/orientdb-server-config.xml<user name="username" password="password" resources="*"/>
Save and close the file.
Finally, modify the file permissions to prevent unauthorized users from reading it:
sudo chmod 640/opt/orientdb/config/orientdb-server-config.xml
Now that the scripts have been configured, you can now copy them to their respective system directories. For the script responsible for running the console, copy it to the following /usr/bin
directory:
sudo cp /opt/orientdb/bin/console.sh /usr/bin/orientdb
Then copy the script responsible for starting and stopping the service or daemon to the /etc/init.d
directory:
sudo cp /opt/orientdb/bin/orientdb.sh /etc/init.d/orientdb
Switch to the /etc/init.d
directory:
cd /etc/init.d
Then update the rc.d
directory so that the system is aware of the new script and starts it at boot time, just like other system daemons.
sudo update-rc.d orientdb defaults
You should get the following output:
update-rc.d: warning:/etc/init.d/orientdb missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
Adding system startup for/etc/init.d/orientdb .../etc/rc0.d/K20orientdb ->../init.d/orientdb
/etc/rc1.d/K20orientdb ->../init.d/orientdb
/etc/rc6.d/K20orientdb ->../init.d/orientdb
/etc/rc2.d/S20orientdb ->../init.d/orientdb
/etc/rc3.d/S20orientdb ->../init.d/orientdb
/etc/rc4.d/S20orientdb ->../init.d/orientdb
/etc/rc5.d/S20orientdb ->../init.d/orientdb
With everything in place, you can now start the service:
sudo service orientdb start
Confirm that it actually started:
sudo service orientdb status
You can also use the command in step 3 of netstat
to verify that the server is listening on the port. If the server does not start, please check the clues in the error log file in the /opt/orientdb/log
directory.
OrientDB Studio is a web interface for managing OrientDB. By default, it is listening on port 2480. To connect to it, open a browser and type the following in the address bar:
http://server-ip-address:2480
If the page loads, you should see the login screen. You should be able to log in to root
and the password you set earlier.
If the page does not load, it may be blocked by a firewall. Therefore, you must add a rule to the firewall to allow OrientDB traffic on port 2480. To do this, open the IPTables firewall rules file for IPv4 traffic:
sudo /etc/iptables/rules.v4
In the INPUT chain, add the following rules:
- A INPUT -p tcp --dport 2480-j ACCEPT
Restart iptables:
sudo service iptables-persistent reload
This should be used to connect to OrientDB Studio.
Congratulations! You have just installed OrientDB Community Edition on the server.
More information and links to the official OrientDB documentation can be found on orientdb.com.
For more Ubuntu tutorials, please go to [Tencent Cloud + Community] (https://cloud.tencent.com/developer?from=10680) to learn more.
Reference: "How To Install and Configure OrientDB on Ubuntu 14.04"
Recommended Posts