1. 下载Zookeeper
下载zookeeper3.4.6,上传,解压到/opt
2. Zookeeper配置安装
1.进入zookeeper/conf,cp zoo_sample.cfg zoo.cfg
,修改zoo.cfg
[root@BaseNode conf]# vim 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=/var/tdp/zookeeper
# 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
#设置服务器内部通讯地址和节点,给zookeeper使用的#ps:注意这里的名字要和主机名一致
server.1=BaseNode:2888:3888
server.2=zknode1:2888:3888
server.3=zknode2:2888:3888
server.4=zknode3:2888:3888
~
3. 在/var/bdp/zookeeper下创建myid文件
以此在每个虚拟机下存入和server.num相同的数字。
4.修改/etc/hosts文件
10.4.17.100 BaseNode
10.4.17.101 zknode1
10.4.17.102 zknode2
10.4.17.103 zkNode3
5. 修改zookeeper环境变量配置
vim /etc/profile
在文件末尾添加:
#Zookeeper
export ZOOKEEPER_HOME=/opt/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin
保存source /etc/profile.
6. 大功告成,试一下吧
zkServer.sh restart/start
再看一下运行状态,zkServer.sh status
停止机群,zkServer.sh stop
。