1、首先是到http://zookeeper.apache.org/releases.html官网下载安装包,这里下载的版本为3.4.12
2、解压到相应的目录
3、在zookeeper文件夹下新建zookeeper存放数据的目录
mkdid -p data/zkdata
创建好后整个文件路径如下:
4、重命名conf下的zoo-sample.cfg为zoo.cfg
5、修改zoo.cfg,主要配置数据存放路径和znode所在服务器
# 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.
###############1、配置zookeeper数据存放位置#############
dataDir=/home/luozheng/tools/zookeeper-3.4.12/data/zkdata
# the port at which the clients will connect
clientPort=2181
###############2、分布式集群添加节点####################
server.1=luozheng.bigdata:2888:3888
server.2=luozheng.bigdata1:2888:3888
server.3=luozheng.bigdata2:2888:3888
######################################################
# 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
6、在zookeeper文件夹下新建myid文件,里面写入1,对应zoo.cfg中server.1中的1
7、zookeeper同步到其他服务器
scp -r zookeeper-3.4.12/ luozheng@luozheng.bigdata1:~/tools/
scp -r zookeeper-3.4.12/ luozheng@luozheng.bigdata2:~/tools/
8、分别修改其他两个节点myid文件中的值
9、zookeeper服务启动,这个要每台服务器都要运行启动命令
bin/zkServer.sh start