zookeeper源码安装
2016/04/15 22:56 于 数据分析 0
介绍
zookeeper是一个管理分布式服务协调的开源服务,它本身亦是分布式服务。
是hadoop,Hbase,codis服务的重要组件,为分布式应用提供一致性服务:配置维护,域名服务,分布式同步,组服务等。
下载安装包
yum -y install openjdk
wget http://apache.fayea.com/zookeeper/zookeeper-3.5.1-alpha/zookeeper-3.5.1-alpha.tar.gz
tar zxf zookeeper-3.5.1-alpha.tar.gz
cd zookeeper-3.5.1-alpha
配置文件
这里先使用默认设置
cat ./conf/zoo.cfg
tickTime=2000 单位毫秒,用来做两次心跳最低超时时间间隔
initLimit=10 集群中的follower服务器(F)与leader服务器(L)之间初始连接时能容忍的最多心跳数(tickTime的数量)。
syncLimit=5 F节点和L节点最多心跳失败5次。
dataDir=/data/zookeeper 内存数据快照到本地的数据,除非特别说明,否则将是更新事物日志。
clientPort=2181 客户端端口
启动服务
zookeeper默认会占用2181,8080,55144三个端口
[root@salt-master zookeeper-3.5.1-alpha]# ./bin/zkServer.sh
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper-3.5.1-alpha/bin/../conf/zoo.cfg
Usage: ./bin/zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|restart|status|print-cmd}
[root@salt-master zookeeper-3.5.1-alpha]# ./bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper-3.5.1-alpha/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
连接测试
./bin/zkCli.sh -server 192.168.1.115:2181
Connecting to 192.168.1.115:2181
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: 192.168.1.115:2181(CONNECTED) 1] ls /
[zookeeper]
[zk: 192.168.1.115:2181(CONNECTED) 4] ls2 /zookeeper
'ls2' has been deprecated. Please use 'ls [-s] path' instead.
[config, quota]
cZxid = 0x0
ctime = Thu Jan 01 08:00:00 CST 1970
mZxid = 0x0
mtime = Thu Jan 01 08:00:00 CST 1970
pZxid = 0x0
cversion = -2
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 2
查看zookeeper服务信息
[root@salt-master codis]# echo stat | nc 192.168.1.115 2181
Zookeeper version: 3.5.1-alpha-1693007, built on 07/28/2015 07:19 GMT
Clients:
/192.168.1.115:56637[0](queued=0,recved=1,sent=0)
/192.168.1.115:56608[1](queued=0,recved=160,sent=160)
Latency min/avg/max: 0/0/22
Received: 162
Sent: 161
Connections: 2
Outstanding: 0
Zxid: 0x1
Mode: standalone
Node count: 5