Neo4j远程shell通过流浪问题

时间:2015-06-28 15:32:29

标签: neo4j vagrant vagrantfile

我正在我的Vagrant机器中运行Neo4j实例。我将这些行放入neo4j.properties以使用远程shell启动服务器

remote_shell_enabled=true
remote_shell_host=0.0.0.0
remote_shell_port=1337

我使用命令bin/neo4j start

启动neo4j服务器

之后,我在vagrant中使用neo4j shell连接到远程shell,它工作正常。

我在Vagrantfile

中将端口1337转发到主机
config.vm.network :forwarded_port, guest: 1337, host: 9255

然后在我的主机(MacOS)上,我使用neo4j shell连接到该服务器但是我失败了

$ bin/neo4j-shell -port 9255 -v
Unable to find any JVMs matching version "1.7".
ERROR (-v for expanded information):
    Connection refused
java.rmi.ConnectException: Connection refused to host: 10.0.2.15; nested exception is:
    java.net.ConnectException: Operation timed out
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:130)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
    at com.sun.proxy.$Proxy1.welcome(Unknown Source)
    at org.neo4j.shell.impl.AbstractClient.sayHi(AbstractClient.java:254)
    at org.neo4j.shell.impl.RemoteClient.findRemoteServer(RemoteClient.java:70)
    at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:62)
    at org.neo4j.shell.impl.RemoteClient.<init>(RemoteClient.java:45)
    at org.neo4j.shell.ShellLobby.newClient(ShellLobby.java:178)
    at org.neo4j.shell.StartClient.startRemote(StartClient.java:302)
    at org.neo4j.shell.StartClient.start(StartClient.java:179)
    at org.neo4j.shell.StartClient.main(StartClient.java:124)
Caused by: java.net.ConnectException: Operation timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.<init>(Socket.java:434)
    at java.net.Socket.<init>(Socket.java:211)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
    ... 14 more

流浪汉机器没有防火墙,我仍然可以连接到网络界面

2 个答案:

答案 0 :(得分:1)

<强>更新

神圣## @ **(*我让它在6个多小时后工作!默认配置Neo4j只接受本地连接。我不是网络用户,但显然neo4j可以告诉端口转发的连接是非本地的要修复,您需要配置neo4j.conf文件以接受非本地连接

# To accept non-local connections, uncomment this line:
dbms.connectors.default_listen_address=0.0.0.0

# You also need to remove the 'advertised_address' from each connector,
# so that only the port is specified
# i.e. my conf file originally had dbms.connector.bolt.listen_address=localhost:7472
# I changed it to dbms.connector.bolt.listen_address=:7472

# Bolt connector
dbms.connector.bolt.enabled=true
dbms.connector.bolt.listen_address=:7472

# HTTP Connector. There must be exactly one HTTP connector.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474

# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=false
dbms.connector.https.listen_address=:7473

当然,除了所有这些之外,您还需要在vagrantfile中正确设置端口转发功能。奇怪的是,我发现我需要确保共享每个端口neo4j正在广播(http,https,bolt),否则Web控制台会出现一些间歇性的连接问题。总而言之,我现在可以通过neo4j-shellcypher-shellweb console - 从我的主机正确连接。

<强>原始

我遇到了类似的问题。在您的情况下,输出错误包括Unable to find any JVMs matching version "1.7". bin/neo4j-shell文件是用Java编写的,我相信(或者它开始依赖于Java的shell)。主机需要安装java开发工具包(JDK)才能运行该命令。尝试安装JDK并再次运行它。

总而言之,我 DO 在我的机器上安装了JDK(现在为“1.8”),当我尝试运行bin/cypher-shell时,我遇到了类似的问题(已从我的主机(Mac)替换bin/neo4j-shell}:Unable to connect to localhost:7687, ensure the database is running and that there is a working network connection to it.当我尝试从vagrant内部进行连接时,我不会遇到任何错误。我的vagrantfile包含config.vm.network "forwarded_port", guest: 7687, host: 7687, host_ip: "127.0.0.1"

我还会注意到,虽然我可以连接到vagrant内的neo4j网络界面,但我无法连接到主机上的网络界面(即端口转发似乎没有任何效果neo4j相关)。不过,我可以连接到在我的主机上同一vagrant box内运行的rails应用程序。虽然我没有尝试过,但我想我可以通过我的Rails应用程序间接访问neo4j数据库(因为我的Rails应用程序正确地进行了端口转发)。

答案 1 :(得分:0)

我仍然无法解决这个问题,但我找到了另一种解决方法,所以我会在这里发布。我们可以使用ssh隧道来假装我们从该服务器连接到localhost。使用ssh直接从远程主机执行命令

ssh user@host /path/to/neo4j-shell

或者如果你正在使用流浪汉

vagrant ssh -c '/path/to/neo4j-shell'