02-Zookeeper环境搭建(02 zookeeper environment construction)

1:下载Zookeeper

      下载地址:http://Zookeeper.apache.org/releases.html# download

2:解压Zookeeper

       [hadoop@hadoop01 app]$ tar -zxvf zookeeper-3.4.6.tar.gz

3:配置Zookeeper

      [hadoop@hadoop01 conf]$ vi zoo.cfg

          dataDir=/home/hadoop/data/zookeeper/zkdata                         –此处的目录要与第四步创建的目录一致

          dataLogDir=/home/hadoop/data/zookeeper/zkdatalog              –此处的目录要与第四步创建的目录一致

          clientPort=2181

        #server.每个节点服务编号=服务器ip地址:集群通信端口:选举端口

          server.1=hadoop01:2888:3888

          server.2=hadoop02:2888:3888

          server.3=hadoop03:2888:3888

4:集群其他节点安装Zookeeper

     将hadoop01节点的Zookeeper安装目录,整体分发到集群的hadoop02和hadoop03节点。

     [hadoop@hadoop01 app]$scp -r zookeeper-3.4.6 hadoop@hadoop02:/home/hadoop/app/

     [hadoop@hadoop01 app]$scp -r zookeeper-3.4.6 hadoop@hadoop03:/home/hadoop/app/

5:创建Zookeeper数据和日志目录

    #创建Zookeeper数据目录

      [hadoop@hadoop01 app]$mkdir -p /home/hadoop/data/zookeeper/zkdata

      [hadoop@hadoop02 app]$mkdir -p /home/hadoop/data/zookeeper/zkdata

      [hadoop@hadoop03 app]$mkdir -p /home/hadoop/data/zookeeper/zkdata

    #创建Zookeeper日志目录

     [hadoop@hadoop01 app] mkdir -p /home/hadoop/data/zookeeper/zkdatalog

     [hadoop@hadoop02 app] mkdir -p /home/hadoop/data/zookeeper/zkdatalog

     [hadoop@hadoop03 app] mkdir -p /home/hadoop/data/zookeeper/zkdatalog

6:为Zookeeper集群各个节点创建服务编号

     #hadoop01节点

      [hadoop@hadoop01 zkdata]$ touch myid

      [hadoop@hadoop01 zkdata]$ echo 1 myid

     #hadoop02节点

      [hadoop@hadoop02 zkdata]$ touch myid

      [hadoop@hadoop02 zkdata]$ echo 2 myid

     #hadoop03节点

     [hadoop@hadoop03 zkdata]$ touch myid

     [hadoop@hadoop03 zkdata]$ echo 3 myid

注意:每个节点服务编号的值是一个整形数字且不能重复

7:启动Zookeeper

      [hadoop@hadoop01 zookeeper]# bin/zkServer.sh start

      [hadoop@hadoop02 zookeeper]# bin/zkServer.sh start

      [hadoop@hadoop03 zookeeper]# bin/zkServer.sh start

8:查看Zookeeper状态

      [hadoop@hadoop01 zookeeper]# bin/zkServer.sh status

      [hadoop@hadoop02 zookeeper]# bin/zkServer.sh status

      [hadoop@hadoop03 zookeeper]# bin/zkServer.sh status

————————

1: Download zookeeper

      下载地址:http://Zookeeper.apache.org/releases.html# download

2: Unzip zookeeper

       [hadoop@hadoop01 app]$ tar -zxvf zookeeper-3.4.6.tar.gz

3: Configure zookeeper

      [hadoop@hadoop01 conf]$ vi zoo.cfg

DataDir = < strong > / home / Hadoop / data / zookeeper / zkdata — the directory here should be consistent with the directory created in step 4 < / strong >

Datalogdir = < strong > / home / Hadoop / data / zookeeper / zkdatalog < strong > — the directory here should be consistent with the directory created in step 4 < / strong > < / strong >

clientPort=2181

#server. Service number of each node = server IP address: cluster communication port: election port

server. 1=hadoop01:2888:3888

server. 2=hadoop02:2888:3888

server. 3=hadoop03:2888:3888

4: Install zookeeper on other nodes of the cluster

Distribute the zookeeper installation directory of Hadoop 01 node to Hadoop 02 and Hadoop 03 nodes of the cluster as a whole.

     [hadoop@hadoop01 app]$scp -r zookeeper-3.4.6 hadoop@hadoop02:/home/hadoop/app/

     [hadoop@hadoop01 app]$scp -r zookeeper-3.4.6 hadoop@hadoop03:/home/hadoop/app/

5: Create zookeeper data and log directories

# create zookeeper data directory

      [hadoop@hadoop01 app]$mkdir -p /home/hadoop/data/zookeeper/zkdata

      [hadoop@hadoop02 app]$mkdir -p /home/hadoop/data/zookeeper/zkdata

      [hadoop@hadoop03 app]$mkdir -p /home/hadoop/data/zookeeper/zkdata

# create zookeeper log directory

     [hadoop@hadoop01 app] mkdir -p /home/hadoop/data/zookeeper/zkdatalog

     [hadoop@hadoop02 app] mkdir -p /home/hadoop/data/zookeeper/zkdatalog

     [hadoop@hadoop03 app] mkdir -p /home/hadoop/data/zookeeper/zkdatalog

6: Create a service number for each node of the zookeeper cluster

#hadoop01 node

      [hadoop@hadoop01 zkdata]$ touch myid

      [hadoop@hadoop01 zkdata]$ echo 1 myid

#hadoop02 node

      [hadoop@hadoop02 zkdata]$ touch myid

      [hadoop@hadoop02 zkdata]$ echo 2 myid

#hadoop03 node

     [hadoop@hadoop03 zkdata]$ touch myid

     [hadoop@hadoop03 zkdata]$ echo 3 myid

< strong > note: the value of the service number of each node is an integer number and cannot be repeated < / strong >

7: Start zookeeper

      [hadoop@hadoop01 zookeeper]# bin/zkServer.sh start

      [hadoop@hadoop02 zookeeper]# bin/zkServer.sh start

      [hadoop@hadoop03 zookeeper]# bin/zkServer.sh start

8: View zookeeper status

      [hadoop@hadoop01 zookeeper]# bin/zkServer.sh status

      [hadoop@hadoop02 zookeeper]# bin/zkServer.sh status

      [hadoop@hadoop03 zookeeper]# bin/zkServer.sh status