單機(jī)版
cd /usr/local
- 下載zookeeper的安裝包,放入local目錄
http://apache.fayea.com/zookeeper/stable/zookeeper-3.4.10.tar.gz
- 解壓zookeeper
tar -xvf zookeeper-3.4.10.tar.gz
rm -rf zookeeper-3.4.10.tar.gz
- 改個(gè)名字
mv zookeeper-3.4.10.tar.gz zookeeper
- 改配置文件
cd zookeeper/conf
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
啟動(dòng)
cd bin
sh zkServer.sh start/status/stop
集群
zookeeper集群, 包含三種角色: leader / follower /observer
observer 是一種特殊的zookeeper節(jié)點(diǎn)嗤堰。不參與投票宜咒。 只接收投票結(jié)果拒秘。
修改兩臺(tái)虛擬機(jī)
修改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/zoo1/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
server.1=192.168.116.150:2281:2381
server.2=192.168.116.177:2281:2381
分別增加配置文件
vim /usr/local/zoo1/zookeeper/data
1
2
查看狀態(tài)
Using config: /usr/local/zoo1/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@localhost bin]#
[root@localhost bin]# sh zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zoo1/zookeeper/bin/../conf/zoo.cfg
Mode: follower