Hadoop生态Zookeeper安装

一、安装条件前置

实验zookeeper安装在【Hadoop入门(二)集群安装】机器上,已完成安装jdk,hadoop和ssh配置环境等。

zookeeper所依赖的虚拟机和操作系统配置

环境:ubuntu14 + apache-zookeeper-3.5.6-bin.tar + jdk1.8+ssh

虚拟机:(vmware10)

 

二、zookeeper安装环境设置

(1)下载

下载网站

下载镜像

(2)上传到linux系统解压

1tar xvf apache-zookeeper-3.5.6-bin.tar.gz 2#放在统一的软件目录下 3mv apache-zookeeper-3.5.6-bin ~/software/ 4

(3) 新建数据目录

1cd ~/software/apache-zookeeper-3.5.6-bin 2#zk的数据目录 3mkdir -p zkData/data 4#zk的日子目录 5mkdir -p zkData/logs 6

(4)配置zoo.cfg

1cd ~/software/apache-zookeeper-3.5.6-bin/conf 2cp zoo_sample.cfg zoo.cfg 3vim zoo.cfg 4

编辑zoo.cfg

1# The number of milliseconds of each tick 2tickTime=2000 3# The number of ticks that the initial 4# synchronization phase can take 5initLimit=10 6# The number of ticks that can pass between 7# sending a request and getting an acknowledgement 8syncLimit=5 9# the directory where the snapshot is stored. 10# do not use /tmp for storage, /tmp here is just 11# example sakes. 12 13# 注释掉默认dataDir 14# dataDir=/tmp/zookeeper 15# 16 17# the port at which the clients will connect 18clientPort=2181 19# the maximum number of client connections. 20# increase this if you need to handle more clients 21#maxClientCnxns=60 22# 23# Be sure to read the maintenance section of the 24# administrator guide before turning on autopurge. 25# 26# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance 27# 28# The number of snapshots to retain in dataDir 29#autopurge.snapRetainCount=3 30# Purge task interval in hours 31# Set to "0" to disable auto purge feature 32#autopurge.purgeInterval=1 33 34#新增的配置,server.i的i是数据目录zkData/data下的myid 35dataDir=/home/mk/software/apache-zookeeper-3.5.6-bin/zkData/data 36dataLogDir=/home/mk/software/apache-zookeeper-3.5.6-bin/zkData/logs 37server.1=hadoop01:2888:3888 38server.2=hadoop02:2888:3888 39server.3=hadoop03:2888:3888 40 41

(5)复制到hadoop02、hadoop03

1scp -r /home/mk/software/apache-zookeeper-3.5.6-bin mk@hadoop02:/home/mk/software/ 2scp -r /home/mk/software/apache-zookeeper-3.5.6-bin mk@hadoop03:/home/mk/software/ 3

(6)配置myid

hadoop01

1echo '1' > ~/software/apache-zookeeper-3.5.6-bin/zkData/data/myid 2

hadoop02

1echo '2' > ~/software/apache-zookeeper-3.5.6-bin/zkData/data/myid 2

hadoop03

1echo '3' > ~/software/apache-zookeeper-3.5.6-bin/zkData/data/myid 2

 

三、启动Zookeeper

(1)启动

zookeeper没有集群启动需要每个机器各自启动

hadoop01、hadoop02、hadoop03都执行启动指令

1~/software/apache-zookeeper-3.5.6-bin/bin/zkServer.sh start 2 3

(2)检查启动状态

1~/software/apache-zookeeper-3.5.6-bin/bin/zkServer.sh status 2 3

hadoop01 

 

hadoop02

hadoop03

** (3)创建节点**

haddoop01登录zk

1~/software/apache-zookeeper-3.5.6-bin/bin/zkCli.sh 2ls / 3create /test 4ls / 5delete /test 6 7

hadoop02登录zk

1~/software/apache-zookeeper-3.5.6-bin/bin/zkCli.sh 2ls / 3 4

hadoop03登录zk

1~/software/apache-zookeeper-3.5.6-bin/bin/zkCli.sh 2ls / 3 4

(4)关闭

1~/software/apache-zookeeper-3.5.6-bin/binzkServer.sh stop 2 3

 

代码交流 2021