下载zookeeper并上传到服务器
解压zookeeper并分别创建3个文件夹
解压文件复制到各个文件中,进入conf文件中,
复制文件并修改名称
mv zoo_sample.cfg zoo.cfg
编辑zoo.cfg
# Server 2
# The number of milliseconds of each tick
# 服务器与客户端之间交互的基本时间单元(ms)
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
# zookeeper所能接受的客户端数量
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.
# 保存zookeeper数据,日志路径
dataDir=/opt/zookeeper-cluster/zookerper-1/data
dataLogDir=/opt/zookeeper-cluster/zookerper-1/log
# the port at which the clients will connect
# 客户端与zookeeper相互交互的端口
clientPort=2181
server.1= 127.0.0.1:2888:3888
server.2= 127.0.0.1:2889:3889
server.3= 127.0.0.1:2890:3890
#server.A=B:C:D 其中A是一个数字,代表这是第几号服务器;B是服务器的IP地址;C表示服务器与群集中的“领导者”交换信息的端口;当领导者失效后,D表示用来执行选举时服务器相互通信的端口。
# 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
在
/opt/zookeeper-cluster/zookerper-1/下创建data和log文件
进入data文件夹
vi myid 并写入1
zookeeper-1就算完成了
继续完成zookeeper-2和zookeeper-3并修改相应的位置,与zookeeper-1相似
如果是一台机器上部署集群的话,clientPort端口一定不能一样,
启动zookeeper
./opt/zookeeper-cluster/zookerper-1/bin/zkServer.sh start
./opt/zookeeper-cluster/zookerper-2/bin/zkServer.sh start
./opt/zookeeper-cluster/zookerper-3/bin/zkServer.sh start
查看状态(全部启动完了后再查看状态)
./opt/zookeeper-cluster/zookerper-1/bin/zkServer.sh status
OK,启动完成