Set up the Gremlin console to connect to a Neptune DB instance - Amazon Neptune

Set up the Gremlin console to connect to a Neptune DB instance

The Gremlin Console allows you to experiment with TinkerPop graphs and queries in a REPL (read-eval-print loop) environment.

You can use the Gremlin Console to connect to a remote graph database. The following section walks you through installing and configuring the Gremlin Console to connect remotely to a Neptune DB instance. You must follow these instructions from an Amazon EC2 instance in the same virtual private cloud (VPC) as your Neptune DB instance.

To install the Gremlin Console and connect to Neptune

  1. The Gremlin Console binaries require Java 8. Enter the following to install Java 8 on your EC2 instance.

    sudo yum install java-1.8.0-devel
  2. Enter the following to set Java 8 as the default runtime on your EC2 instance.

    sudo /usr/sbin/alternatives --config java

    When prompted, enter the number for Java 8.

  3. Download the appropriate version of the Gremlin console from the Apache web site. You can check the engine release page for the Neptune engine version you are currently running to determine which Gremlin version it supports. For example, for version 3.4.8, you can download the Gremlin console from the Apache Tinkerpop3 website onto your EC2 instance like this:

  4. Unzip the Gremlin Console zip file.

  5. Change directories into the unzipped directory.

    cd apache-tinkerpop-gremlin-console-3.4.8
  6. Install the CA certificate. Gremlin Console requires a certificate to verify the remote certificate.

    1. Download the certificate:

    2. Create a directory for certificates:

      mkdir /tmp/certs/
    3. Copy Java certificates into the new directory:

      cp jre_path/lib/security/cacerts /tmp/certs/cacerts
    4. Add the Amazon certificate to the repository:

      sudo keytool -importcert \ -alias neptune-tests-ca \ -keystore /tmp/certs/cacerts \ -file /home/ec2-user/apache-tinkerpop-gremlin-console-3.4.8/SFSRootCAG2.cer \ -noprompt \ -storepass changeit
  7. In the conf subdirectory of the extracted directory, create a file named neptune-remote.yaml with the following text. Replace your-neptune-endpoint with the hostname or IP address of your Neptune DB instance. The square brackets ([ ]) are required.


    For information about finding the hostname of your Neptune DB instance, see the Connecting to Amazon Neptune Endpoints section.

    hosts: [your-neptune-endpoint] port: 8182 connectionPool: { enableSsl: true, trustStore: /tmp/certs/cacerts } serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
  8. In a terminal, navigate to the Gremlin Console directory (apache-tinkerpop-gremlin-console-3.4.8), and then enter the following command to run the Gremlin Console.


    You should see the following output:

    \,,,/ (o o) -----oOOo-(3)-oOOo----- plugin activated: tinkerpop.server plugin activated: tinkerpop.utilities plugin activated: tinkerpop.tinkergraph gremlin>

    You are now at the gremlin> prompt. You will enter the remaining steps at this prompt.

  9. At the gremlin> prompt, enter the following to connect to the Neptune DB instance.

    :remote connect tinkerpop.server conf/neptune-remote.yaml
  10. At the gremlin> prompt, enter the following to switch to remote mode. This sends all Gremlin queries to the remote connection.

    :remote console
  11. Enter the following to send a query to the Gremlin Graph.

  12. When you are finished, enter the following to exit the Gremlin Console.


Use a semicolon (;) or a newline character (\n) to separate each statement.

Each traversal preceding the final traversal must end in next() to be executed. Only the data from the final traversal is returned.

For more information on the Neptune implementation of Gremlin, see Gremlin standards compliance in Amazon Neptune.