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 so it is 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. This was written and tested on JanusGraph v0.6.0.

You will also need to:

Prepare your secure bundle

  1. On the JanusGraph server, unpack your secure bundle.

    • Example commands

    • Example file listing

    $ cd /path/to/scb
    $ unzip secure-connect-graphdb.zip
    /
      path/
        to/
          scb/
            ca.crt
            cert
            cert.pfx
            config.json
            cqlshrc
            identity.jks
            key
            trustStore.jks
  2. Extract your database metadata from the config.json file.

    • Example config.json

    {
      "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

  1. On the JanusGraph server, modify the CQL storage configuration file janusgraph-cql.properties. Make the necessary changes using the example template below.

    • Example commands

    • Example template

    $ 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.
  2. Using the example values in the config.json above, the conf/janusgraph-cql.properties would contain:

    • Example config.json

    # 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

  1. Start a Gremlin console.

    • Command

    $ bin/gremlin.sh
    
             \,,,/
             (o o)
    -----oOOo-(3)-oOOo-----
    gremlin>
  2. Load a graph using Astra as the storage backend with:

    • Command

    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 text file with a sample output for comparison of what to expect.

  3. In the Astra DB CQL Console, check that the JanusGraph tables were successfully created:

    • Example

    token@cqlsh> USE graphks;
    token@cqlsh:graphks> DESCRIBE TABLES;
    
    edgestore_lock_  graphindex_lock_         janusgraph_ids
    txlog            systemlog                graphindex
    edgestore        system_properties_lock_  system_properties