如何在titan/hbase的远程gremlin服务器上运行gremlin脚本?

如何在titan/hbase的远程gremlin服务器上运行gremlin脚本?,gremlin,titan,tinkerpop,gremlin-server,Gremlin,Titan,Tinkerpop,Gremlin Server,我正在使用titan/hbase存储数据,titan和hbase驻留在远程服务器机器中。我用bin/titan.sh start启动了Gremlin服务器。之后,我在服务器计算机上运行了以下命令,运行良好: bin/gremlin.sh \,,,/ (o o) -----oOOo-(3)-oOOo----- plugin activated: aurelius.titan plugin activated: tinkerpop.server plugin

我正在使用titan/hbase存储数据,titan和hbase驻留在远程服务器机器中。我用
bin/titan.sh start
启动了Gremlin服务器。之后,我在服务器计算机上运行了以下命令,运行良好:

bin/gremlin.sh 

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: aurelius.titan
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/titan-1.0.0-hadoop1/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/titan-1.0.0-hadoop1/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
18:32:20 INFO  org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph  - HADOOP_GREMLIN_LIBS is set to: /usr/local/titan-1.0.0-hadoop1/lib
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.tinkergraph
gremlin> g = TitanFactory.open("conf/titan-hbase.properties")
==>standardtitangraph[hbase:[192.168.1.65]]
gremlin> gr = g.traversal()
==>graphtraversalsource[standardtitangraph[hbase:[192.168.1.65]], standard]
gremlin> gr.V().count()
18:33:37 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
==>41
现在,为了检查远程连接,我刚从客户机运行了
gremlin.sh
,然后

gremlin> :remote connect tinkerpop.server conf/remote.yaml 
g=TitanFactory.open("conf/titan-hbase.properties")
我得到以下信息:

java.lang.RuntimeException: com.thinkaurelius.titan.diskstorage.TemporaryBackendException: Temporary failure in storage backend
    at com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager.getDeployment(HBaseStoreManager.java:351)
    at com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager.getFeatures(HBaseStoreManager.java:389)
    at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.<init>(GraphDatabaseConfiguration.java:1321)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:94)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:78)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:70)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:104)
    at org.apache.tinkerpop.gremlin.server.GraphManager.lambda$new$27(GraphManager.java:50)
    at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:663)
    at org.apache.tinkerpop.gremlin.server.GraphManager.<init>(GraphManager.java:48)
    at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:94)
    at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:88)
    at pluradj.titan.tinkerpop3.example.ServiceTest.startServer(ServiceTest.java:37)
    at pluradj.titan.tinkerpop3.example.ServiceTest.setUp(ServiceTest.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.thinkaurelius.titan.diskstorage.TemporaryBackendException: Temporary failure in storage backend
    at com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager.ensureTableExists(HBaseStoreManager.java:759)
    at com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager.getLocalKeyPartition(HBaseStoreManager.java:556)
    at com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager.getDeployment(HBaseStoreManager.java:347)
    ... 43 more
Caused by: org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=35, exceptions:

    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:129)
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:90)
    at org.apache.hadoop.hbase.client.ClientScanner.nextScanner(ClientScanner.java:264)
    at org.apache.hadoop.hbase.client.ClientScanner.initializeScannerInConstruction(ClientScanner.java:169)
    at org.apache.hadoop.hbase.client.ClientScanner.<init>(ClientScanner.java:164)
    at org.apache.hadoop.hbase.client.ClientScanner.<init>(ClientScanner.java:107)
    at org.apache.hadoop.hbase.client.HTable.getScanner(HTable.java:736)
    at org.apache.hadoop.hbase.catalog.MetaReader.fullScan(MetaReader.java:539)
    at org.apache.hadoop.hbase.catalog.MetaReader.tableExists(MetaReader.java:310)
    at org.apache.hadoop.hbase.client.HBaseAdmin.tableExists(HBaseAdmin.java:279)
    at org.apache.hadoop.hbase.client.HBaseAdmin.tableExists(HBaseAdmin.java:293)
    at com.thinkaurelius.titan.diskstorage.hbase.HBaseAdmin0_98.tableExists(HBaseAdmin0_98.java:93)
    at com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager.ensureTableExists(HBaseStoreManager.java:753)
    ... 45 more
