How to Install and Configure Dgraph on Ubuntu 16.04 | 18.04

Dgraph is probably the world’s most advanced graph, multi-model NoSQL database system with high availability across multiple systems thus eliminating a single failure point…

If you need a database management system with native multi-model and robust user interface, including high availability, you may want to look at Dgraph…

This database platform is used small and large companies who process massive amount of data… The system provides synchronous replication, automatic failover so losing a hard disk or a server doesn’t affect services….

This brief tutorial shows students and new users how to install Dgraph on Ubuntu 16.04 | 18.04 LTS servers…

For more about Dgraph, please visit its homepage.

If you want to test it in your lab environment before going out and using it in production, the steps below should be a great place to start..Follow the steps below to get Dgraph installed on Ubuntu

Step 1: Install Required Packages

To install Dgraph, you may want to install some required packages and prepare your server…

First, run the commands below to install curl and apt-transport-https

sudo apt update
sudo apt install curl apt-transport-https

After installing the package above, continue below to installing Dgraph.

Step 2: Installing Dgraph

Now that some required packages are installed, follow the steps below to get Dgraph installed and configured… Dgraph has an official script that allows you to easily install and configure the server…

To get the script, run the commands below:

curl https://get.dgraph.io -sSf | bash

When you run the script above, you’re prompted to accept the license agreement and others…

After the steps above, run the commands below to install it.

/usr/local/bin/

you should see similar message as shown below:

Latest release version is v1.0.11.
Downloading checksum file for v1.0.11 build.
######################################################################## 100.0%
Download complete.
Comparing checksums for dgraph binaries
Downloading https://github.com/dgraph-io/dgraph/releases/download/v1.0.11/dgraph-linux-amd64.tar.gz
######################################################################## 100.0%
Download complete.
Inflating binaries (password may be required).
Dgraph binaries v1.0.11 have been installed successfully in /usr/local/bin.
Please visit https://docs.dgraph.io/get-started for further instructions on usage.

Although Dgraph is installed and can function, there’s no way to control its services via Systemd… With that, we’ll want to create these services so managing startups and shutdowns can be easy…

To do that, run the commands below to create a system user called dgraph…

sudo groupadd --system dgraph
sudo useradd --system -d /var/run/dgraph -s /bin/false -g dgraph dgraph

After that, run the commands below to create directories for Dgraph logs and state files..

sudo mkdir -p /var/log/dgraph
sudo mkdir -p /var/run/dgraph/{p,w,zw}
sudo chown -R dgraph:dgraph /var/{run,log}/dgraph

After creating the directories above, you can begin creating each of the systemd service profiles for each of the services…

There are three services we need to create: dgraph-zero.service, graph-ui.service and dgraph.service

For dgraph.service, run the commands below:

sudo nano /etc/systemd/system/dgraph.service

Then copy and paste the lines below into the file and save..

[Unit]
Description=dgraph.io data server
Wants=network.target
After=network.target dgraph-zero.service
Requires=dgraph-zero.service

[Service]
Type=simple
ExecStart=/usr/local/bin/dgraph alpha --lru_mb 2048 -p /var/run/dgraph/p -w /var/run/dgraph/w
StandardOutput=journal
StandardError=journal
User=dgraph
Group=dgraph

[Install]
WantedBy=multi-user.target

For dgraph-zero.service, run the commands below:

sudo nano /etc/systemd/system/dgraph-zero.service

Then copy and paste the lines below into the file and save…

[Unit]
Description=dgraph.io zero server
Wants=network.target
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/dgraph zero --wal /var/run/dgraph/zw
StandardOutput=journal
StandardError=journal
User=dgraph
Group=dgraph

[Install]
WantedBy=multi-user.target
RequiredBy=dgraph.service

For graph-ui.service. run the commands below:

sudo nano /etc/systemd/system/dgraph-ui.service

Then copy and paste the lines below into the file and save.

[Unit]
Description=dgraph.io UI server
Wants=network.target
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/dgraph-ratel
StandardOutput=journal
StandardError=journal
User=dgraph
Group=dgraph

[Install]
WantedBy=multi-user.target

After the above,

sudo systemctl daemon-reload
sudo systemctl enable --now dgraph
sudo systemctl enable --now dgraph-ui

That should do it!

When you check the services status, you should see them all running and active…

systemctl status dgraph dgraph-zero dgraph-ui

See all services below:

