知识库

错误“Failed to obtain connection towards WRITE server. Known routing table is: Ttl…​”解释

在 Neo4j 4.0 中,如果您登录到因果集群的 READ_REPLICA,并执行以下命令登录到 cypher-shell

$ $NEO4J_HOME/bin/cypher-shell -u neo4j -p mypwd

您将遇到此错误

Failed to obtain connection towards WRITE server.
Known routing table is: Ttl 1589334991968, currentTime 1589334691977,
routers AddressSet=[localhost:7637], writers AddressSet=[],
readers AddressSet=[localhost:7637], database '<default database>'
在 4.0 版本之前,上述命令是登录 cypher-shell 的完全有效/正确命令。

原因是命令中地址(-a)参数的默认值为 neo4j://localhost:7687

语法在 cypher-shell 命令行帮助中记载为

$ $NEO4J_HOME/bin/cypher-shell -help
 -a ADDRESS, --address ADDRESS
                         address and port to connect to (default: neo4j://localhost:7687)

默认值 neo4j://localhost:7687 的含义是 cypher-shell 将登录命令解释为

$ $NEO4J_HOME/bin/cypher-shell -u neo4j -p mypwd -a neo4j://localhost:7687
上述命令是无效/错误的。neo4j URI 方案是 bolt+routing 在 4.0 中的等效,应仅用于连接到因果集群中的 CORE 服务器之一,而非任何 READ REPLICA

要解决此错误并登录到 READ_REPLICAcypher-shell,请改用以下命令

$ $NEO4J_HOME/bin/cypher-shell -u neo4j -p mypwd -a bolt://localhost:7687

从不同的 Causal Cluster 成员连接到 READ REPLICA 时,请使用如下命令

$ $NEO4J_HOME/bin/cypher-shell -u neo4j -p mypwd -a bolt://<read-replica-server-ip>:7687
本文的一个关键点是,如果您使用 neo4jbolt+routing URI 方案,您应该连接到 Causal Cluster 中的 CORE 节点,而不是 READ_REPLICA
© . All rights reserved.