1. zookeeper 的下载
从官网下载自己要安装的 zookeeper
附上官网地址
http://zookeeper.apache.org/releases.html
2.开始安装
2.1 上传到服务器
scp zookeeper.3.14.tar.gz root@:hdp:~/
2.2 解压
tar zvxf zookeeper.3.14.tar.gz
2.3 移动到/usr/local 目录并重命名为 zookeeper
mv zookeeper-3.14 /usr/local/zookeeper
2.4 修改配置文件
先复制模版
cd zookeeper/conf
cp zookeeper-sample.cfg zookeeper.cfg
2.4.1 如果单机启动的话只修改数据存放文件就可以了
# 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=/root/zkdata
# the port at which the clients will connect
clientPort=2181
2.4.2 集群启动的话需要配置各节点
# 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=/root/zkdata
# the port at which the clients will connect
clientPort=2181
server.1=hdp-master:2888:3888
server.2=hdp-node:2888:3888
server.3=hdp-node2:2888:3888
2.5 在服务器上新建数据目录/root/zkdata,并生成 myid
mkdir zkdata
echo 1 > zkdata/myid
2.6 如果启动集群的话分发 zookeeper
scp zookeeper root@hdp-node:$PWD
3 启动
bin/zkServer.sh start
4 通过脚本批量启动集群
▽
#!/bin/bash
# 要启动的集群hosts
manager_hosts=(hdp-master hdp-node hdp-node2)
for host in ${manager_hosts[@]}
do
echo "${host}:${1}ing..."
ssh ${host} "source /etc/profile;/usr/local/zookeeper/bin/zkServer.sh $1"
done
sleep 2
for host in ${manager_hosts[@]}
do
echo "${host}:${1}ing..."
ssh ${host} "source /etc/profile;/usr/local/zookeeper/bin/zkServer.sh status"
done
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于