Installing Dgraph on Linux as systemctl service

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…

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 /**/dgraph
sudo mkdir -p /**/dgraph/{p,w,zw}
sudo chown -R dgraph:dgraph /**/dgraph

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

For dgraph.service :

sudo nano /**/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=/**/dgraph alpha --lru_mb **** -p /**/dgraph/p -w /**/dgraph/w
StandardOutput=journal
StandardError=journal
User=*****
Group=*****

[Install]
WantedBy=multi-user.target

For dgraph-zero.service :

sudo nano /**/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/**/dgraph zero --wal /**/dgraph/zw
StandardOutput=journal
StandardError=journal
User=*****
Group=*****

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

For graph-ui.service :

sudo nano /****/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=/****/dgraph-ratel
StandardOutput=journal
StandardError=journal
User=****
Group=****

[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!

Monitoring Dgraph on Linux : 

https://unix.stackexchange.com/questions/225401/how-to-see-full-log-from-systemctl-status-service

Leave a comment

Design a site like this with WordPress.com
Get started