ZooKeeper 安装
一、Zookeeper简介与应用场景
Zookeeper 是一个开源的、为分布式应用提供协调服务的 Apache 项目.提供的服务包括:统一命名服务、统一配置管理、统一集群管理、服务器节点动态上下线、软负载均衡等.
Zookeeper 使用方式主要有单机、伪集群、集群三种部署方式.
二、官网下载 Linux 版本的 Zookeeper,下载好的 Zookeeper 上传到 Linux 系统上(上传到 /opt下面,主要是放在这里备份一下)
三、创建一个安装目录(我这里想安装在 /usr/local/zookeeper下面)
四、解压
1、切换到 /opt 目录下面,然后执行命令解压
1 2 | // 解压文件到 /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配置文件简介
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # 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 端口不一样. |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?