apache zookeeper的安装、运行

进入http://zookeeper.apache.org/releases.html下载zookeeper的最新稳定版本,

当前稳定版本为zookeeper-3.4.6.tar.gz

 

解压到/usr/local/zookeeper

进入

[root@localhost conf]# pwd
/usr/local/zookeeper/zookeeper-3.4.6/conf

 修改zoo_sample.cfg为zoo.cfg

zoo.cfg文件内容为

[root@localhost conf]# cat zoo.cfg 
# 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.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

 启动命令为

[root@localhost zookeeper-3.4.6]# bin/zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

 查看一下zookeeper的进程

[root@localhost zookeeper-3.4.6]# ps -ef|grep zookeeper
root      3360     1  7 07:51 pts/1    00:00:00 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /usr/local/zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg
root      3381  2596  0 07:51 pts/1    00:00:00 grep zookeeper

 启动OK,

启动客户端连接服务

[root@localhost zookeeper-3.4.6]# bin/zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2014-05-12 07:51:32,888 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2014-05-12 07:51:32,896 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=localhost
2014-05-12 07:51:32,896 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.7.0_15
2014-05-12 07:51:32,904 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2014-05-12 07:51:32,904 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.7.0_15/jre
2014-05-12 07:51:32,904 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/../conf:
2014-05-12 07:51:32,904 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2014-05-12 07:51:32,905 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2014-05-12 07:51:32,907 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=
2014-05-12 07:51:32,907 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2014-05-12 07:51:32,907 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2014-05-12 07:51:32,907 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=2.6.32-279.el6.x86_64
2014-05-12 07:51:32,907 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2014-05-12 07:51:32,908 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2014-05-12 07:51:32,908 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/usr/local/zookeeper/zookeeper-3.4.6
2014-05-12 07:51:32,911 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@57830ec7
Welcome to ZooKeeper!
2014-05-12 07:51:32,968 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@975] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2014-05-12 07:51:32,996 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@852] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
[zk: 127.0.0.1:2181(CONNECTING) 0] 2014-05-12 07:51:33,172 [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 = 0x145f0ea62770000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

 连接成功

 

你可能感兴趣的:(linux,大数据,java,数据库)