Zookeeper连接超时
一、错误描述安装完zookeeper后,启动服务,然后进行测试,报“Error contacting service. It is probably not running.”,使用客户端命令zkCli.sh提示“java.net.ConnectException:拒绝连接..”异常,如下所示[root@localhost bin]# sh
·
一、错误描述
安装完zookeeper后,启动服务,然后进行测试,报“Error contacting service. It is probably not running.”,使用客户端命令zkCli.sh提示“java.net.ConnectException: 拒绝连接..”异常,如下所示
[root@localhost bin]# sh zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2016-09-24 16:33:21,601 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
...
java.net.ConnectException: 拒绝连接
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:701)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
JLine support is enabled
|
二、解决方法
1.查看/conf/zoo.cfg配置文件,如下所示
tickTime=30000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper
dataLogDir=/data/logs
clientPort=2181
|
2.如上配置内容所示,由于配置数据存在路径dataDir、日志存储路径dataLogDir,但是实际不存在该目录,造成zookeeper无发正常启动,创建这两个目录,再重启服务
[root@localhost bin]
# mkdir /data/zookeeper
[root@localhost bin]
# mkdir /data/logs
[root@localhost bin]
# sh zkServer.sh restart
Using config:
/usr/local/zookeeper-3
.4.6
/bin/
..
/conf/zoo
.cfg
JMX enabled by default
Using config:
/usr/local/zookeeper-3
.4.6
/bin/
..
/conf/zoo
.cfg
Stopping zookeeper ...
/usr/local/zookeeper-3
.4.6
/bin/zkServer
.sh: line 143:
kill
: (9075) - 没有那个进程
STOPPED
JMX enabled by default
Using config:
/usr/local/zookeeper-3
.4.6
/bin/
..
/conf/zoo
.cfg
Starting zookeeper ... STARTED
|
3.测试服务已正常
[root@localhost bin]
# telnet localhost 2181
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is
'^]'
.
Connection closed by foreign host.
|
[root@localhost bin]
# sh zkServer.sh status
JMX enabled by default
Using config:
/usr/local/zookeeper-3
.4.6
/bin/
..
/conf/zoo
.cfg
Mode: standalone
|
[root@localhost bin]
# sh zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2016-09-24 17:02:38,607 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02
/20/2014
09:09 GMT
...
Welcome to ZooKeeper!
JLine support is enabled
2016-09-24 17:02:38,843 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server 127.0.0.1
/127
.0.0.1:2181, sessionid = 0x1575b644d900000, negotiated timeout = 60000
WATCHER::
WatchedEvent state:SyncConnected
type
:None path:null
[zk: 127.0.0.1:2181(CONNECTED) 0]
ls
/
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 1] create
/test
hello
Created
/test
[zk: 127.0.0.1:2181(CONNECTED) 4]
set
/test
hello
cZxid = 0x2
ctime = Sat Sep 24 17:03:15 CST 2016
mZxid = 0x3
mtime = Sat Sep 24 17:04:16 CST 2016
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 5
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 5] get
/test
hello
cZxid = 0x2
ctime = Sat Sep 24 17:03:15 CST 2016
mZxid = 0x3
mtime = Sat Sep 24 17:04:16 CST 2016
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 5
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 6]
更多推荐
已为社区贡献1条内容
所有评论(0)