3

在同一个数据中心,我有一个应用程序服务器(客户端)连接到一个包含 3 个节点的 couchbase 集群。

我希望客户端通过内部 IP 而不是外部 IP 进行连接以优化性能。假设这些是我的 IP:

  • 节点1内部IP/节点1外部IP
  • 节点2内部IP/节点2外部IP
  • 节点3内部IP/节点3外部IP

在创建我的 couchbase 客户端(java 代码)时,我提供了我的内部 IP,但是在建立连接后,我得到了这些日志:

2014-07-28 12:33:21.030 INFO net.spy.memcached.auth.AuthThread:  Authenticated to /node1InternalIP :11210
2014-07-28 12:33:21.142 INFO net.spy.memcached.auth.AuthThread:  Authenticated to /node2InternalIP :11210
2014-07-28 12:33:21.253 INFO net.spy.memcached.auth.AuthThread:  Authenticated to /node3InternalIP :11210
2014-07-28 12:33:21.374 INFO com.couchbase.client.vbucket.provider.BucketConfigurationProvider:  Carrier config not available, bootstrapped through HTTP.
2014-07-28 12:33:21.544 INFO com.couchbase.client.CouchbaseConnection:  Added {QA sa=cache2.lac.company.info/node1ExternalIP:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-07-28 12:33:21.545 INFO com.couchbase.client.CouchbaseConnection:  Added {QA sa=cache3.lac.company.info/node2ExternalIP:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-07-28 12:33:21.545 INFO com.couchbase.client.CouchbaseConnection:  Added {QA sa=cache4.lac.company.info/node3ExternalIP:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue

因此,似乎对内部 IP 进行了身份验证,但连接本身通过外部 IP 进行 - 这与我有关。

此外,有时我会收到 CheckedOperationTimeoutException:

net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting for operation - failing node: cache2.lac.company.info/node1ExternalIP:11210

异常显示客户端从外部 ip 连接超时。

如何确保我的连接将使用内部 IP?

4

1 回答 1

2

Couchbase 使用单个地址(IP 或主机名)来标识每个集群节点。然后在引导时将这些地址发送给客户端,以便它们可以连接到集群中的所有节点。您所看到的将是由于您最初使用外部 IP 地址作为名称设置集群节点,这是在连接时发送给客户端的内容。

要实现您想要做的事情,您需要使用主机名(管理员指南)而不是 IP 地址来识别每个节点,然后将客户端的 DNS 配置为使用外部IP 地址,但节点的 DNS(或/etc/hosts)使用内部IP。

于 2014-07-28T14:40:38.457 回答