zookeeper有单机、伪集群、集群三种部署方式,可根据自己实际情况选择合适的部署方式。下边对这三种部署方式逐一进行讲解。

一 单机模式

1.下载

进入要下载的版本的目录,选择.tar.gz文件下载
下载链接:http://archive.apache.org/dist/zookeeper/
注意:点击进入之后,会显示zookeeper文件的下载目录,如图所示,显示了多个版本可以下载。alpha版本是内测,功能不是很完全的,能够满足一定的需要,这里我们不建议选择;beta是公测版本,基本上可以满足要求,可以适当的根据需要选择;如果是对稳定性要求非常高的话,最好是选择正式发布的版本。

zookeeper三种模式安装详解(centos 7+zookeeper-3.4.9)

2.上传安装包到usr/local目录下,并解压缩,重命名,配置环境变量

[root@hadoop ~]# cd /usr/local/
[root@hadoop local]# tar xzvf zookeeper-3.4.9.tar.gz #解压缩
[root@hadoop local]# mv zookeeper-3.4.9 zookeeper #重命名
[root@hadoop local]# vi /etc/profile #添加环境变量
添加变量:export ZOO_HOME=/usr/local/zookeeper
然后在PATH变量后面添加::$ZOO_HOME/bin
[root@hadoop local]# source /etc/profile #生成环境变量

3.配置zookeeper。将配置模板生成为配置文件,生成dataDir目录,修改参数

[root@hadoop local]# cd /usr/local/zookeeper/conf
[root@hadoop conf]# ls
configuration.xsl  log4j.properties  zoo_sample.cfg
[root@hadoop conf]# cp zoo_sample.cfg zoo.cfg #生成配置文件
[root@hadoop conf]# mkdir -p /usr/local/zookeeper/data #生成dataDir目录
[root@hadoop conf]# vi zoo.cfg  #添加如下参数
dataDir=/usr/local/zookeeper/data #已有,修改即可
dataLogDir=/usr/local/zookeeper/data/log 
server.1=hadoop:2888:3888

附zoo.cfg文件

# The number of milliseconds of each tick
#表示每2s心跳一次,zookeeper的服务器之间或者客户端与服务器之间维持着一种心跳机制
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
#集群中的follower和leader之间初始连接时能够容忍的最大心跳数
initLimit=10 
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
#leader和follower之间同步的实现,follower和leader之间请求和应答能容忍的最大心跳数
#也就是说在5个心跳之后判断对方死亡
syncLimit=5 
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
#zookeeper数据存放的目录
dataDir=/usr/local/zookeeper/data
#zookeeper数据的日志文件存放的目录
dataLogDir=/usr/local/zookeeper/data/log
# the port at which the clients will connect
#客户端连接zookeeper的端口号
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
#此处指的是你有多少台zookeeper,每台zookeeper的服务器主机名叫什么以及相应的端口
#服务器名称与地址,包括服务器编号,地址,leader与follower通讯端口,选举端口等
server.1=hadoop:2888:3888
View Code

相关文章:

  • 2021-08-08
  • 2021-12-29
  • 2021-10-24
  • 2022-01-20
  • 2021-07-19
  • 2021-12-09
  • 2021-06-21
  • 2021-04-28
猜你喜欢
  • 2021-05-28
  • 2022-03-04
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
相关资源
相似解决方案