Couchbase连接 – 外部IP而不是内部

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

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

  • node1InternalIP / node1ExternalIP
  • node2InternalIP / node2ExternalIP
  • node3InternalIP / node3ExternalIP

在创建我的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 

该exception显示客户端从外部ip连接获得超时。

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

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

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