ZooKeeper 安装部署
一、解压
tar -zxvf zookeeper-3.3.5.tar.gz
二、将zookeeper-3.3.4/conf目录下面的 zoo_sample.cfg修改为zoo.cfg,配置文件内容如下所示:
tickTime= #该参数用来定义心跳的间隔时间,zookeeper的客户端和服务端之间也有和web开发里类似的session的概念,而zookeeper里最小的session过期时间就是tickTime的两倍。
dataDir=/home/hadoop/storage/zookeeper #为存储在内存中的数据库快照功能
clientPort= #是监听客户端连接的端口号。
initLimit= #是指follower连接并同步到leader的初始化连接,它是通过tickTime的倍数表示,例如我们上面的配置就是10倍的tickTime,当初始化连接时间超过设置的倍数时候则连接失败。
syncLimit= #是指follower和leader之间发送消息时请求和应答的时间长度,如果follower在设置的时间范围内不能和leader通信,那么该follower将会被丢弃,它也是按tickTime的倍数进行设置的。
三、下面启动ZooKeeper服务器进程:
cd zookeeper-3.3./
bin/zkServer.sh start
四、在客户端连接ZooKeeper服务器,执行如下命令:
bin/zkCli.sh -server dynamic:
上面dynamic是我的主机名,如果在本机执行,则执行如下命令即可:
bin/zkCli.sh
五、客户端连接信息如下所示:
hadoop@master:~/installation/zookeeper-3.3.$ bin/zkCli.sh -server dynamic:
Connecting to dynamic:
-- ::, - INFO [main:Environment@] - Client environment:zookeeper.version=3.3.-, built on // : GMT
-- ::, - INFO [main:Environment@] - Client environment:host.name=master
-- ::, - INFO [main:Environment@] - Client environment:java.version=1.6.0_30
-- ::, - INFO [main:Environment@] - Client environment:java.vendor=Sun Microsystems Inc.
-- ::, - INFO [main:Environment@] - Client environment:java.home=/home/hadoop/installation/jdk1..0_30/jre
-- ::, - INFO [main:Environment@] - Client environment:java.class.path=/home/hadoop/installation/zookeeper-3.3./bin/../build/classes:/home/hadoop/installation/zookeeper-3.3./bin/../build/lib/*.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../zookeeper-3.3.4.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/log4j-1.2.15.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/jline-0.9.94.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-lang-2.4.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-collections-3.2.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-cli-1.1.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/apache-rat-tasks-0.6.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/apache-rat-core-0.6.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../src/java/lib/*.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../conf:/home/hadoop/installation/jdk1.6.0_30/lib/*.jar:/home/hadoop/installation/jdk1.6.0_30/jre/lib/*.jar
2012-01-08 21:30:06,206 - INFO [main:Environment@97] - Client environment:java.library.path=/home/hadoop/installation/jdk1.6.0_30/jre/lib/i386/client:/home/hadoop/installation/jdk1.6.0_30/jre/lib/i386:/home/hadoop/installation/jdk1.6.0_30/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
2012-01-08 21:30:06,213 - INFO [main:Environment@97] - Client environment:java.io.tmpdir=/tmp
2012-01-08 21:30:06,216 - INFO [main:Environment@97] - Client environment:java.compiler=<NA>
2012-01-08 21:30:06,235 - INFO [main:Environment@97] - Client environment:os.name=Linux
2012-01-08 21:30:06,244 - INFO [main:Environment@97] - Client environment:os.arch=i386
2012-01-08 21:30:06,246 - INFO [main:Environment@97] - Client environment:os.version=3.0.0-14-generic
2012-01-08 21:30:06,251 - INFO [main:Environment@97] - Client environment:user.name=hadoop
2012-01-08 21:30:06,254 - INFO [main:Environment@97] - Client environment:user.home=/home/hadoop
2012-01-08 21:30:06,255 - INFO [main:Environment@97] - Client environment:user.dir=/home/hadoop/installation/zookeeper-3.3.4
2012-01-08 21:30:06,264 - INFO [main:ZooKeeper@379] - Initiating client connection, connectString=dynamic:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@bf32c
2012-01-08 21:30:06,339 - INFO [main-SendThread():ClientCnxn$SendThread@1061] - Opening socket connection to server dynamic/192.168.0.107:2181
Welcome to ZooKeeper!
2012-01-08 21:30:06,397 - INFO [main-SendThread(dynamic:2181):ClientCnxn$SendThread@950] - Socket connection established to dynamic/192.168.0.107:2181, initiating session
JLine support is enabled
2012-01-08 21:30:06,492 - INFO [main-SendThread(dynamic:2181):ClientCnxn$SendThread@739] - Session establishment complete on server dynamic/192.168.0.107:2181, sessionid = 0x134b9b714f9000c, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null
[zk: dynamic:2181(CONNECTED) 0]
六、集群配置
1、hosts文件如下:
192.168.0.179 slave-
192.168.0.178 slave-
192.168.0.177 slave-
2、在其中一台机器(slave-01)上,解压缩zookeeper-3.3.4.tar.gz,修改配置文件conf/zoo.cfg,内容如下所示:
tickTime=
dataDir=/home/hadoop/storage/zookeeper
clientPort=
initLimit=
syncLimit=
server.=slave-::
server.=slave-::
server.=slave-::
是用于进行leader选举的端口,是zookeeper集群里各个机器之间的通信接口。
3、远程复制分发安装文件
上面已经在一台机器slave-01上配置完成ZooKeeper,现在可以将该配置好的安装文件远程拷贝到集群中的各个结点对应的conf/目录下。
4、设置myid
hadoop@slave-:~/installation/zookeeper-3.3.$ echo "" > /home/hadoop/storage/zookeeper/myid
hadoop@slave-:~/installation/zookeeper-3.3.$ echo "" > /home/hadoop/storage/zookeeper/myid
hadoop@slave-:~/installation/zookeeper-3.3.$ echo "" > /home/hadoop/storage/zookeeper/myid
5、启动ZooKeeper集群
在ZooKeeper集群的每个结点上,执行启动ZooKeeper服务的脚本,如下所示:
hadoop@slave-:~/installation/zookeeper-3.3.$ bin/zkServer.sh start
hadoop@slave-:~/installation/zookeeper-3.3.$ bin/zkServer.sh start
hadoop@slave-:~/installation/zookeeper-3.3.$ bin/zkServer.sh start
以结点slave-01为例,日志如下所示:
hadoop@slave-:~/installation/zookeeper-3.3.$ tail -500f zookeeper.out
-- ::, - INFO [main:QuorumPeerConfig@] - Reading configuration from: /home/hadoop/installation/zookeeper-3.3./bin/../conf/zoo.cfg
-- ::, - INFO [main:QuorumPeerConfig@] - Defaulting to majority quorums
-- ::, - INFO [main:QuorumPeerMain@] - Starting quorum peer
-- ::, - INFO [main:NIOServerCnxn$Factory@] - binding to port 0.0.0.0/0.0.0.0:
-- ::, - INFO [main:QuorumPeer@] - tickTime set to
-- ::, - INFO [main:QuorumPeer@] - minSessionTimeout set to -
-- ::, - INFO [main:QuorumPeer@] - maxSessionTimeout set to -
-- ::, - INFO [main:QuorumPeer@] - initLimit set to
-- ::, - INFO [Thread-:QuorumCnxManager$Listener@] - My election bind port:
-- ::, - INFO [QuorumPeer:/:::::::::QuorumPeer@] - LOOKING
-- ::, - INFO [QuorumPeer:/:::::::::FastLeaderElection@] - New election. My id = , Proposed zxid =
-- ::, - INFO [WorkerReceiver Thread:FastLeaderElection@] - Notification: (n.leader), (n.zxid), (n.round), LOOKING (n.state), (n.sid), LOOKING (my state)
-- ::, - WARN [WorkerSender Thread:QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.178:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:)
at java.lang.Thread.run(Thread.java:)
-- ::, - WARN [WorkerSender Thread:QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.177:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:)
at java.lang.Thread.run(Thread.java:)
-- ::, - WARN [QuorumPeer:/:::::::::QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.178:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:)
-- ::, - WARN [QuorumPeer:/:::::::::QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.177:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:)
-- ::, - INFO [QuorumPeer:/:::::::::FastLeaderElection@] - Notification time out:
-- ::, - WARN [QuorumPeer:/:::::::::QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.178:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:)
-- ::, - WARN [QuorumPeer:/:::::::::QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.177:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:)
-- ::, - INFO [QuorumPeer:/:::::::::FastLeaderElection@] - Notification time out:
-- ::, - WARN [QuorumPeer:/:::::::::QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.178:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:)
-- ::, - WARN [QuorumPeer:/:::::::::QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.177:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:)
-- ::, - INFO [QuorumPeer:/:::::::::FastLeaderElection@] - Notification time out:
-- ::, - WARN [QuorumPeer:/:::::::::QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.178:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:)
-- ::, - WARN [QuorumPeer:/:::::::::QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.177:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:)
-- ::, - INFO [QuorumPeer:/:::::::::FastLeaderElection@] - Notification time out:
-- ::, - INFO [WorkerReceiver Thread:FastLeaderElection@] - Notification: (n.leader), (n.zxid), (n.round), LOOKING (n.state), (n.sid), LOOKING (my state)
-- ::, - INFO [QuorumPeer:/:::::::::FastLeaderElection@] - Updating proposal
-- ::, - WARN [WorkerSender Thread:QuorumCnxManager@] - Cannot open channel to at election address slave-/192.168.0.177:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:)
at java.lang.Thread.run(Thread.java:)
-- ::, - INFO [WorkerReceiver Thread:FastLeaderElection@] - Notification: (n.leader), (n.zxid), (n.round), LOOKING (n.state), (n.sid), LOOKING (my state)
-- ::, - INFO [QuorumPeer:/:::::::::QuorumPeer@] - FOLLOWING
-- ::, - INFO [QuorumPeer:/:::::::::Learner@] - TCP NoDelay set to: true
-- ::, - INFO [QuorumPeer:/:::::::::Environment@] - Server environment:zookeeper.version=3.3.-, built on // : GMT
-- ::, - INFO [QuorumPeer:/:::::::::Environment@] - Server environment:host.name=slave-
-- ::, - INFO [QuorumPeer:/:::::::::Environment@] - Server environment:java.version=1.6.0_30
-- ::, - INFO [QuorumPeer:/:::::::::Environment@] - Server environment:java.vendor=Sun Microsystems Inc.
-- ::, - INFO [QuorumPeer:/:::::::::Environment@] - Server environment:java.home=/home/hadoop/installation/jdk1..0_30/jre
-- ::, - INFO [QuorumPeer:/:::::::::Environment@] - Server environment:java.class.path=/home/hadoop/installation/zookeeper-3.3./bin/../build/classes:/home/hadoop/installation/zookeeper-3.3./bin/../build/lib/*.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../zookeeper-3.3.4.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/log4j-1.2.15.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/jline-0.9.94.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-lang-2.4.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-collections-3.2.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-cli-1.1.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/apache-rat-tasks-0.6.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/apache-rat-core-0.6.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../src/java/lib/*.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../conf:/home/hadoop/installation/jdk1.6.0_30/lib/*.jar:/home/hadoop/installation/jdk1.6.0_30/jre/lib/*.jar
2012-01-08 06:51:23,210 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:java.library.path=/home/hadoop/installation/jdk1.6.0_30/jre/lib/i386/client:/home/hadoop/installation/jdk1.6.0_30/jre/lib/i386:/home/hadoop/installation/jdk1.6.0_30/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
2012-01-08 06:51:23,210 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:java.io.tmpdir=/tmp
2012-01-08 06:51:23,212 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:java.compiler=<NA>
2012-01-08 06:51:23,212 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:os.name=Linux
2012-01-08 06:51:23,212 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:os.arch=i386
2012-01-08 06:51:23,213 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:os.version=3.0.0-14-generic
2012-01-08 06:51:23,213 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:user.name=hadoop
2012-01-08 06:51:23,214 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:user.home=/home/hadoop
2012-01-08 06:51:23,214 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Environment@97] - Server environment:user.dir=/home/hadoop/installation/zookeeper-3.3.4
2012-01-08 06:51:23,223 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:ZooKeeperServer@151] - Created server with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000 datadir /home/hadoop/storage/zookeeper/version-2 snapdir /home/hadoop/storage/zookeeper/version-2
2012-01-08 06:51:23,339 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Learner@294] - Getting a snapshot from leader
2012-01-08 06:51:23,358 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:Learner@325] - Setting leader epoch 1
2012-01-08 06:51:23,358 - INFO [QuorumPeer:/0:0:0:0:0:0:0:0:2181:FileTxnSnapLog@254] - Snapshotting: 0
2012-01-08 06:51:25,511 - INFO [WorkerReceiver Thread:FastLeaderElection@496] - Notification: 3 (n.leader), 0 (n.zxid), 1 (n.round), LOOKING (n.state), 3 (n.sid), FOLLOWING (my state)
2012-01-08 06:51:42,584 - INFO [WorkerReceiver Thread:FastLeaderElection@496] - Notification: 3 (n.leader), 0 (n.zxid), 2 (n.round), LOOKING (n.state), 3 (n.sid), FOLLOWING (my state)
6、安装验证
可以通过ZooKeeper的脚本来查看启动状态,包括集群中各个结点的角色(或是Leader,或是Follower),如下所示,是在ZooKeeper集群中的每个结点上查询的结果:
hadoop@slave-:~/installation/zookeeper-3.3.$ bin/zkServer.sh status
JMX enabled by default
Using config: /home/hadoop/installation/zookeeper-3.3./bin/../conf/zoo.cfg
Mode: follower hadoop@slave-:~/installation/zookeeper-3.3.$ bin/zkServer.sh status
JMX enabled by default
Using config: /home/hadoop/installation/zookeeper-3.3./bin/../conf/zoo.cfg
Mode: leader hadoop@slave-:~/installation/zookeeper-3.3.$ bin/zkServer.sh status
JMX enabled by default
Using config: /home/hadoop/installation/zookeeper-3.3./bin/../conf/zoo.cfg
Mode: follower
7、另外,可以通过客户端脚本,连接到ZooKeeper集群上。对于客户端来说,ZooKeeper是一个整体(ensemble),连接到ZooKeeper集群实际上感觉在独享整个集群的服务,所以,你可以在任何一个结点上建立到服务集群的连接,例如:
hadoop@slave-:~/installation/zookeeper-3.3.$ bin/zkCli.sh -server slave-:
Connecting to slave-:
-- ::, - INFO [main:Environment@] - Client environment:zookeeper.version=3.3.-, built on // : GMT
-- ::, - INFO [main:Environment@] - Client environment:host.name=slave-
-- ::, - INFO [main:Environment@] - Client environment:java.version=1.6.0_30
-- ::, - INFO [main:Environment@] - Client environment:java.vendor=Sun Microsystems Inc.
-- ::, - INFO [main:Environment@] - Client environment:java.home=/home/hadoop/installation/jdk1..0_30/jre
-- ::, - INFO [main:Environment@] - Client environment:java.class.path=/home/hadoop/installation/zookeeper-3.3./bin/../build/classes:/home/hadoop/installation/zookeeper-3.3./bin/../build/lib/*.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../zookeeper-3.3.4.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/log4j-1.2.15.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/jline-0.9.94.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-lang-2.4.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-collections-3.2.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/commons-cli-1.1.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/apache-rat-tasks-0.6.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../lib/apache-rat-core-0.6.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../src/java/lib/*.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/../conf:/home/hadoop/installation/jdk1.6.0_30/lib/*.jar:/home/hadoop/installation/jdk1.6.0_30/jre/lib/*.jar
2012-01-08 07:14:21,111 - INFO [main:Environment@97] - Client environment:java.library.path=/home/hadoop/installation/jdk1.6.0_30/jre/lib/i386/client:/home/hadoop/installation/jdk1.6.0_30/jre/lib/i386:/home/hadoop/installation/jdk1.6.0_30/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
2012-01-08 07:14:21,116 - INFO [main:Environment@97] - Client environment:java.io.tmpdir=/tmp
2012-01-08 07:14:21,124 - INFO [main:Environment@97] - Client environment:java.compiler=<NA>
2012-01-08 07:14:21,169 - INFO [main:Environment@97] - Client environment:os.name=Linux
2012-01-08 07:14:21,175 - INFO [main:Environment@97] - Client environment:os.arch=i386
2012-01-08 07:14:21,177 - INFO [main:Environment@97] - Client environment:os.version=3.0.0-14-generic
2012-01-08 07:14:21,185 - INFO [main:Environment@97] - Client environment:user.name=hadoop
2012-01-08 07:14:21,188 - INFO [main:Environment@97] - Client environment:user.home=/home/hadoop
2012-01-08 07:14:21,190 - INFO [main:Environment@97] - Client environment:user.dir=/home/hadoop/installation/zookeeper-3.3.4
2012-01-08 07:14:21,197 - INFO [main:ZooKeeper@379] - Initiating client connection, connectString=slave-01:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@bf32c
2012-01-08 07:14:21,305 - INFO [main-SendThread():ClientCnxn$SendThread@1061] - Opening socket connection to server slave-01/192.168.0.179:2181
Welcome to ZooKeeper!
2012-01-08 07:14:21,376 - INFO [main-SendThread(slave-01:2181):ClientCnxn$SendThread@950] - Socket connection established to slave-01/192.168.0.179:2181, initiating session
JLine support is enabled
[zk: slave-01:2181(CONNECTING) 0] 2012-01-08 07:14:21,872 - INFO [main-SendThread(slave-01:2181):ClientCnxn$SendThread@739] - Session establishment complete on server slave-01/192.168.0.179:2181, sessionid = 0x134bdcd6b730000, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: slave-01:2181(CONNECTED) 0] ls /
[zookeeper]
ZooKeeper 安装部署的更多相关文章
- ZooKeeper 安装部署及hello world(转)
ZooKeeper 安装部署及hello world 先给一堆学习文档,方便以后查看官网文档地址大全:OverView(概述)http://zookeeper.apache.org/doc/r3.4 ...
- ZooKeeper 安装部署及hello world
ZooKeeper 安装部署及hello world 先给一堆学习文档,方便以后查看官网文档地址大全: OverView(概述)http://zookeeper.apache.org/doc/r3. ...
- Zookeeper安装部署
Zookeeper安装 1. 安装 wget http://www.apache.org/dist//zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz ...
- ZooKeeper安装,部署
实验环境 192.168.1.10 Zookeeper1:2181, Zookeeper2:2182 192.168.1.11 ZooKeeper3:2181 依赖环境 JDK1.7 安装,配置 1. ...
- windows下dubbo-admin和zookeeper安装部署
1. 概述 ZooKeeper是Hadoop的正式子项目,它是一个针对大型分布式系统的可靠协调系统,提供的功能包括:配置维护.名字服务.分布式同步.组服务等.ZooKeeper的目标就是封装好复杂 ...
- kafka和zookeeper安装部署(版本弄不好就是坑)
yum install -y unzip zip 配置host vi /etc/host172.19.68.10 zk1 1. zookeeper zookeeper下载地址 http://mirro ...
- zookeeper安装部署步骤
安装步骤 本安装教程,采用zookeeper 3.6.1 装java 下载zk包,分发到各个机器 确定或创建一个zookeeper的数据存放路径,并在该路径下创建一个myid文件,其中设置当前zook ...
- 161209、简要分析ZooKeeper基本原理及安装部署
一.ZooKeeper 基本概念 1.ZooKeeper 是什么? Zookeeper官网地址: http://zookeeper.apache.org/ Zookeeper官网文档地址:http:/ ...
- zookeeper与kafka安装部署及java环境搭建(发布订阅模式)
1. ZooKeeper安装部署 本文在一台机器上模拟3个zk server的集群安装. 1.1. 创建目录.解压 cd /usr/ #创建项目目录 mkdir zookeeper cd zookee ...
随机推荐
- 【团队项目演示】FZU5BOYS之团队项目链接汇总
FZU5BOYS 项目冲刺之博客汇总 Alpha版本 Day One Day Two Day Three Day Four Day Five Day Six Day Seven Day Ei ...
- 第九章:Java----泛型学习(最后过一遍)
泛型:让集合记住里面元素的类型,避免取出时需要强制类型转换(大到小). ClassCastException! 编译阶段就能发现错误. 语法更严格! 更不容易犯错! 1. 构造器的名字还是类名, ...
- hibernate事务
hibernate事务 9.3 Hibernate的事务管理 事务(Transaction)是工作中的基本逻辑单位,可以用于确保数据库能够被正确修改,避免数据只修改了一部分而导致数据不完整,或者在修改 ...
- Java设计模式-状态模式(State)
核心思想就是:当对象的状态改变时,同时改变其行为,很好理解!就拿QQ来说,有几种状态,在线.隐身.忙碌等,每个状态对应不同的操作,而且你的好友也能看到你的状态,所以,状态模式就两点:1.可以通过改变状 ...
- Java基础-关键字-String
1.String的本质 线程安全 打开String的源码,类注释中有这么一段话“Strings are constant; their values cannot be changed after t ...
- 牛客网上的剑指offer题目
题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数. 题目:请实现一个函数,将一 ...
- golang thrift 源码分析,服务器和客户端究竟是如何工作的
首先编写thrift文件(rpcserver.thrift),运行thrift --gen go rpcserver.thrift,生成代码 namespace go rpc service RpcS ...
- 【poj3348】 Cows
http://poj.org/problem?id=3348 (题目链接) 题意 给出平面上n个点,以这n个点中的一些围成的多边形面积 div 50的最大值. Solution 凸包求面积. 很好做, ...
- [NOIP2009] 提高组 洛谷P1073 最优贸易
题目描述 C 国有 n 个大城市和 m 条道路,每条道路连接这 n 个城市中的某两个城市.任意两个 城市之间最多只有一条道路直接相连.这 m 条道路中有一部分为单向通行的道路,一部分 为双向通行的道路 ...
- TYVJ1939 玉蟾宫
背景 有一天,小猫rainbow和freda来到了湘西张家界的天门山玉蟾宫,玉蟾宫宫主蓝兔盛情地款待了它们,并赐予它们一片土地. 描述 这片土地被分成N*M个格子,每个格子里写着'R'或者'F',R代 ...