Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"java.net.ConnectException: Connection refused" in zookeeper

I installed zookeeper as follows :

wget http://archive.cloudera.com/cdh/3/zookeeper-3.3.3-cdh3u1.tar.gz

Here is my zoo.cf:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/home/reach121/basf/data/zookeeper/data1
# maximum client connection
maxClientCnxns=500
# the port at which the clients will connect
clientPort=2183
server.1=localhost:2878:3878
server.2=localhost:2879:3879
server.3=localhost:2880:3880

and started by

/bin/zkServer.sh start zoo.cfg

and when I do?

bin/zkCli.sh -server 127.0.0.1:2183

it gives me this error:

Connecting to 127.0.0.1:2183
2011-10-13 14:11:28,433 - INFO  [main:Environment@97] - Client environment:zookeeper.version=3.3.3-cdh3u1--1, built on 07/18/2011 15:17 GMT
2011-10-13 14:11:28,437 - INFO  [main:Environment@97] - Client environment:host.name=cignexnew
2011-10-13 14:11:28,437 - INFO  [main:Environment@97] - Client environment:java.version=1.6.0_22
2011-10-13 14:11:28,438 - INFO  [main:Environment@97] - Client environment:java.vendor=Sun Microsystems Inc.
2011-10-13 14:11:28,438 - INFO  [main:Environment@97] - Client environment:java.home=/usr/lib/jvm/java-6-openjdk/jre
2011-10-13 14:11:28,439 - INFO  [main:Environment@97] - Client environment:java.class.path=/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../build/classes:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../build/lib/*.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../zookeeper-3.3.3-cdh3u1.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../lib/log4j-1.2.15.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../lib/jline-0.9.94.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../src/java/lib/*.jar:/home/reach121/basf/zookeeper-3.3.3-cdh3u1/bin/../conf:
2011-10-13 14:11:28,439 - INFO  [main:Environment@97] - Client environment:java.library.path=/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
2011-10-13 14:11:28,440 - INFO  [main:Environment@97] - Client environment:java.io.tmpdir=/tmp
2011-10-13 14:11:28,440 - INFO  [main:Environment@97] - Client environment:java.compiler=<NA>
2011-10-13 14:11:28,441 - INFO  [main:Environment@97] - Client environment:os.name=Linux
2011-10-13 14:11:28,441 - INFO  [main:Environment@97] - Client environment:os.arch=amd64
2011-10-13 14:11:28,441 - INFO  [main:Environment@97] - Client environment:os.version=2.6.35.4-rscloud
2011-10-13 14:11:28,442 - INFO  [main:Environment@97] - Client environment:user.name=reach121
2011-10-13 14:11:28,443 - INFO  [main:Environment@97] - Client environment:user.home=/home/reach121
2011-10-13 14:11:28,443 - INFO  [main:Environment@97] - Client environment:user.dir=/home/reach121/basf/zookeeper-3.3.3-cdh3u1
2011-10-13 14:11:28,446 - INFO  [main:ZooKeeper@373] - Initiating client connection, connectString=127.0.0.1:2183 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@5311a775
Welcome to ZooKeeper!
2011-10-13 14:11:28,472 - INFO  [main-SendThread():ClientCnxn$SendThread@1041] - Opening socket connection to server /127.0.0.1:2183
JLine support is enabled
2011-10-13 14:11:28,487 - WARN  [main-SendThread(localhost:2183):ClientCnxn$SendThread@1161] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:592)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
[zk: 127.0.0.1:2183(CONNECTING) 0] 2011-10-13 14:11:30,374 - INFO  [main-SendThread(localhost:2183):ClientCnxn$SendThread@1041] - Opening socket connection to server localhost/127.0.0.1:2183
2011-10-13 14:11:30,376 - WARN  [main-SendThread(localhost:2183):ClientCnxn$SendThread@1161] - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:592)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
like image 331
XMen Avatar asked Oct 13 '11 14:10

XMen


People also ask

What ports does zookeeper use?

Conventionally, ZooKeeper uses port 2181 to listen for client connections.


1 Answers

Are the servers coming up? Likely not given:

server.1=localhost:2878:3878
server.2=localhost:2879:3879
server.3=localhost:2880:3880

If you are running all three servers on the same host they will need to each have a different config - in particular the datadir location must be different, and you need to assure that each datadir has a myid file corresponding to the server line (ie server.# in config).

Typically when you want to run in distributed mode you need to have separate hosts. In this case why not just run in standalone (default) mode?

I'd suggest you read more in the admin guide first: http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html

like image 167
phunt Avatar answered Oct 22 '22 09:10

phunt