Zookeeper 集群搭建

Zookeeper 集群搭建

1.安装包下载与解压

搭建zookeeper集群最少需要三台机器

安装包下载与解压,前往apache官网下载,不做赘述

我是将zookeeper放置在/usr/local目录下

2.修改配置文件

在zookeeper安装目录的conf中将zoo_sample.cfg修改为zoo.cfg

修改其中配置

[root@hadoop1 conf] mv zoo_sample.cfg zoo.cfg
[root@hadoop1 conf] vi 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.
####此处需要修改
dataDir=/data/zookeeper
# the port at which the clients will connect
clientPort=2181
####此处需要新增,
server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888

3.配置环境变量

[root@hadoop conf] vi /etc/profile
    export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6
    export PATH=${PATH}:${ZOOKEEPER_HOME}/bin
[root@hadoop1 conf] source /etc/profile
[root@hadoop1 conf] cd  /data/zookeeper
[root@hadoop1 zookeeper] echo 1 > myid

以上配置完成,将以上配置复制到另外两台机器上,主要myid要匹配

4.启动zookeeper

#启动
[root@hadoop1 zookeeper] zkServer.sh start
      ZooKeeper JMX enabled by default
      Using config: /opt/zookeeper-3.4.10/bin/../conf/zoo.cfg
      Starting zookeeper ... STARTED
#查看状态
[root@hadoop1 zookeeper] zkServer.sh status
      ZooKeeper JMX enabled by default
      Using config: /opt/zookeeper-3.4.10/bin/../conf/zoo.cfg
      Mode: leader
#测试
[root@hadoop1 zookeeper] zkCli.sh hadoop1:2181

5.设置开机自启动

[root@zookeeper ~] vim /etc/rc.d/rc.local 
 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
 
touch /var/lock/subsys/local
export JAVA_HOME=/usr/java/jdk1.8.0_112
/usr/local/zookeeper-3.4.6/bin/zkServer.sh start
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值