目录
-
注意安装前请确认已经成功安装了Hadoop
-
安装前请关闭Spark和Hadoop相关进程(请先关闭Spark,再关闭Hadoop)
-
ZooKeeper 可以从官方网站下载:Zookeeper官网
1.安装前准备
建立三个文件夹用于存储大数据软件、安装包、日志数据
mkdir -p /export/server
mkdir -p /export/software
mkdir -p /export/data
2.安装zookeeper
cd /export/software/
下载安装包 wget https://archive.apache.org/dist/zookeeper/zookeeper-3.5.7/apache-zookeeper-3.5.7-bin.tar.gz
进入server目录下
cd /export/servertar -zxvf /export/software/apache-zookeeper-3.5.7-bin.tar.gz
3. 修改环境变量
vim /etc/profile
#zookeeper
export PATH=$PATH:/export/servers/apache-zookeeper-3.5.7-bin/bin
export ZOOKEEPER_HOME=/export/servers/apache-zookeeper-3.5.7-bin
source /etc/profile
4.配置 zoo.cfg
- 进入 ZooKeeper 的 conf 目录,并将
zoo_sample.cfg
文件重命名为zoo.cfg
cp $ZOOKEEPER_HOME/conf/zoo_sample.cfg $ZOOKEEPER_HOME/conf/zoo.cfg
建立一个zkdata文件夹用于存放zookeeper日志文件
mkdir -p /export/data/zookeeper/zkdata/
vim $ZOOKEEPER_HOME/conf/zoo.cfg
- 修改相关设置,注意此处设置 dataDir 和 dataLogDir
# 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=/export/data/zookeeper/zkdata/ # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # 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 server.1=hadoop01:2888:3888 server.2=hadoop02:2888:3888 server.3=hadoop03:2888:3888
- 创建对应的文件夹
mkdir -p $ZOOKEEPER_HOME/{data,logs}
ls $ZOOKEEPER_HOME/
5. 集成 ZooKeeper 到Hadoop
修改 yarn-site.xml
文件将 zookeeper参数写入
vim $HADOOP_HOME/etc/hadoop/yarn-site.xml
<property>
<name>ha.zookeeper.quorum</name>
<value>lhadoop01:2181</value>
</property>
6. 启动 ZooKeeper
- 运行以下命令以启动 ZooKeeper:
$ZOOKEEPER_HOME/bin/zkServer.sh start
jps
检查ZooKeeper是否启动,应该有QuorumPeerMain
进程
这样就已经安装zookeeper
后续还会更新大数据组件的安装部署教程