Caused by: java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
    at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:511)
    at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:481)
    at org.apache.hadoop.hbase.ipc.RpcClient$Connection.setupConnection(RpcClient.java:578)
    at org.apache.hadoop.hbase.ipc.RpcClient$Connection.setupIOstreams(RpcClient.java:866)
    at org.apache.hadoop.hbase.ipc.RpcClient.getConnection(RpcClient.java:1536)
    at org.apache.hadoop.hbase.ipc.RpcClient.call(RpcClient.java:1435)
    at org.apache.hadoop.hbase.ipc.RpcClient.callBlockingMethod(RpcClient.java:1654)
    at org.apache.hadoop.hbase.ipc.RpcClient$BlockingRpcChannelImplementation.callBlockingMethod(RpcClient.java:1712)
    at org.apache.hadoop.hbase.protobuf.generated.ClientProtos$ClientService$BlockingStub.scan(ClientProtos.java:29900)
    at org.apache.hadoop.hbase.client.ScannerCallable.openScanner(ScannerCallable.java:302)
    at org.apache.hadoop.hbase.client.ScannerCallable.call(ScannerCallable.java:157)
    at org.apache.hadoop.hbase.client.ScannerCallable.call(ScannerCallable.java:57)
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:114)
    ... 57 more
而remote.yaml是:

hosts: [192.168.1.65]
port: 8182
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}

这里出了什么问题?如何实现这一点?

您需要做的是使用Titan HBase属性配置Gremlin服务器。在这种情况下,您根本不应该使用
titan.sh
,因为它会自动启动Cassandra和Elasticsearch节点,所以请确保在继续之前使用
bin/titan.sh stop
关闭该节点

  • 将您的
    titan hbase.properties
    放在
    conf/gremlin server/
    下。您在上面发布的内容看起来不错,只是最后一个属性名应该是
    storage.hbase.table

  • 使用Titan HBase配置更新
    conf/gremlin server/
    下的
    gremlin server.yaml
    (默认配置使用Cassandra+Elasticsearch)。此外,请记住,如果要从其他计算机连接到Gremlin服务器,则需要将主机更新为服务器的IP地址
    192.168.1.65

    图:{graph:conf/gremlin server/titan-hbase.properties}

  • 使用
    bin/Gremlin Server.sh
    启动Gremlin服务器。在启动时查看日志中的错误。如果成功,您将看到一条信息消息,说明
    graph
    g
    已配置并绑定
    g
    scripts/empty sample.groovy
    脚本中定义,该脚本通过
    conf/gremlin server.yaml
    加载

    8456[main]INFO org.apache.tinkerpop.gremlin.server.GremlinServer-已通过[conf/gremlin server/titan hbase.properties]成功配置图形[Graph]。
    9349[main]INFO org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor-GraphTraversalSource[standardtitangraph[hbase:[127.0.0.1]],standard]

  • 启动Gremlin控制台,并使用
    conf/remote.yaml
    创建到Gremlin服务器的远程连接。由于
    graph
    g
    已经通过服务器配置绑定,因此不需要在控制台中初始化它们。确保在查询开始时使用
    :>
    将命令发送到远程服务器

  • 下面是一个小精灵控制台会话示例:

    gremlin> :remote connect tinkerpop.server conf/remote.yaml
    ==>Connected - localhost/127.0.0.1:8182
    gremlin> :> g.V().count()
    ==>12
    

    请参阅,以从Gremlin控制台连接到Gremlin服务器。

    您需要做的是使用Titan HBase属性配置Gremlin服务器。在这种情况下,您根本不应该使用
    titan.sh
    ,因为它会自动启动Cassandra和Elasticsearch节点,所以请确保在继续之前使用
    bin/titan.sh stop
    关闭该节点

  • 将您的
    titan hbase.properties
    放在
    conf/gremlin server/
    下。您在上面发布的内容看起来不错,只是最后一个属性名应该是
    storage.hbase.table

  • 使用Titan HBase配置更新
    conf/gremlin server/
    下的
    gremlin server.yaml
    (默认配置使用Cassandra+Elasticsearch)。此外,请记住,如果要从其他计算机连接到Gremlin服务器,则需要将主机更新为服务器的IP地址
    192.168.1.65

    图:{graph:conf/gremlin server/titan-hbase.properties}

  • 使用
    bin/Gremlin Server.sh
    启动Gremlin服务器。在启动时查看日志中的错误。如果成功,您将看到一条信息消息,说明
    graph
    g
    已配置并绑定
    g
    scripts/empty sample.groovy
    脚本中定义,该脚本通过
    conf/gremlin server.yaml
    加载

    8456[main]INFO org.apache.tinkerpop.gremlin.server.GremlinServer-已通过[conf/gremlin server/titan hbase.properties]成功配置图形[Graph]。
    9349[main]INFO org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor-GraphTraversalSource[standardtitangraph[hbase:[127.0.0.1]],standard]

  • 启动Gremlin控制台,并使用
    conf/remote.yaml
    创建到Gremlin服务器的远程连接。由于
    graph
    g
    已经通过服务器配置绑定,因此不需要在控制台中初始化它们。确保在查询开始时使用
    :>
    将命令发送到远程服务器

  • 下面是一个小精灵控制台会话示例:

    gremlin> :remote connect tinkerpop.server conf/remote.yaml
    ==>Connected - localhost/127.0.0.1:8182
    gremlin> :> g.V().count()
    ==>12
    
    有关从Gremlin控制台连接到Gremlin服务器的信息,请参阅