Configure JanusGraph with Astra DB as storage backend
Use DataStax Astra DB as the storage backend for JanusGraph server.
JanusGraph uses the Java driver to connect to Apache Cassandra®. The Java driver supports the use of the secure connect bundle to connect to Astra DB, but JanusGraph does not provide this functionality. Thus it’s necessary to unpack the secure connect bundle and use its contents to configure JanusGraph.
Prerequisites
This article assumes you have a running installation of JanusGraph server. These steps were written and tested on JanusGraph v0.6.0.
You will also need to:
-
Generate an application token for your Astra DB.
-
Download the secure connect bundle for your Astra DB.
Prepare your secure bundle
-
On the JanusGraph server, unpack your secure bundle.
-
Extract your database metadata from the
config.json
file.{ "host": "70bf8560-105f-11ec-a3ea-0800200c9a66-us-west1.db.astra.datastax.com", "port": 98765, "cql_port": 34567, "keyspace": "graphks", "localDC": "us-west1", "caCertLocation": "./ca.crt", "keyLocation": "./key", "certLocation": "./cert", "keyStoreLocation": "./identity.jks", "keyStorePassword": "Kga1OJ83EF2oBQYR5", "trustStoreLocation": "./trustStore.jks", "trustStorePassword": "n8F9ptJO3H7YRxTW1", "csvLocation": "./data", "pfxCertPassword": "9b3HgFChtY60m4nfJ" }
Configure JanusGraph
-
On the JanusGraph server, modify the CQL storage configuration file
janusgraph-cql.properties
. Make the necessary changes using the example template below.$ cd /path/to/installation/janusgraph-0.6.0 $ vi conf/janusgraph-cql.properties
# basic CQL settings gremlin.graph=org.janusgraph.core.JanusGraphFactory storage.backend=cql storage.hostname=CONFIG-JSON-HOST storage.port=CONFIG-JSON-CQL-PORT storage.username=token <----- literally the string "token" storage.password=ASTRA_APP_TOKEN storage.cql.keyspace=GRAPH_KEYSPACE storage.cql.local-datacenter=CONFIG-JSON-LOCALDC # SSL related settings storage.cql.ssl.enabled=true storage.cql.ssl.truststore.location=/path/to/scb/trustStore.jks storage.cql.ssl.truststore.password=CONFIG-JSON-TRUSTSTOREPASSWORD storage.cql.ssl.keystore.location=/path/to/scb/identity.jks storage.cql.ssl.keystore.keypassword=CONFIG-JSON-KEYSTOREPASSWORD storage.cql.ssl.keystore.storepassword=CONFIG-JSON-KEYSTOREPASSWORD storage.cql.ssl.client-authentication-enabled=true # consistency settings storage.cql.read-consistency-level=LOCAL_QUORUM storage.cql.write-consistency-level=LOCAL_QUORUM
The username to connect to Astra is literally the word "token". Do not set this value to your DB’s client ID. The ASTRA_APP_TOKEN
is from the token you generated in the Prerequisites section above. -
Using the example values in the
config.json
above, theconf/janusgraph-cql.properties
would contain:# basic CQL settings gremlin.graph=org.janusgraph.core.JanusGraphFactory storage.backend=cql storage.hostname=70bf8560-105f-11ec-a3ea-0800200c9a66-us-west1.db.astra.datastax.com storage.port=34567 storage.username=token storage.password=AstraCS:AbCwZYOKqvXHZWRvpbvHqXYz:47820923e5be3b7b9e689bc18614c631d5fdd8b435e68613433651fd20fexyz0 storage.cql.keyspace=graphks storage.cql.local-datacenter=us-west1 # SSL related settings storage.cql.ssl.enabled=true storage.cql.ssl.truststore.location=/path/to/scb/trustStore.jks storage.cql.ssl.truststore.password=n8F9ptJO3H7YRxTW1 storage.cql.ssl.keystore.location=/path/to/scb/identity.jks storage.cql.ssl.keystore.keypassword=Kga1OJ83EF2oBQYR5 storage.cql.ssl.keystore.storepassword=Kga1OJ83EF2oBQYR5 storage.cql.ssl.client-authentication-enabled=true # consistency settings storage.cql.read-consistency-level=LOCAL_QUORUM storage.cql.write-consistency-level=LOCAL_QUORUM
Final test
-
Start a Gremlin console.
-
Load a graph using Astra as the storage backend with:
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-cql.properties') ==>standardjanusgraph[cql:[70bf8560-105f-11ec-a3ea-0800200c9a66-us-west1.db.astra.datastax.com]]
Note that it is normal to see some warnings on the Gremlin console. See this file with a sample output for comparison of what to expect.
-
In the Astra DB CQL Console, check that the JanusGraph tables were successfully created: