1.前提条件
需要安装jdk,尽量关闭防火墙
2.开始安装
- wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
- tar -zxvf zookeeper-3.4.9.tar.gz
- ln -s zookeeper-3.4.9.tar.gz zk
- cd zk/conf
- cp zoo_sample.cfg zoo1.cfg、cp zoo_sample.cfg zoo2.cfg、cp zoo_sample.cfg zoo3.cfg
- 分别编辑zoo1.cfg、zoo2.cfg、zoo3.cfg
# The number of milliseconds of each tick
#zk时间单元(毫秒)
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
# floower启动过程中从leader同部数据的时间限制
#如果集群规模大,数据量多的话,适当调大此参数
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# 快照文件snapshot的存储目录
dataDir=/usr/local/src/zookeeper/data/zk1
# 事务日志目录
dataLogDir=/usr/local/src/zookeeper/log/zk1
# 客户端与服务端通信口号
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
#第一个是服务端通信的端口号,第二个是zk选举端口号
server.1=localhost:2187:2887
server.2=localhost:2188:2888
server.3=localhost:2189:2189
-创建相应的dataDir dataLogDir目录(在相应的dataDir目录下创建myid)
- echo "1" > /usr/local/src/zookeeper/data/zk1/myid
- echo "2" > /usr/local/src/zookeeper/data/zk2/myid
- echo "3" > /usr/local/src/zookeeper/data/zk3/myid
3.启动zookeeper
- 分别启动zookeeper 在bin目录中执行 ./zkServer.sh start ../conf/zoo1.cfg ./zkServer.sh start ../conf/zoo2.cfg ./zkServer.sh start ../conf/zoo3.cfg
4.检查是否启动成功
-
./zkServer.sh status ../conf/zoo1.cfg
image.png -
zkCli.sh -server localhost:2181, localhost:2182, localhost:2183
-------------------------------------至此安装完毕-------------------------------------
网友评论