在三台Centos或Windows中部署三台Zookeeper集群配置
一、安装包
1、下载最新版(3.4.13):https://archive.apache.org/dist/zookeeper/ 下载https://archive.apache.org/dist/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz解压开即可。本文中解压到/opt目录下。
二、环境
1、三台服务器IP分别为:192.168.1.104、192.168.1.105、192.168.1.106
2、三台的Zookeeper配置文件路径都是:/opt/zookeeper/zookeeper-3.4.13/conf/zoo.cfg
三、配置集群:
1、服务器192.168.1.104中:
(1)修改/opt/zookeeper/zookeeper-3.4.13/conf/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=/opt/zookeeper/zkdata/data dataLogDir=/opt/zookeeper/zkdata/log # 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.104=0.0.0.0:2888:3888 server.105=192.168.6.105:2888:3888 server.106=192.168.6.106:2888:3888
(2)创建目录并配置myid。
I、创建目录:/opt/zookeeper/zkdata/data
II、创建文件:/opt/zookeeper/zkdata/data/myid ,内容为"104" ,或者使用命令快速生成:
echo 104>/opt/zookeeper/zkdata/data/myid
2、服务器192.168.1.105中:
(1)修改/opt/zookeeper/zookeeper-3.4.13/conf/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=/opt/zookeeper/zkdata/data
dataLogDir=/opt/zookeeper/zkdata/log
# 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.104=192.168.6.104:2888:3888
server.105=0.0.0.0:2888:3888
server.106=192.168.6.106:2888:3888
(2)创建目录并配置myid。
I、创建目录:/opt/zookeeper/zkdata/data
II、创建文件:/opt/zookeeper/zkdata/data/myid ,内容为"105" ,或者使用命令快速生成:
echo 105>/opt/zookeeper/zkdata/data/myid
3、服务器192.168.1.106中:
(1)修改/opt/zookeeper/zookeeper-3.4.13/conf/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=/opt/zookeeper/zkdata/data dataLogDir=/opt/zookeeper/zkdata/log # 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.104=192.168.6.104:2888:3888 server.105=192.168.6.105:2888:3888 server.106=0.0.0.0:2888:3888
(2)创建目录并配置myid。
I、创建目录:/opt/zookeeper/zkdata/data
II、创建文件:/opt/zookeeper/zkdata/data/myid ,内容为"106" ,或者使用命令快速生成:
echo 106>/opt/zookeeper/zkdata/data/myid
四、三台机器中,都为防火墙中添加2181、2888、3888端口入站。
添加端口: firewall-cmd --zone=public --add-port=2181/tcp --permanent firewall-cmd --zone=public --add-port=2888/tcp --permanent firewall-cmd --zone=public --add-port=3888/tcp --permanent 重新载入: firewall-cmd --reload
五、启动Zookeeper:三台机器中依次运行
/opt/zookeeper/zookeeper-3.4.13/bin/zkServer.sh start /opt/zookeeper/zookeeper-3.4.13/conf/zoo.cfg
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
2015-03-21 Xamarin 中开发Android实现全屏或者不显示标题栏的方法-宋兴柱
2015-03-21 Android中实现全屏、无标题栏的两种办法