官网下载地址
略
三、配置Zookeeper 1.复制模版文件zoo_sample.cfg为zoo.cfgcp /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg2.修改配置文件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/zookeeper/data dataLogDir=/usr/local/zookeeper/datalog # 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=master:2888:3888 server.2=slave1:2888:3888 server.3=slave2:2888:3888四、创建所需目录和新建的myid文件
创建/usr/local/zookeeper/data与/usr/local/zookeeper/datalog目录
sudo mkdir /usr/local/zookeeper/data sudo mkdir /usr/local/zookeeper/datalog sudo vim /usr/local/zookeeper/data/myid
将myid内容设置为1
设置为1是由于配置文件zoo.cfg中“server.id=host:port:port”,配置项master机器对应的“id”为"1"
su root scp -r /usr/local/zookeeper root@slave1:/usr/local/zookeeper scp -r /usr/local/zookeeper root@slave2:/usr/local/zookeeper六、设置$ZOOKEEPER_HOME的目录属主
为了在普通用户下使用Zookeeper集群,依次将master、slave1、slave2三台机器上的zookeeper目录设置为linux普通用户
chown -R 用户名 /usr/local/zookeeper七、修改slave1、slave2的myid内容
在slave1、slave2中执行
sudo vim /usr/local/zookeeper/data/myid
export ZOOKEEPER_HOME=/usr/local/zookeeper export PATH=$ZOOKEEPER_HOME/bin:$PATH
source ~/.bashrc
配置好后执行zkServer.sh start
zkServer.sh start九、验证zookeeper集群
zkServer.sh status jps
leader角色随缘分配 这次slave1为leader, master与slave2为follower
master、slave1、slave2 三机器jps出现上图QuorumPeerMain 说明zookeeper集群配置成功



