Question: How to install Dgraph on CentOS 7?, How to install Dgraph on Ubuntu 18.04. Dgraph is an open source distributed graph database built from ground up for a rich set of queries.

Features of Dgraph

  • DISTRIBUTED: Dgraph shards the data to horizontally scale to hundreds of servers. It is designed to minimize the number of disk seeks and network calls.
  • FAST: Dgraph is built like a search engine. Queries are broken into sub-queries, which run concurrently to achieve low-latency and high throughput.
  • TRANSACTIONAL: With distributed ACID transactions, you can focus on your application logic, instead of worrying about data integrity.
  • HIGHLY AVAILABLE: Dgraph automatically runs synchronous replication, so losing a hard disk or a server doesn’t affect your services.
  • SHARD REBALANCING: Dgraph ensures that data is evenly balanced across servers by automatically moving shards, improving resource utilization for high performance.
  • FLEXIBLE SCHEMA: Quick iteration is important to keep your users happy. An adaptable flexible schema works with you as your application design evolves.
  • USER INTERFACE: Dgraph provides a user interface, so you can browse and manage your data, making it easier to stay on top of things.

Dgraph automatically optimizes query performance and throughput by closely controlling how the data is placed on disk to reduce disk seeks and network calls in a cluster. Dgraph supports GraphQL-like query syntax, and responds in JSON and Protocol Buffers over GRPC and HTTP.

Install Dgraph on CentOS 7 / Ubuntu 18.04

In this section, we will download Dgraph binaries and configure systemd service units. The first step is downloading the binary files.

Step 1: Download Dgraph binaries on CentOS 7 / Ubuntu 18.04

Download the latest binaries of Dgraph to your OS.

curl -sSf | bash

Agree to the terms of the Dgraph Community License when asked.

Do you agree to the terms of the Dgraph Community License? [Y/n] Y
Latest release version is v1.0.11.
Downloading checksum file for v1.0.11 build.
################################################################## 100.0%
Download complete.

A successful installation should give output similar to below.

Download complete.
Inflating binaries (password may be required).
Dgraph binaries v1.0.11 have been installed successfully in /usr/local/bin.
Please visit for further instructions on usage.

Dgraph binaries will be installed in /usr/local/bin. Ensure this directory is in your $PATH.

$ ls /usr/local/bin/dgraph<TAB>
dgraph dgraph-ratel

Step 2: Create systemd service unit files

Since both CentOS 7 and Ubuntu 18.04 uses systemd init system, we will configure Dgraph services to use Systemd for managing its states.

First, create a system account for dgraph service:

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

Create required directories – for 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

Create systemd service files starting with dgraph.service.

cat <<EOF | sudo tee /etc/systemd/system/dgraph.service
[Unit] data server dgraph-zero.service

ExecStart=/usr/local/bin/dgraph alpha --lru_mb 2048 -p /var/run/dgraph/p -w /var/run/dgraph/w


Also add one for dgraph-zero.service.

cat <<EOF | sudo tee /etc/systemd/system/dgraph-zero.service
[Unit] zero server

ExecStart=/usr/local/bin/dgraph zero --wal /var/run/dgraph/zw


Lastly create graph-ui.service.

cat <<EOF | sudo tee /etc/systemd/system/dgraph-ui.service
[Unit] UI server



Next, enable and start the dgraph services.

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

Check the status to confirm all services are running.

$ systemctl status dgraph dgraph-zero dgraph-ui
● dgraph.service - data server
Loaded: loaded (/etc/systemd/system/dgraph.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2019-02-25 05:27:58 UTC; 1min 3s ago
Main PID: 5585 (dgraph)
CGroup: /system.slice/dgraph.service
└─5585 /usr/local/bin/dgraph alpha --lru_mb 2048 -p /var/run/dgraph/p -w /var/run/dgraph/w
● dgraph-zero.service - zero server
Loaded: loaded (/etc/systemd/system/dgraph-zero.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2019-02-25 05:27:58 UTC; 1min 3s ago
Main PID: 5584 (dgraph)
CGroup: /system.slice/dgraph-zero.service
└─5584 /usr/local/bin/dgraph zero --wal /var/run/dgraph/zw
● dgraph-ui.service - UI server
Loaded: loaded (/etc/systemd/system/dgraph-ui.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2019-02-25 05:28:20 UTC; 41s ago
Main PID: 5657 (dgraph-ratel)
CGroup: /system.slice/dgraph-ui.service
└─5657 /usr/local/bin/dgraph-ratel

Allow ports 8000 and 8080 on the firewall.

# CentOS 7
sudo firewall-cmd --add-port={8000,8080}/tcp --permanent

# Ubuntu 18.04
sudo ufw allow proto tcp from any to any port 8000,8080

Accessing Dgraph UI

To access Dgraph UI, open the Server IP or hostname with port 8000. You should see an interface similar to below.

install dgraph ubuntu 18.04 01

Choose the ratel interface to load. On the next page, enter the Dgraph URL, it should be port “8080“.

install dgraph ubuntu 18.04 02

You should then get the Dgraph Dashboard.

install dgraph ubuntu 18.04 03
install dgraph ubuntu 18.04 04

Refer to Dgraph Documentation for more reading. Below are similar articles.

Install and Configure DBeaver on Ubuntu 18.04 / Ubuntu 16.04 / Debian 9

How to Install TimescaleDB on Ubuntu 18.04 LTS

How to install LevelDB on Ubuntu 18.04 / Ubuntu 16.04

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here