zookeeper安装部署

kafka部署前需要部署zookeeper,zookeeper是kafka的前置依赖

一、zookeeper下载

wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

二、解压安装

cd /software
tar -xvzf zookeeper-3.4.6.tar.gz 
mv zookeeper-3.4.6 zookeeper

三、建立数据和日志目录

mkdir -p /software/zookeeper/data
mkdir -p /software/zookeeper/logs

四、更改配置文件

//更改配置文件名
cp /software/zookeeper/conf/zoo_sample.cfg /software/zookeeper/conf/zoo.cfg

vi /software/zookeeper/conf/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=/software/zookeeper/data
dataLogDir=/software/zookeeper/logs
# 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=192.168.230.131:3188:3288
server.2=192.168.230.132:3188:3288
server.3=192.168.230.133:3188:3288

五、安装包分发

分发zookeeper文件夹到其他集群主机

然后每台集群创建myid文件

scp -r /software/zookeeper hadoop02:/software
scp -r /software/zookeeper hadoop03:/software
在每个节点的dataDir指定的目录下创建一个myid的文件

echo 1 > /software/zookeeper/data/myid
echo 2 > /software/zookeeper/data/myid
echo 3 > /software/zookeeper/data/myid

 六、配置zookeeper启动脚本

脚本分发到所有集群

(后续发布hadoop生态圈的集群一键启停脚本)

vim /etc/init.d/zookeeper
#!/bin/bash
#chkconfig:2345 20 90
#description:Zookeeper Service Control Script
ZK_HOME='/software/zookeeper'
case $1 in
start)
  echo "zookpeeper 启动"
  echo "$ZK_HOME/bin/zkServer.sh start"  
  $ZK_HOME/bin/zkServer.sh start
;;
stop)
  echo "zookpeeper 停止"
  echo "$ZK_HOME/bin/zkServer.sh stop"
  $ZK_HOME/bin/zkServer.sh stop
;;
restart)
  echo "zookpeeper 重启"
  echo "$ZK_HOME/bin/zkServer.sh restart"
  $ZK_HOME/bin/zkServer.sh restart
;;
status)
  echo "zookpeeper 状态"
  echo "$ZK_HOME/bin/zkServer.sh status"
  $ZK_HOME/bin/zkServer.sh status
;;
*)
  echo "Usage: $0 {start|stop|restart|status}"
esac

七、设置开机自启,每台机群

//赋权
chmod +x /etc/init.d/zookeeper

chkconfig --add zookeeper

//启动
service zookeeper start
//查看状态
service zookeeper status

八、启动zkCli客户端 

cd /software/zookeeper/bin
./zkCli.sh -server hadoop01:2181,hadoop02:2181,hadoop03:2181

 

问题记录:

zk启动正常,查看状态异常,报错如下

JMX enabled by default
Using config: /software/zookeeper/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.

参考博客

启动Zookeeper报错:Error contacting service. It is probably not running._俗子胸襟谁识我的博客-CSDN博客

重点问题汇总:

1、selinux和防火墙的未关闭

2、节点ID标识文件myid是否正确

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值