● dgraph.service - dgraph.io data server
   Loaded: loaded (/etc/systemd/system/dgraph.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-02-27 11:05:50 CST; 24s ago
 Main PID: 22272 (dgraph)
    Tasks: 58 (limit: 4663)
   CGroup: /system.slice/dgraph.service
           └─22272 /usr/local/bin/dgraph alpha --lru_mb 2048 -p /var/run/dgraph/p -w /var/ru

Feb 27 11:05:54 ubuntu1804 dgraph[22272]: I0227 11:05:54.113076   22272 groups.go:388] Servi
Feb 27 11:05:54 ubuntu1804 dgraph[22272]: I0227 11:05:54.113488   22272 mutation.go:158] Don
Feb 27 11:05:54 ubuntu1804 dgraph[22272]: I0227 11:05:54.114168   22272 groups.go:388] Servi
Feb 27 11:05:54 ubuntu1804 dgraph[22272]: I0227 11:05:54.114531   22272 index.go:48] Deletin
Feb 27 11:05:54 ubuntu1804 dgraph[22272]: I0227 11:05:54.114678   22272 index.go:54] Rebuild
Feb 27 11:05:54 ubuntu1804 dgraph[22272]: I0227 11:05:54.114839   22272 mutation.go:158] Don
Feb 27 11:05:54 ubuntu1804 dgraph[22272]: I0227 11:05:54.115672   22272 groups.go:388] Servi
Feb 27 11:05:54 ubuntu1804 dgraph[22272]: I0227 11:05:54.115967   22272 mutation.go:158] Don
Feb 27 11:05:55 ubuntu1804 dgraph[22272]: I0227 11:05:55.104681   22272 groups.go:850] Leade
Feb 27 11:05:55 ubuntu1804 dgraph[22272]: I0227 11:05:55.105426   22272 groups.go:859] Got Z

● dgraph-zero.service - dgraph.io zero server
   Loaded: loaded (/etc/systemd/system/dgraph-zero.service; disabled; vendor preset: enabled
   Active: active (running) since Wed 2019-02-27 11:05:50 CST; 24s ago
 Main PID: 22271 (dgraph)
    Tasks: 13 (limit: 4663)
   CGroup: /system.slice/dgraph-zero.service
           └─22271 /usr/local/bin/dgraph zero --wal /var/run/dgraph/zw

Feb 27 11:05:53 ubuntu1804 dgraph[22271]: I0227 11:05:53.855906   22271 node.go:83] raft.nod
Feb 27 11:05:53 ubuntu1804 dgraph[22271]: I0227 11:05:53.856089   22271 raft.go:613] I've be
Feb 27 11:05:53 ubuntu1804 dgraph[22271]: I0227 11:05:53.856165   22271 assign.go:44] Update
Feb 27 11:05:53 ubuntu1804 dgraph[22271]: E0227 11:05:53.976168   22271 raft.go:464] While p
Feb 27 11:05:54 ubuntu1804 dgraph[22271]: W0227 11:05:54.091018   22271 node.go:550] [1] Rea
Feb 27 11:05:54 ubuntu1804 dgraph[22271]: I0227 11:05:54.091746   22271 zero.go:386] Connect
Feb 27 11:05:54 ubuntu1804 dgraph[22271]: I0227 11:05:54.093119   22271 zero.go:368] Got con
Feb 27 11:05:54 ubuntu1804 dgraph[22271]: I0227 11:05:54.097819   22271 pool.go:140] CONNECT
Feb 27 11:05:54 ubuntu1804 dgraph[22271]: I0227 11:05:54.098836   22271 zero.go:495] Connect
Feb 27 11:05:56 ubuntu1804 dgraph[22271]: I0227 11:05:56.977013   22271 raft.go:458] CID set

● dgraph-ui.service - dgraph.io UI server
   Loaded: loaded (/etc/systemd/system/dgraph-ui.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-02-27 11:06:00 CST; 14s ago
 Main PID: 22362 (dgraph-ratel)
    Tasks: 4 (limit: 4663)
   CGroup: /system.slice/dgraph-ui.service
           └─22362 /usr/local/bin/dgraph-ratel

Feb 27 11:06:00 ubuntu1804 systemd[1]: Started dgraph.io UI server.

Now you continue below to access its web interface..

Step 3: Accessing Dgraph Web Interface

Dgraph also comes with a web interface for easy management in your web browser… To logon, go the server hostname or IP address followed by port # 8000

http://localhost:8000

Logon with no passwords..

Dgraph Ubuntu Install

Enjoy!

Congratulations! You have successfully installed Dgraph on Ubuntu 16.04 and 18.05

You may also like the post below:

Install Canvas LMS Platform on Ubuntu 16.04 / 18.04

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.