1、zk移动到software目录下(根据自己的共享文件夹目录做相应的改变)
[hadoop@master ~]$ mv /mnt/hgfs/first/zookeeper-3.4.10.tar.gz /home/hadoop/software/
2、解压zk
[hadoop@master ~]$ cd /home/hadoop/software/
[hadoop@master software]$ tar xzvf zookeeper-3.4.10.tar.gz
3、添加一个zoo.cfg文件
[hadoop@master software]$ cd zookeeper-3.4.10/conf
[hadoop@master conf]$ cp zoo_sample.cfg zoo.cfg
4、修改配置文件(zoo.cfg)
[hadoop@master conf]$ vi zoo.cfg
(1)配置下列一行
dataDir=/home/hadoop/software/zookeeper-3.4.10/data
(2)底部添加下列三行
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
5、myid配置
[hadoop@master conf]$ mkdir /home/hadoop/software/zookeeper-3.4.10/data
[hadoop@master conf]$ cd /home/hadoop/software/zookeeper-3.4.10/data
[hadoop@master data]$ echo "1" > myid
6、将配置好的zk拷贝到其他结点
[hadoop@master ~]$ scp -r /home/hadoop/software/zookeeper-3.4.10 hadoop@slave1:/home/hadoop/software/
[hadoop@master ~]$ scp -r /home/hadoop/software/zookeeper-3.4.10 hadoop@slave2:/home/hadoop/software/
7、在其他结点上修改myid的内容,分别是2,3
[hadoop@slave1 ~]$ cd /home/hadoop/software/zookeeper-3.4.10/data
[hadoop@slave1 data]$ vi myid
2
[hadoop@slave1 ~]$ cd /home/hadoop/software/zookeeper-3.4.10/data
[hadoop@slave2 data]$ vi myid
3
8、修改环境变量
[hadoop@master ~]$vi .bashrc
添加下面两行
export ZOOKEEPER_HOME=/home/hadoop/software/zookeeper-3.4.10
export PATH=$ZOOKEEPER_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
每个都添加
环境变量修改完成后需要刷新
[hadoop@master ~]$. .bash_profile
9、开启zk
[hadoop@master ~]$ zkServer.sh start
[hadoop@master ~]$ jps
5585 ResourceManager
5414 SecondaryNameNode
5899 Jps
5868 QuorumPeerMain
5215 NameNode
[hadoop@slave1 ~]$ jps
3719 Jps
3416 DataNode
3688 QuorumPeerMain
3547 NodeManager