“java.net.ConnectException:连接被拒绝”在动物园管理员
我按如下方式安装了zookeeper:
wget http://archive.cloudera.com/cdh/3/zookeeper-3.3.3-cdh3u1.tar.gz
这是我的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
启动
/bin/zkServer.sh start zoo.cfg
并在我何时
bin/zkCli.sh -server 127.0.0.1:2183
?它给了我这个错误:
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
服务器来了吗?可能没有给出:
如果您在同一主机上运行所有三个服务器,它们将需要每个服务器都有不同的配置 - 特别是 datadir 位置必须不同,并且您需要确保每个 datadir 都有一个与服务器对应的 myid 文件行(即配置中的 server.#)。
通常,当您想在分布式模式下运行时,您需要拥有单独的主机。在这种情况下,为什么不直接以独立(默认)模式运行呢?
我建议您首先阅读管理指南中的更多内容:http://zookeeper。 apache.org/doc/r3.3.3/zookeeperAdmin.html
Are the servers coming up? Likely not given:
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
确保所有必需的服务都在运行
第 1 步:检查 hbase-master 是否正在运行
如果没有运行,则启动它
sudo /etc/init.d/hbase-master start
< strong>第2步:检查hbase-regionserver是否正在运行
如果没有,则启动它
sudo /etc/init.d/hbase-regionserver start
第3步:检查zookeeper是否运行-服务器是正在运行
如果没有,则启动它
sudo /etc/init.d/zookeeper-server start
或者简单地连续运行这3个命令。
之后不要忘记检查状态
您可能会发现 Zookeeper 仍未运行:
然后您可以运行zookeeper
,然后再次检查状态并确保其正在运行
这应该可以工作。
Make sure all required services are running
Step 1 : Check if hbase-master is running
if not, then start it
sudo /etc/init.d/hbase-master start
Step 2 : Check if hbase-regionserver is running
if not, then start it
sudo /etc/init.d/hbase-regionserver start
Step 3 : Check if zookeeper-server is running
if not, then start it
sudo /etc/init.d/zookeeper-server start
or simply run these 3 commands in a row.
after that don't forget to check the status
You might find that zookeeper is still not running:
then you can run the zookeeper
after that again check the status and make sure its running
This should work.
我在从客户端代码连接到开箱即用的 mapr m3 时遇到了同样的问题,
问题是客户端试图连接到本地主机的 M3 动物园管理员。
我的 M3 集群上的
/opt/mapr/conf/mapr-clusters.conf
指向 localhost ...我将其更改为 M3 机器的 IP 地址,并且客户端的连接正常
/opt/mapr/conf/cldb.conf
添加 IP 地址代替 localhost并重新启动 Zookeeper
I had the same issue connecting from a client code to mapr m3 out of the box
the issue is the the client was trying to connect to M3 zookeeper at localhost.
/opt/mapr/conf/mapr-clusters.conf
on my M3 cluster was pointing to localhost ...i changed it to the ip address of M3 machine and the connection from client worked
/opt/mapr/conf/cldb.conf
add ip address in place of localhostand restart zookeeper