ZooKeeper 安装

 一、Zookeeper简介与应用场景

Zookeeper 是一个开源的、为分布式应用提供协调服务的 Apache 项目.提供的服务包括:统一命名服务、统一配置管理、统一集群管理、服务器节点动态上下线、软负载均衡等.
Zookeeper 使用方式主要有单机、伪集群、集群三种部署方式.

  

二、官网下载 Linux 版本的 Zookeeper,下载好的 Zookeeper 上传到 Linux 系统上(上传到 /opt下面,主要是放在这里备份一下)

 

三、创建一个安装目录(我这里想安装在 /usr/local/zookeeper下面)

 

四、解压

1、切换到 /opt 目录下面,然后执行命令解压

// 解压文件到 /usr/local/zookeeper 目录下
tar -zxvf zookeeper-3.4.14.tar.gz -C /usr/local/zookeeper

2、解压后的目录结构如下

 

五、创建配置文件

1、创建一个 zookeeper 的配置文件 zoo.cfg,可复制 conf/zoo_sample.cfg 作为配置文件

2、zoo.cfg配置文件简介

# The number of milliseconds of each tick
# tickTime: 客户端与服务器、服务器与服务器之间维持心跳的时间间隔,也就是每一个 tickTime 会发送一次心跳,单位为毫秒
#
tickTime=2000
#
# The number of ticks that the initial 
# synchronization phase can take
# initLimit: 集群中 Leader 和 Follow 初始化连接时最多能容忍的心跳数
# 也就是初始化过程中,如果 Leader 和 Follow 在 (10*tickTime)的时间内还没有连接上,则认为连接失败
initLimit=10
#
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
# syncLimit: 同步通信实现, Leader 和 Follow 服务器之间发送请求和接收应答最多能容忍的心跳数
# 也就是Leader和Follow如果发送的请求在 (5*tickTime)的时间没没有应答,那么就认为Leader和Follow之间连接失败
#
syncLimit=5
#
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
# dataDir: zookeeper保存日志文件的目录
#
dataDir=/tmp/zookeeper
#
# the port at which the clients will connect
# clientPort: 客户端连接 zookeeper 服务器的端口, 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

# 集群信息规则(server.服务器编号=服务器的 IP 地址: LF 通信端口:选举端口
# server.N=YYY:A:B
# N: 服务器编号,每一台服务器的编号都是唯一的
# YYY: 服务器的 IP 地址
# A: LF 通信的端口,服务器与 zookeeper 集群中 Leader 交换信息的端口
# B: 选举端口,集群中每一台服务器的 A 端口都是一样的,集群中的每一台服务器的 B 端口也是一样的
# 但是当采用伪集群的时候,由于 IP 地址都是一样的,只能是 A 端口和 B 端口不一样.

  

 

posted @ 2020-10-13 19:15  变体精灵  阅读(586)  评论(0编辑  收藏  举报