在 HA 中启动 Neo4j 并返回网络错误

在 HA 中启动 Neo4j 并返回网络错误

我目前正尝试在我们的内部云中运行 Neo4j 3.0.3。

我有3个节点,它们的本地IP是:

  • 172.16.1.8
  • 172.16.1.74
  • 172.16.1.79

neo4j.conf文件与所有节点相同,除了ha.server_id参数:

# Database mode
# Allowed values:
# HA - High Availability
# SINGLE - Single mode, default.
# To run in High Availability mode uncomment this line:
dbms.mode=HA

# ha.server_id is the number of each instance in the HA cluster. It should be
# an integer (e.g. 1), and should be unique for each cluster instance.
ha.server_id=1 # 2 or 3, depending on which server it's running

# ha.initial_hosts is a comma-separated list (without spaces) of the host:port
# where the ha.host.coordination of all instances will be listening. Typically
# this will be the same for all cluster instances.
ha.initial_hosts=172.16.1.8:5001,172.16.1.74:5001,172.16.1.79:5001

# HTTP Connector
dbms.connector.http.type=HTTP
dbms.connector.http.enabled=true
#dbms.connector.http.encryption=NONE
# To have HTTP accept non-local connections, uncomment this line
dbms.connector.http.address=0.0.0.0:7474

这与文档。我只是使用 IP 地址而不是主机名。

然后我运行neo4j start并查看日志。这是我得到的:

2016-08-02 19:17:01.211+0000 ERROR Failed to start Neo4j: Starting Neo4j failed:
 Component 'org.neo4j.server.database.LifecycleManagingDatabase@25a55713' was su
ccessfully initialized, but failed to start. Please see attached cause exception
. Starting Neo4j failed: Component 'org.neo4j.server.database.LifecycleManagingD
atabase@25a55713' was successfully initialized, but failed to start. Please see
attached cause exception.
org.neo4j.server.ServerStartupException: Starting Neo4j failed: Component 'org.n
eo4j.server.database.LifecycleManagingDatabase@25a55713' was successfully initia
lized, but failed to start. Please see attached cause exception.

异常被链接起来直到这个:

Caused by: java.lang.RuntimeException: java.net.UnknownHostException: npc_cvalor_v1_db3-a923e8d7-0e02-4209-9bac-c5a55d7a09c6.arq.lab: npc_cvalor_v1_db3-a923e8d7-0e02-4209-9bac-c5a55d7a09c6.arq.lab: unknown error

奇怪的是,两个节点可以互相看到对方(通过测试ping),所以我不知道是什么原因导致了这个问题,但我相信这与 Java 有关。

有什么想法吗?

附加信息:我正在运行带有 Java 1.8.0(IBM 发行版)的 RHEL 7

答案1

我发现了问题所在。

由于某些我尚不清楚的原因,组件java.net.*无法将主机名解析为其正在运行的服务器的 IP。

我必须在/etc/hosts文件中添加一个条目,将服务器 IP 指向主机名:

# On Server 1
172.16.1.8 <full.hostname> <hostname>

# On Server 2
172.16.1.74 <full.hostname> <hostname>

# On Server 3
172.16.1.79 <full.hostname> <hostname>

相关内容