当前位置: 首页 > news >正文

使用docker搭建zk集群

使用zk搭建一个3节点的zk集群,网络方式为host。

配置节点1

# 创建一个目录
/root/lyl/zookeeper/zk1

创建文件myid,文件内容如下:

1

创建文件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=/data
# 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=14lw.commands.whitelist=ruok,srvr,stat,confserver.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890

创建启动文件startzk.sh,文件内容如下:

#!/bin/shdocker rm -f myzookeeper1docker run --network host  -v /root/lyl/zookeeper/zk1/myid:/data/myid  -v /root/lyl/zookeeper/zk1/zoo.cfg:/conf/zoo.cfg  --name myzookeeper1  --restart always -d zookeeper:3.9.2

完成。

 配置节点2

# 创建一个目录
/root/lyl/zookeeper/zk2

创建文件myid,文件内容如下:

2

创建文件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=/data
# the port at which the clients will connect
clientPort=2182
# 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=14lw.commands.whitelist=ruok,srvr,stat,confserver.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890

创建启动文件startzk.sh,文件内容如下:

#!/bin/shdocker rm -f myzookeeper2docker run --network host  -v /root/lyl/zookeeper/zk2/myid:/data/myid  -v /root/lyl/zookeeper/zk2/zoo.cfg:/conf/zoo.cfg  --name myzookeeper2  --restart always -d zookeeper:3.9.2

完成节点2配置。

 配置节点3

# 创建一个目录
/root/lyl/zookeeper/zk3

创建文件myid,文件内容如下:

3

创建文件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=/data
# the port at which the clients will connect
clientPort=2183
# 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=14lw.commands.whitelist=ruok,srvr,stat,confserver.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890

创建启动文件startzk.sh,文件内容如下:

#!/bin/shdocker rm -f myzookeeper3docker run --network host  -v /root/lyl/zookeeper/zk3/myid:/data/myid  -v /root/lyl/zookeeper/zk3/zoo.cfg:/conf/zoo.cfg  --name myzookeeper3  --restart always -d zookeeper:3.9.2

完成。

相关文章:

  • 【新闻转载】Storm-0501:勒索软件攻击扩展到混合云环境
  • 【源码+文档+调试讲解】交通信息管理系统
  • 用Python实现运筹学——Day 8: 对偶理论的经济解释
  • 论文阅读【时间序列】ModerTCN (ICLR2024)
  • 堆【数据结构C语言版】【 详解】
  • 打点 - 泛微 E-Cology WorkflowServiceXml
  • 记录|Modbus-TCP产品使用记录【德克威尔】
  • Docker面试-24年
  • Simplygon 使用笔记2
  • 华为OD机试 - 超级玛丽通过吊桥的走法 - 动态规划(Python/JS/C/C++ 2024 E卷 200分)
  • 025.Oracle_DBMS_job定时任务
  • python运维自动化Paramiko
  • 【信创,国产化】信息化系统信创改造,国产化改造方案,云建设
  • 鸿蒙NEXT开发-ArkUI(基于最新api12稳定版)
  • Vue Element UI 打包上线后icon偶发性乱码问题
  • [ 一起学React系列 -- 8 ] React中的文件上传
  • 【附node操作实例】redis简明入门系列—字符串类型
  • 【划重点】MySQL技术内幕:InnoDB存储引擎
  • 10个最佳ES6特性 ES7与ES8的特性
  • HTML-表单
  • linux学习笔记
  • maya建模与骨骼动画快速实现人工鱼
  • October CMS - 快速入门 9 Images And Galleries
  • spring + angular 实现导出excel
  • 互联网大裁员:Java程序员失工作,焉知不能进ali?
  • 前端性能优化--懒加载和预加载
  • 微服务框架lagom
  • 好程序员大数据教程Hadoop全分布安装(非HA)
  • ​如何使用QGIS制作三维建筑
  • # 消息中间件 RocketMQ 高级功能和源码分析(七)
  • ## 1.3.Git命令
  • ###51单片机学习(2)-----如何通过C语言运用延时函数设计LED流水灯
  • #进阶:轻量级ORM框架Dapper的使用教程与原理详解
  • #我与Java虚拟机的故事#连载17:我的Java技术水平有了一个本质的提升
  • $redis-setphp_redis Set命令,php操作Redis Set函数介绍
  • (10)STL算法之搜索(二) 二分查找
  • (2/2) 为了理解 UWP 的启动流程,我从零开始创建了一个 UWP 程序
  • (vue)el-tabs选中最后一项后更新数据后无法展开
  • (保姆级教程)Mysql中索引、触发器、存储过程、存储函数的概念、作用,以及如何使用索引、存储过程,代码操作演示
  • (四)Controller接口控制器详解(三)
  • (推荐)叮当——中文语音对话机器人
  • (译)2019年前端性能优化清单 — 下篇
  • .config、Kconfig、***_defconfig之间的关系和工作原理
  • .NET 4.0网络开发入门之旅-- 我在“网” 中央(下)
  • .net CHARTING图表控件下载地址
  • .net core 6 redis操作类
  • .NET 指南:抽象化实现的基类
  • .netcore 如何获取系统中所有session_ASP.NET Core如何解决分布式Session一致性问题
  • .NET成年了,然后呢?
  • .net专家(张羿专栏)
  • /boot 内存空间不够
  • @Bean, @Component, @Configuration简析
  • @DS 多数据源 + @Transactional(rollbackFor = Exception.class) 导致@DS 多数据源没法使用
  • @Value获取值和@ConfigurationProperties获取值用法及比较(springboot)
  • [1127]图形打印 sdutOJ