Atlantic.Net Blog

How to Install Dgraph on CentOS 8

Hitesh Jethva
by Atlantic.Net (273 posts) under VPS Hosting
0 Comments

Dgraph is a free, open-source, distributed GraphQL database with a graph backend written in Go language. It is one of the most advanced graphing and multi-model NoSQL database systems available to small and large companies that process massive amounts of data. Dgraph aims to provide Google production-level scale and throughput and serve real-time user queries. It is capable of handling terabytes of structured data running on commodity hardware with low latency for real-time user queries. Dgraph is fast and highly available, offers flexible schema, distributed and transactional graphs, and much more.

In this tutorial, we will show you how to install the Dgraph database system on CentOS 8.

Prerequisites

  • A fresh CentOS 8 VPS on the Atlantic.net Cloud Platform
  • A root password configured on your server

Step 1 – Create an Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing CentOS 8 as the operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged into your CentOS 8 server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Dgraph

A simple and easy way to install Dgraph is to run the Dgraph auto-installation script. You can run the Dgraph installation script using the following command:

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

You will need to accept the terms of service to install the Dgraph in your system, as shown below:

By downloading Dgraph you agree to the Dgraph Community License (DCL) terms
shown above. An open-source (Apache 2.0) version of Dgraph without any
DCL-licensed enterprise features is available by building from the Dgraph
source code. See the source installation instructions for more info:

https://github.com/dgraph-io/dgraph#install-from-source

Do you agree to the terms of the Dgraph Community License? [Y/n] Y
Latest release version is v20.07.0.
Downloading checksum file for v20.07.0 build.
######################################################################## 100.0%##O#- # ######################################################################## 100.0%
Download complete.
Comparing checksums for dgraph binaries
Downloading https://github.com/dgraph-io/dgraph/releases/download/v20.07.0/dgraph-linux-amd64.tar.gz
######################################################################## 100.0%#=#=# ######################################################################## 100.0%
Download complete.
Inflating binaries (password may be required).
Dgraph binaries v20.07.0 have been installed successfully in /usr/local/bin.
Please visit https://dgraph.io/docs/get-started for further instructions on usage.

Once Dgraph is installed, you can proceed to the next step.

Step 3 – Create a User for Dgraph

Next, you will need to create a separate user and group to run the Dgraph service. You can create them with the following command:

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

Next, you will need to create directories to store Dgraph log and state files. You can create them with the following command:

mkdir -p /var/log/dgraph
mkdir -p /var/run/dgraph/{p,w,zw}

Next, change the ownership of the directory to dgraph as shown below:

chown -R dgraph:dgraph /var/{run,log}/dgraph

Step 4 – Create a Systemd Service File for Dgraph

Next, you will need to create some systemd service files to manage Dgraph.

First, create a dgraph.service file with the following command:

nano /etc/systemd/system/dgraph.service

Add the following lines:

[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

Save and close the file when you are finished.

Next, create a dgraph-zero.service file with the following command:

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

Add the following lines:

[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

Save and close the file when you are finished.

Next, create a graph-ui.service file with the following command:

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

Add the following lines:

[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

Save and close the file, then reload the systemd daemon with the following command:

systemctl daemon-reload

Next, start and enable all services to start at system reboot with the following command:

systemctl enable --now dgraph
systemctl enable --now dgraph-ui
systemctl enable --now dgraph-zero
systemctl start dgraph
systemctl start dgraph-ui
systemctl start dgraph-zero

At this point, all Dgraph services are running and listening on port 8000 and 8080. You can check them with the following command:

ss -tunelp | grep 8000

You should get the following output:

tcp6 0 0 :::8000 :::* LISTEN 990 24437 1066/dgraph-ratel

ss -tunelp | grep 8080

You should get the following output:

tcp6 0 0 :::8080 :::* LISTEN 990 24979 1083/dgraph

Step 5 – Access Dgraph Web Interface

Now, open your web browser and access the Dgraph web interface using the URL http://your-server-ip:8000. You should see the following page:

Click on the Launch Latest button. You will be redirected to the following page:

Provide your Dgraph server URL and click on the Continue button. You should see the following page:

Click on the Continue button. You will be redirected to the Dgraph dashboard in the following page:

Conclusion

Congratulations! You have successfully installed Dgraph on CentOS 8. You can now start building your application with Dgraph and GraphQL on your Atlantic.Net VPS. For more information, visit the Dgraph official documentation.

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Penalties for Non-Compliance of HIPAA: What Is the Fine? Can You Get Jail Time?
Major SMS Company Hacked
​​Fight the Phish
How to Install WordPress with SlickStack on Ubuntu 20.04
Top 10 Linux Distributions

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources