尝试在JanusGraph-Docker中创建图形时连接被拒绝

时间:2019-09-26 12:40:35

标签: docker elasticsearch cassandra gremlin janusgraph

我正在使用JanusGraph-Docker映像(https://github.com/JanusGraph/janusgraph-docker)在Docker中设置JanusGraph。当我在没有docker的情况下使用JanusGraph时,对我来说一切正常,但是现在我遇到了一些问题:

我使用以下命令通过Cassandra + Elasticsearch设置janusgraph:

docker-compose -f docker-compose-cql-es.yml up

这将启动所有必需的容器,对此我进行了仔细检查:

docker ps

现在,我想使用以下命令通过Gremlin控制台连接到Janusgraph:

docker-compose -f docker-compose-cql-es.yml run --rm -e GREMLIN_REMOTE_HOSTS=janusgraph janusgraph ./bin/gremlin.sh

这将启动gremlin控制台,我使用以下命令配置遥控器:

:remote connect tinkerpop.server conf/remote.yaml
:remote console

哪个也可以。之后,我尝试创建一个新图,该图失败:

graph = JanusGraphFactory.open('conf/janusgraph-cassandra-es.properties')

这会给我以下消息:

  

连接被拒绝(连接被拒绝)

全栈跟踪:

  

java.net.ConnectException:连接被拒绝(连接被拒绝)       在java.net.PlainSocketImpl.socketConnect(本地方法)       在java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)       在java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)       在java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)       在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)       在java.net.Socket.connect(Socket.java:589)       在org.apache.thrift.transport.TSocket.open(TSocket.java:182)       在org.apache.thrift.transport.TFramedTransport.open(TFramedTransport.java:81)       在org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory.makeRawConnection(CTConnectionFactory.java:110)处       在org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory.makeObject(CTConnectionFactory.java:74)       在org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory.makeObject(CTConnectionFactory.java:43)       在org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1220)       在org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager.getCassandraPartitioner(CassandraThriftStoreManager.java:215)       在org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager。(CassandraThriftStoreManager.java:197)       在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)处       在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)       在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)       在java.lang.reflect.Constructor.newInstance(Constructor.java:423)       在org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:58)       在org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:440)       在org.janusgraph.diskstorage.Backend.getStorageManager(Backend.java:411)       在org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder.build(GraphDatabaseConfigurationBuilder.java:50)       在org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:161)       在org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:132)       在org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:79)       在org.janusgraph.core.JanusGraphFactory $ open.call(未知来源)       在Script4.run(Script4.groovy:1)       在org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:674)       在org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:376)       在javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)       在org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda $ eval $ 0(GremlinExecutor.java:266)中       在java.util.concurrent.FutureTask.run(FutureTask.java:266)       在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)       在java.util.concurrent.FutureTask.run(FutureTask.java:266)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)       在java.lang.Thread.run(Thread.java:748)

由于janusgraph服务器似乎预先部署了带有遍历对象的图形,因此我可以运行以下查询:

g.addV('user').property('username','exampleUserName')

但是当我尝试使用以下命令从python gremlin连接时:

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://0.0.0.0:8182/gremlin','g'))

我遇到同样的错误,有帮助吗?

1 个答案:

答案 0 :(得分:0)

请注意,当服务器在0.0.0.0上侦听时,这意味着可以从运行该服务器的计算机以外的其他计算机上访问该服务器。在127.0.0.1上侦听的另一种方法意味着只能从与服务器运行相同主机上的进程访问它。

但是,当客户端连接到服务器时,它必须指定其连接到的实际主机名或IP地址,可以是localhost127.0.0.1或服务器在网络上连接到的IP地址是什么。但是,不能在客户端到服务器的连接字符串中使用0.0.0.0,因为这不是要连接的有效IP地址。