阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Zookeeper3.4.6的安装

213次阅读
没有评论

共计 2852 个字符,预计需要花费 8 分钟才能阅读完成。

最近为了解决 HDFS 的单点故障的问题,采用了 HA 的方式是实现,并通过 zookeeper 来实现自动切换,既然需自动切换的话,那么必须要安装 zookeeper,我选用的版本是 3.4.6。下面详细介绍一下其安装过程。

再讲具体的步骤之前,需要说明的是,我安装 zookeeper 的集群是用到了五个节点:分别是 Hadoop1,hadoop2,hadoop3,hadoop4,hadoop5。也就是说要在这五个节点上部署 zookeeper。这里需要注意一点:zookeeper 集群的节点数必须是奇数,并且至少为 3 个。这里涉及到 zookeeper 的选举算法。

1、首先肯定是从官网下载相应的 tar 包,并解压

网址:http://zookeeper.apache.org/releases.html#download 截至到我发表该文章的时候,应尽出现了 3.5.0 的版本了。

解压:tar -zxvf zookeeper-3.4.6.tar.gz

2、添加环境变量

export ZOOKEEPER_HOME=/home/grid/zookeeper-3.4.6

export PATH=$PATH:$ZOOKEEPER_HOME/bin

3、修改配置文件

cd  zookeeper-3.4.6/conf,将 zoo_sample.cfg 复制为 zoo.cfg,并修改 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=/home/grid/zookeeper-3.4.6/zkdata
dataLogDir=/home/grid/zookeeper-3.4.6/zkdatalog
# 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=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888
server.4=hadoop4:2888:3888
server.5=hadoop5:2888:3888

在这里需要注意 zoo.cfg 的配置文件中的 dataDir 和 dataLogDir 的路径当中的文件夹必须要已存在,否则后面启动 zkServer 服务的时候会失败。

4、在 dataDir 对应的路径文件夹下(我这里是 zkdata 文件夹),创建一个 myid 的文件,并在该文件中输入对应集群各节点的 id,我这里对应的是 hadoop1 对应的就是 1,这个是与

server.1=hadoop1:2888:3888 对应的。各个节点分别输入对应的 id 值即可。

5、启动 zkServer

在各节点上执行:zkServer.sh start  并通过 jps 可以看到:启动了 QuorumpeerMain 进程。

Zookeeper3.4.6 的安装

6、此时可以通过 zkServer.sh  status 命令来查看节点的启动状态。

这里需要注意点,只有当至少启动了三个节点之后,该命令才会产生结果。否则会显示:zookeeper Error contacting service. It is probably not running 错误

当你启动了至少三个节点之后,执行该命令可以看到:

Zookeeper3.4.6 的安装

至此,zookeeper 的安装工作结束。

7、关闭 zookeeper 服务

zkServer.sh stop  关闭

zkServer.sh restart  重启

————————————– 分割线 ————————————–

Ubuntu 14.04 安装分布式存储 Sheepdog+ZooKeeper  http://www.linuxidc.com/Linux/2014-12/110352.htm

CentOS 6 安装 sheepdog 虚拟机分布式储存  http://www.linuxidc.com/Linux/2013-08/89109.htm

ZooKeeper 集群配置 http://www.linuxidc.com/Linux/2013-06/86348.htm

使用 ZooKeeper 实现分布式共享锁 http://www.linuxidc.com/Linux/2013-06/85550.htm

分布式服务框架 ZooKeeper — 管理分布式环境中的数据 http://www.linuxidc.com/Linux/2013-06/85549.htm

ZooKeeper 集群环境搭建实践 http://www.linuxidc.com/Linux/2013-04/83562.htm

ZooKeeper 服务器集群环境配置实测 http://www.linuxidc.com/Linux/2013-04/83559.htm

ZooKeeper 集群安装 http://www.linuxidc.com/Linux/2012-10/72906.htm

————————————– 分割线 ————————————–

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-05/117697.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计2852字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中