Zookeeper 00 安装

ZooKeeper是一个分布式开源框架,提供了协调分布式应用的基本服务,它向外部应用暴露一组通用服务——分布式同步(Distributed Synchronization)、命名服务(Naming Service)、集群维护(Group Maintenance)等,简化分布式应用协调及其管理的难度,提供高性能的分布式服务。ZooKeeper本身可以以Standalone模式安装运行,不过它的长处在于通过分布式ZooKeeper集群(一个Leader,多个Follower),基于一定的策略来保证ZooKeeper集群的稳定性和可用性,从而实现分布式应用的可靠性。

下面,我们简单说明一下ZooKeeper的配置。

ZooKeeper Standalone模式

从Apache网站上(zookeeper.apache.org)下载ZooKeeper软件包,我选择了3.3.4版本的(zookeeper-3.3.4.tar.gz),在一台Linux机器上安装非常容易,只需要解压缩后,简单配置一下即可以启动ZooKeeper服务器进程。

将zookeeper-3.3.4/conf目录下面的 zoo_sample.cfg修改为zoo.cfg,配置文件内容如下所示:

tickTime=2000
dataDir=/home/hadoop/storage/zookeeper
clientPort=2181
initLimit=5
syncLimit=2

上面各个配置参数的含义也非常简单,引用如下所示:

tickTime —— the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats and the minimum session timeout will be twice the tickTime.dataDir —— the location to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.clientPort —— the port to listen for client connections

启动ZooKeeper服务器进程

bin/zkServer.sh start

在客户端连接ZooKeeper服务器

bin/zkCli.sh -server localhost:2181

ZooKeeper Distributed模式

ZooKeeper分布式模式安装(ZooKeeper集群)也比较容易,这里说明一下基本要点。

第一步:主机名称到IP地址映射配置

ZooKeeper集群中具有两个关键的角色:Leader和Follower。集群中所有的结点作为一个整体对分布式应用提供服务,集群中每个结点之间都互相连接,所以,在配置的ZooKeeper集群的时候,每一个结点的host到IP地址的映射都要配置上集群中其它结点的映射信息。

例如,我的ZooKeeper集群中每个结点的配置,以slave-01为例,/etc/hosts内容如下所示:

192.168.0.179   slave-01
192.168.0.178   slave-02
192.168.0.177   slave-03

在其中一台机器(slave-01)上,解压缩zookeeper-3.3.4.tar.gz,修改配置文件conf/zoo.cfg,内容如下所示:

tickTime=2000
dataDir=/home/hadoop/storage/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=slave-01:2888:3888
server.2=slave-02:2888:3888
server.3=slave-03:2888:3888
在之前设置的dataDir中新建myid文件, 写入一个数字, 该数字表示这是第几号server. 该数字必须和zoo.cfg文件中的server.X中的X一一对应.
cd /home/hadoop/installation/
scp -r zookeeper-3.3.4/ hadoop@slave-02:/home/hadoop/installation/
scp -r zookeeper-3.3.4/ hadoop@slave-03:/home/hadoop/installation/
hadoop@slave-01:~/installation/zookeeper-3.3.4$ bin/zkServer.sh starthadoop@slave-02:~/installation/zookeeper-3.3.4$ bin/zkServer.sh start
hadoop@slave-03:~/installation/zookeeper-3.3.4$ bin/zkServer.sh start
hadoop@slave-01:~/installation/zookeeper-3.3.4$ bin/zkServer.sh status  JMX enabled by default  
Using config: /home/hadoop/installation/zookeeper-3.3.4/bin/../conf/zoo.cfg  
Mode: follower


转载于:https://my.oschina.net/Yaland/blog/464137

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值