LoginSignup
1
1

More than 5 years have passed since last update.

Couchbase Java SDK を 2.1.1 に上げたら接続エラーが発生する場合の対処法

Posted at

Couchbase Java SDKを 2.1.1 に上げると、以下のようなメッセージが繰り返し出力されてサーバへ接続できなくなる事象が発生しました。
以下は11210ポートへの接続エラーですが、8092ポートへの接続エラーも同様に出力され、最終的にタイムアウトが発生します。

2015-03-07 03:40:32.244  WARN 53654 --- [      cb-io-1-3] c.c.client.core.endpoint.Endpoint        : [null][KeyValueEndpoint]: Could not connect to endpoint, retrying with delay 32 MILLISECONDS: 

java.net.ConnectException: Connection refused: localhost/127.0.0.1:11210
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716)
    at com.couchbase.client.deps.io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:208)
    at com.couchbase.client.deps.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:281)
    at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
    at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at com.couchbase.client.deps.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
    at com.couchbase.client.deps.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
    at java.lang.Thread.run(Thread.java:745)

どうやら、サーバの初期設定 の「Hostname」にループバックアドレスが設定されていると発生するようです。

configure_server1.png

サーバの初期設定からやり直すのはシンドイので、そういう場合は REST API を使ってホスト名を設定します。

以下は実際にVagrant上で立ち上げていたCouchbaseの「Hostname」をループバックアドレスからIPアドレスに変えた際の様子です。

[vagrant@localhost ~]$ curl -v -XPOST -u Administrator:password http://localhost:8091/node/controller/rename -d hostname=192.168.28.100
* About to connect() to localhost port 8091 (#0)
*   Trying ::1... 接続を拒否されました
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8091 (#0)
* Server auth using Basic with user 'Administrator'
> POST /node/controller/rename HTTP/1.1
> Authorization: Basic QWRtaW5pc3RyYXRvcjpob2dlbW9nZQ==
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: localhost:8091
> Accept: */*
> Content-Length: 23
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 200 OK
< Server: Couchbase Server
< Pragma: no-cache
< Date: Mon, 09 Mar 2015 02:21:51 GMT
< Content-Length: 0
< Cache-Control: no-cache
< 
* Connection #0 to host localhost left intact
* Closing connection #0

Hostname設定は couchbase-cli node-init を使って自動化したいですね。

$ /opt/couchbase/bin/couchbase-cli node-init -c localhost:8091 \
    --node-init-hostname=192.168.28.100 \
    -u xxxx -p yyyy

インストール直後で administrator account を設定していない場合でも -u-p は必要みたいなんですが、デタラメなやつを指定してもイケました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1