Integrate JanusGraph and Astra DB Serverless
JanusGraph supports graph traversals and analytical queries on extremely large graphs. Your Astra DB Serverless databases can be the storage backend for JanusGraph.
Prepare Astra
-
Create an Astra DB Serverless database or use an existing one.
-
Generate an application token with the Database Administrator role.
-
Download your database’s Secure Connect Bundle (SCB).
-
Create a keyspace in your database where JanusGraph will store the graph. There is no required name for this keyspace; you specify the keyspace name in your JanusGraph configuration.
Configure JanusGraph
-
Deploy and start a JanusGraph instance if you don’t already have one.
-
Store your database’s SCB zip file in a location where it can be accessed by your JanusGraph deployment.
JanusGraph uses the Apache Cassandra® Java driver to connect to Astra, which requires access to the SCB. If you are running JanusGraph locally, you can store the SCB zip file anywhere on your local filesystem. If you are running JanusGraph as a container or remote deployment, choose an appropriate location based on your deployment infrastructure.
-
Set the Astra connection parameters in your JanusGraph CQL storage configuration file (
conf/janusgraph-cql.properties
). You can set the properties directly, with a JVM argument, or use an external configuration file.-
Direct string configuration
-
JVM argument configuration
-
External file configuration
janusgraph-cql.propertiesgremlin.graph=org.janusgraph.core.JanusGraphFactory storage.backend=cql storage.cql.keyspace=KEYSPACE storage.username=token storage.password=APPLICATION_TOKEN storage.cql.internal.string-configuration=datastax-java-driver { basic.cloud.secure-connect-bundle=PATH/TO/SCB.zip }
Replace the following:
-
KEYSPACE
: The name of the keyspace you created for JanusGraph in Astra. -
APPLICATION_TOKEN
: A secure reference to your Astra application token (prefixed byAstraCS:
). -
PATH/TO/SCB.zip
: The path to your database’s SCB zip file.
-
Set the following in your
janusgraph-cql.properties
file:gremlin.graph=org.janusgraph.core.JanusGraphFactory storage.backend=cql storage.cql.keyspace=KEYSPACE storage.username=token storage.password=APPLICATION_TOKEN
Replace the following:
-
KEYSPACE
: The name of the keyspace you created for JanusGraph in Astra. -
APPLICATION_TOKEN
: A secure reference to your Astra application token (prefixed byAstraCS:
).
-
-
When starting JanusGraph, use a JVM argument to pass the driver configuration with the path to your database’s SCB:
-Ddatastax-java-driver.basic.cloud.secure-connect-bundle=PATH/TO/SCB.zip
Use this option if you want to separate the Java driver configuration for Astra from the rest of your JanusGraph configuration.
-
Create a
.conf
file that contains the Java driver configuration:astra.confdatastax-java-driver { basic.cloud { secure-connect-bundle = "PATH/TO/SCB.zip" } advanced.auth-provider { class = PlainTextAuthProvider username = "token" password = "APPLICATION_TOKEN" } }
Replace the following:
-
KEYSPACE
: The name of the keyspace you created for JanusGraph in Astra. -
APPLICATION_TOKEN
: A secure reference to your Astra application token (prefixed byAstraCS:
). -
PATH/TO/SCB.zip
: The path to your database’s SCB zip file.
-
-
In your
janusgraph-cql.properties
file, set your JanusGraph keyspace and the path to your external configuration file:janusgraph-cql.propertiesgremlin.graph=org.janusgraph.core.JanusGraphFactory storage.backend=cql storage.cql.keyspace=KEYSPACE storage.cql.internal.file-configuration=PATH/TO/ASTRA.conf
-
The |
Test the JanusGraph integration
-
Start a Gremlin console:
bin/gremlin.sh
-
Load a graph using Astra as the storage backend:
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-cql.properties') ==>standardjanusgraph[cql:[70bf8560-105f-11ec-a3ea-0800200c9a66-us-west1.db.astra.datastax.com]]
Some warnings are normal and can be ignored.
-
Use
cqlsh
to check that the JanusGraph tables are present in Astra:DESCRIBE KEYSPACE_NAME;
Replace
KEYSPACE_NAME
with the name of your JanusGraph keyspace.Result
edgestore_lock_ graphindex_lock_ janusgraph_ids txlog systemlog graphindex edgestore system_properties_lock_ system_properties