1.下载tar包并上传到centos
define$ scp zookeeper-3.4.5.tar.gz root@10.211.55.4:/usr/local/
2.解压tar 包到创建的zookeeper 目录
[root@centos-linux-7 zookeeper]# tar -zxvf zookeeper-3.4.5.tar.gz
3.记得rm掉相关的tar包
[root@centos-linux-7 zookeeper]# rm -rf zookeeper-3.4.5.tar.gz
4.cd 到配置目录
[root@centos-linux-7 zookeeper-3.4.5]# cd conf/
5.创建data,log 目录 --之后需要用到,存放数据和日志
[root@centos-linux-7 zookeeper-3.4.5]# mkdir data/ log/
6.修改配置文件 sample 样例文件
[root@centos-linux-7 conf]# mv zoo_sample.cfg zoo.cfg
7.配置 zoo.cfg文件
[root@centos-linux-7 conf]# vim zoo.cfg
dataDir=/usr/local/zookeeper/zookeeper-3.4.5/data
dataLogDir=/usr/local/zookeeper/zookeeper-3.4.5/log
server.1=master:2287:3387
server.2=slave1:2288:3388
server.3=slave2:2289:3389
8.在每个服务器的对应 data/下创建对应server id 的文件
[root@centos-linux-7 zookeeper-3.4.5]# cd data/
[root@centos-linux-7 data]# echo 1 > myid
9.编辑PATH变量
[root@centos-linux-7 data]# vim /etc/profile
export ZK_HOME=/usr/local/zookeeper/
export PATH=$PATH:${ZK_HOME}/bin
10.编译生效
[root@centos-linux-7 zookeeper-3.4.5]# source /etc/profile
11.启动zookeeper
[root@centos-linux-7 zookeeper-3.4.5]# cd bin/
[root@centos-linux-7 bin]# chown root:root *.* -- 使用zkServer.sh当前目录无法使用, 查看得知是
用户不符,修改文件的属组,本人使用root配置虚拟机
[root@centos-linux-7 bin]# sh zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
12.检查生效
[root@centos-linux-7 bin]# ps -ef|grep zoo
或
[root@centos-linux-7 bin]# sh zkServer.sh status