We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
You can deploy and manage Dgraph database in a variety of self-managed deployment scenarios, including:
This section focuses exclusively on deployment and management for these self-managed scenarios. To learn about fully managed options that let you focus on building apps and websites, rather than managing infrastructure, or Try Dgraph on Hypermode.
A Dgraph cluster consists of the following:
/admin
HTTP and
gRPC endpoint that can be used for data and node administration tasks such as
backup, export, draining, and shutdown.You need at least one node of each type to run Dgraph. You need three nodes of each type to run Dgraph in a high-availability (HA) cluster configuration. To learn more about 2-node and 6-node deployment options, see the Production Checklist.
Each Dgraph Alpha exposes various administrative (admin) endpoints both over HTTP and GraphQL, for example endpoints to export data and to perform a clean shutdown. All such admin endpoints are protected by three layers of authentication:
--security
superflag’s whitelist
option on
Dgraph Alpha to whitelist IP addresses other than localhost).--security
superflag’s
token
option, then you should pass the token as an X-Dgraph-AuthToken
header while making the HTTP request.X-Dgraph-AccessToken
header while making the HTTP request.An administration endpoint is any HTTP endpoint which provides admin
capabilities. Administration endpoints usually start with the /admin
path. The
current list of admin endpoints includes the following:
/admin
/admin/config/cache_mb
/admin/draining
/admin/shutdown
/admin/schema
/admin/schema/validate
/alter
/login
There are a few exceptions to this general rule:
/login
: This endpoint logs-in an ACL user, and provides them with a JWT.
Only IP Whitelisting and Poor-man’s auth checks are performed for this
endpoint./admin
: This endpoint provides GraphQL queries/mutations corresponding to
the HTTP admin endpoints. All of the queries/mutations on /admin
have all
three layers of authentication, except for login (mutation)
, which has the
same behavior as the HTTP /login
endpoint.By default, admin operations can only be initiated from the machine on which the Dgraph Alpha runs.
You can use the --security
superflag’s whitelist
option to specify a
comma-separated whitelist of IP addresses, IP ranges, CIDR ranges, or hostnames
for hosts from which admin operations can be initiated.
IP Address
This would allow admin operations from hosts with IP 127.0.0.1 (that’s
localhost
only).
IP Range
This would allow admin operations from hosts with IP between 172.17.0.0
and
172.20.0.0
along with the server which has IP address as 192.168.1.1
.
CIDR Range
This would allow admin operations from hosts that matches the CIDR range
172.17.0.0/16
, 172.18.0.0/15
, 172.20.0.0/32
, or 192.168.1.1/32
(the same
range as the IP Range example).
You can set whitelist IP to 0.0.0.0/0
to whitelist all IP addresses.
Hostname
This would allow admin operations from hosts with hostnames admin-bastion
and
host.docker.internal
.
By default, you can perform mutation operations for any predicate. If the predicate in mutation doesn’t exist in the schema, the predicate gets added to the schema with an appropriate Dgraph Type.
You can use --limit "mutations=disallow"
to disable all mutations, which is
set to allow
by default.
Enforce a strict schema by setting --limit "mutations=strict
. This mode allows
mutations only on predicates already in the schema. Before performing a mutation
on a predicate that doesn’t exist in the schema, you need to perform an alter
operation with that predicate and its schema type.
Clients can use alter operations to apply schema updates and drop particular or all predicates from the database. By default, all clients are allowed to perform alter operations. You can configure Dgraph to only allow alter operations when the client provides a specific token. You can use this “Simple ACL” token to prevent clients from making unintended or accidental schema updates or predicate drops.
You can specify the auth token with the --security
superflag’s token
option
for each Dgraph Alpha in the cluster. Clients must include the same auth token
to make alter requests.
To fully secure alter operations in the cluster, the authentication token must be set for every Alpha node.
As an Administrator
you might want to export data from Dgraph to:
For more information about exporting your database, see Export data
A clean exit of a single Dgraph node is initiated by running the following GraphQL mutation on /admin endpoint.
This won’t work if called from outside the server where Dgraph is running. You
can specify a list or range of whitelisted IP addresses from which shutdown or
other admin operations can be initiated using the --security
superflag’s
whitelist
option on dgraph alpha
.
This stops the Alpha on which the command is executed and not the entire cluster.
To drop all data, you could send a DropAll
request via /alter
endpoint.
Alternatively, you could:
p
and w
directories, thenDoing periodic exports is always a good idea. This is particularly useful if you wish to upgrade Dgraph or reconfigure the sharding of a cluster. The following are the right steps to safely export and restart.
-p
and -w
for Alphas and -w
for Zeros)These steps are necessary because Dgraph’s underlying data format could have changed, and reloading the export avoids encoding incompatibilities.
Blue-green deployment is a common approach to minimize downtime during the
upgrade process. This approach involves switching your app to read-only mode. To
make sure that no mutations are executed during the maintenance window you can
do a rolling restart of all your Alpha using the option --mutations disallow
when you restart the Alpha nodes. This ensures the cluster is in read-only mode.
At this point your app can still read from the old cluster and you can perform steps 4 and 5. When the new cluster (that uses the upgraded version of Dgraph) is up and running, you can point your app to it, and shutdown the old cluster.
Now that Dgraph is up and running, to understand how to add and query data to Dgraph, follow Query Language Spec.
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
You can deploy and manage Dgraph database in a variety of self-managed deployment scenarios, including:
This section focuses exclusively on deployment and management for these self-managed scenarios. To learn about fully managed options that let you focus on building apps and websites, rather than managing infrastructure, or Try Dgraph on Hypermode.
A Dgraph cluster consists of the following:
/admin
HTTP and
gRPC endpoint that can be used for data and node administration tasks such as
backup, export, draining, and shutdown.You need at least one node of each type to run Dgraph. You need three nodes of each type to run Dgraph in a high-availability (HA) cluster configuration. To learn more about 2-node and 6-node deployment options, see the Production Checklist.
Each Dgraph Alpha exposes various administrative (admin) endpoints both over HTTP and GraphQL, for example endpoints to export data and to perform a clean shutdown. All such admin endpoints are protected by three layers of authentication:
--security
superflag’s whitelist
option on
Dgraph Alpha to whitelist IP addresses other than localhost).--security
superflag’s
token
option, then you should pass the token as an X-Dgraph-AuthToken
header while making the HTTP request.X-Dgraph-AccessToken
header while making the HTTP request.An administration endpoint is any HTTP endpoint which provides admin
capabilities. Administration endpoints usually start with the /admin
path. The
current list of admin endpoints includes the following:
/admin
/admin/config/cache_mb
/admin/draining
/admin/shutdown
/admin/schema
/admin/schema/validate
/alter
/login
There are a few exceptions to this general rule:
/login
: This endpoint logs-in an ACL user, and provides them with a JWT.
Only IP Whitelisting and Poor-man’s auth checks are performed for this
endpoint./admin
: This endpoint provides GraphQL queries/mutations corresponding to
the HTTP admin endpoints. All of the queries/mutations on /admin
have all
three layers of authentication, except for login (mutation)
, which has the
same behavior as the HTTP /login
endpoint.By default, admin operations can only be initiated from the machine on which the Dgraph Alpha runs.
You can use the --security
superflag’s whitelist
option to specify a
comma-separated whitelist of IP addresses, IP ranges, CIDR ranges, or hostnames
for hosts from which admin operations can be initiated.
IP Address
This would allow admin operations from hosts with IP 127.0.0.1 (that’s
localhost
only).
IP Range
This would allow admin operations from hosts with IP between 172.17.0.0
and
172.20.0.0
along with the server which has IP address as 192.168.1.1
.
CIDR Range
This would allow admin operations from hosts that matches the CIDR range
172.17.0.0/16
, 172.18.0.0/15
, 172.20.0.0/32
, or 192.168.1.1/32
(the same
range as the IP Range example).
You can set whitelist IP to 0.0.0.0/0
to whitelist all IP addresses.
Hostname
This would allow admin operations from hosts with hostnames admin-bastion
and
host.docker.internal
.
By default, you can perform mutation operations for any predicate. If the predicate in mutation doesn’t exist in the schema, the predicate gets added to the schema with an appropriate Dgraph Type.
You can use --limit "mutations=disallow"
to disable all mutations, which is
set to allow
by default.
Enforce a strict schema by setting --limit "mutations=strict
. This mode allows
mutations only on predicates already in the schema. Before performing a mutation
on a predicate that doesn’t exist in the schema, you need to perform an alter
operation with that predicate and its schema type.
Clients can use alter operations to apply schema updates and drop particular or all predicates from the database. By default, all clients are allowed to perform alter operations. You can configure Dgraph to only allow alter operations when the client provides a specific token. You can use this “Simple ACL” token to prevent clients from making unintended or accidental schema updates or predicate drops.
You can specify the auth token with the --security
superflag’s token
option
for each Dgraph Alpha in the cluster. Clients must include the same auth token
to make alter requests.
To fully secure alter operations in the cluster, the authentication token must be set for every Alpha node.
As an Administrator
you might want to export data from Dgraph to:
For more information about exporting your database, see Export data
A clean exit of a single Dgraph node is initiated by running the following GraphQL mutation on /admin endpoint.
This won’t work if called from outside the server where Dgraph is running. You
can specify a list or range of whitelisted IP addresses from which shutdown or
other admin operations can be initiated using the --security
superflag’s
whitelist
option on dgraph alpha
.
This stops the Alpha on which the command is executed and not the entire cluster.
To drop all data, you could send a DropAll
request via /alter
endpoint.
Alternatively, you could:
p
and w
directories, thenDoing periodic exports is always a good idea. This is particularly useful if you wish to upgrade Dgraph or reconfigure the sharding of a cluster. The following are the right steps to safely export and restart.
-p
and -w
for Alphas and -w
for Zeros)These steps are necessary because Dgraph’s underlying data format could have changed, and reloading the export avoids encoding incompatibilities.
Blue-green deployment is a common approach to minimize downtime during the
upgrade process. This approach involves switching your app to read-only mode. To
make sure that no mutations are executed during the maintenance window you can
do a rolling restart of all your Alpha using the option --mutations disallow
when you restart the Alpha nodes. This ensures the cluster is in read-only mode.
At this point your app can still read from the old cluster and you can perform steps 4 and 5. When the new cluster (that uses the upgraded version of Dgraph) is up and running, you can point your app to it, and shutdown the old cluster.
Now that Dgraph is up and running, to understand how to add and query data to Dgraph, follow Query Language Spec.