一、下载zookeeper二进制安装包
二、解压zookeeper安装包
把zookeeper-3.4.14.tar.gz文件存放在/home/local目录下。解压
sudo tar -zxvf zookeeper-3.4.3.tar.gz
chown -R hadoop:hadoop zookeeper-3.4.3
或者使用在线安装方式
cd /home/local
wget http://www.apache.org/dist/zookeeper/zookeeper-3.3.3/zookeeper-3.3.3.tar.gz
tar zxvf zookeeper-3.3.3.tar.gz
三、设置环境变量
在/etc/profile,/home/local/.bashrc文件中添加如下红色信息
在/etc/profile,/home/hadoop/.bashrc文件中修改如下信息
#set java environment
ZOOKEEPER_HOME=/root/soft/zookeeper-3.4.14
MAHOUT_HOME=/home/hadoop/mahout-distribution-0.7
PIG_HOME=/home/hadoop/pig-0.9.2
HBASE_HOME=/home/hadoop/hbase-0.94.3
HIVE_HOME=/home/hadoop/hive-0.9.0
HADOOP_HOME=/home/hadoop/hadoop-1.1.1
JAVA_HOME=/home/hadoop/jdk1.7.0
PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PIG_HOME/bin:$MAHOUT_HOME/bin:$HBASE_HOME/bin:$HIVE_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/conf:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$ZOOKEEPER_HOME/lib:$HBASE_HOME/lib:$MAHOUT_HOME/lib:$PIG_HOME/lib:$HIVE_HOME/lib:$JAVA_HOME/lib/tools.jar
export ZOOKEEPER_HOME
export MAHOUT_HOME
export PIG_HOME
export HBASE_HOME
export HADOOP_HOME
export JAVA_HOME
export HIVE_HOME
export PATH
export CLASSPATH
四、配置
配置文件存放在$zookeeper_home/conf/目录下,将zoo_sample.cfd文件名称改为zoo.cfg,缺省的内容如下
# 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.
dataDir=/home/hadoop/zookeeper-3.4.3/data #这是我修改后的
# the port at which the clients will connect
clientPort=2181
#
# 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
配置说明
tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳
dataDir:顾名思义就是 Zookeeper 保存数据的目录
clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求
五、启动zookeeper
netstat -at|grep 2181 #查看zookeeper端口
netstat -nat #查看端口信息
cd zookeeper-3.4.3/bin
./zkServer.sh start #启动
jps #查看启动的服务名称
./zkServer.sh stop #关闭
启动后要检查 Zookeeper 是否已经在服务,可以通过 netstat -at|grep 2181
命令查看是否有 clientPort 端口号在监听服务。