Set up the Gremlin Console to Connect to a Neptune DB Instance

2020年04月22日

-
Below are detailed steps corresponding to the guidance from AWS official document.

Launch an AWS EC2 instance (t3a.nano-micro, Amaon Linux AMI (not Amazon Linux 2 AMI), same VPC as the Neptune instance, assign IAM role)

sudo yum install -y java-1.8.0-devel

sudo /usr/sbin/alternatives --config java

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64/jre/bin/java)

Enter to keep the current selection[+], or type selection number: 1
When prompted, enter the number for Java 8.

wget https://archive.apache.org/dist/tinkerpop/3.4.1/apache-tinkerpop-gremlin-console-3.4.1-bin.zip
wget https://archive.apache.org/dist/tinkerpop/3.3.2/apache-tinkerpop-gremlin-console-3.3.2-bin.zip

unzip apache-tinkerpop-gremlin-console-3.4.1-bin.zip > /dev/null

cd apache-tinkerpop-gremlin-console-3.4.1

wget https://www.amazontrust.com/repository/SFSRootCAG2.pem

vim conf/neptune-remote.yaml
hosts: [your-neptune-endpoint]
port: 8182
connectionPool: { enableSsl: true, trustCertChainFile: "SFSRootCAG2.pem"}
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
Replace your-neptune-endpoint with the hostname or IP address of your Neptune DB instance.

bin/gremlin.sh
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> :remote connect tinkerpop.server conf/neptune-remote.yaml
WARN  org.apache.tinkerpop.gremlin.driver.Cluster  - Using deprecated SSL trustCertChainFile support
WARN  org.apache.tinkerpop.gremlin.driver.Cluster  - Using deprecated SSL trustCertChainFile support
==>Configured ***.***.us-west-2.neptune.amazonaws.com/10.*.*.*:8182

Enter the following to switch to remote mode. This sends all Gremlin queries to the remote connection.
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [***.***.us-west-2.neptune.amazonaws.com/10.0.*.*:8182] - type ':remote console' to return to local mode

gremlin> g.V().limit(1)
==>v[1]

gremlin> :exit


Next time login to Neptune Gremlin, only follow below steps.

cd apache-tinkerpop-gremlin-console-3.4.1

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

gremlin> :remote connect tinkerpop.server conf/neptune-remote.yaml
WARN  org.apache.tinkerpop.gremlin.driver.Cluster  - Using deprecated SSL trustCertChainFile support
WARN  org.apache.tinkerpop.gremlin.driver.Cluster  - Using deprecated SSL trustCertChainFile support
==>Configured ***.***.us-west-2.neptune.amazonaws.com/10.0.*.*:8182

gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [***.***.us-west-2.neptune.amazonaws.com/10.0.*.*:8182] - type ':remote console' to return to local mode


References

Using the Gremlin Console to Connect to a Neptune DB Instance

Category: GraphDB Tags: public

Upvote


Downvote