《Linux运维总结:基于ARM64+X86_64架构CPU使用docker-compose一键离线部署redis 7.4.5容器版分片集群》

总结:整理不易,如果对你有帮助,可否点赞关注一下?

更多详细内容请参考:《Linux运维篇:Linux系统运维指南》


一、部署背景

随着客户部署数量增加,传统手工方式部署 Redis 分片集群已难以满足效率与稳定性要求。特别是面对 x86_64 和 ARM64 多架构共存的环境,以及 Redis 7.4.5 启用 TLS/SSL 的安全需求,配置复杂度显著上升。

因此,开发一套支持 跨平台容器化部署的 Redis 分片集群自动化工具,不仅能大幅缩短交付周期,还能统一安全策略、降低人为错误率,是实现运维提效和产品标准化交付的关键一步。

CPU架构 docker版本 docker-compose版本
X86_64 26.1.3 v2.29.0
ARM64 26.1.3 v2.29.0

二、工具介绍

一键部署工具实现功能如下:

1、支持 ARM64与x86_64架构CPU,确保在国产化与通用平台环境下均可部署运行。
2、支持TLS/SSL全链路加密通信(客户端-服务端、节点间通信), SSL证书有效期为100年,降低证书轮换维护成本。
3、支持Redis单实例部署,适用于开发测试或轻量级应用环境。
4、支持在同一主机上模拟完整的Redis Cluster架构,3个主节点(Master)+ 3个从节点(Slave),每个主节点对应一个副本实现数据分片与高可用能力的本地验证与测试。
5、支持跨主机的生产级分布式部署Redis Cluster架构,3个主节点(Master)+ 3个从节点(Slave),节点分布于不同物理机或虚拟机,自动实现数据分片(sharding)、故障检测与主从切换,保障服务高可用。。
6、支持数据目录、日志目录、服务端口、最大客户端连接数、访问密码、 I/O线程数、内存上限等参数灵活配置。
7、支持数据目录、日志目录及配置文件的持久化存储。
8、支持集群的一键创建、启动、停止、健康检查、卸载等完整生命周期操作,便于自动化运维与资源回收。
9、提供一键连接功能,快速进入Redis CLI客户端,简化调试与维护流程。

如下图所示:


说明:工具使用非常简单,只需要修改变量文件,就可以快速帮你快速部署redis 7.4.5 cluster集群。


三、工具下载

基于X86-64+ARM64架构CPU使用docker-compose一键离线部署redis 6.2.14容器版分片集群工具

主控脚本部分内容如下所示:


四、部署步骤

说明:单机伪集群是指在单主机部署redis cluster集群,分布式集群是指在多个不同主机上部署redis cluster集群,这里部署的是多机分布式cluster集群。


1、查看帮助命令


2、部署规划

说明:由于资源有限,这里使用1台服务器部署redis cluster集群。

宿主机IP 操作系统 内核版本 节点说明
192.168.1.111 Ubuntu 22.04.2 LTS 5.15.0-113-generic redis1节点
192.168.1.112 Ubuntu 22.04.2 LTS 5.15.0-113-generic redis2节点
192.168.1.113 Ubuntu 22.04.2 LTS 5.15.0-113-generic redis3节点
192.168.1.114 Ubuntu 22.04.2 LTS 5.15.0-113-generic redis4节点
192.168.1.115 Ubuntu 22.04.2 LTS 5.15.0-113-generic redis5节点
192.168.1.116 Ubuntu 22.04.2 LTS 5.15.0-113-generic redis6节点

3、准备一键部署工具包

说明:将一键部署工具包分别上传到rediscluster集群所有节点上。


4、编辑变量文件

说明:以下操作分别在rediscluster集群节点的部署工具包中修改cluster.conf文件, 三个节点上cluster.conf文件内容一致

bash 复制代码
root@localhost:/opt/redis-cluster# cp cluster.conf.tpl cluster.conf
root@localhost:/opt/redis-cluster# cat  cluster.conf

如下图所示:


5、执行部署

说明:部署顺序必须为:redis1节点 > redis2节点 > redis3节点>redis4节点 > redis5节点 > redis6节点


a、部署redis1节点(192.168.1.111)

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a build -m redis1

b、部署redis2节点(192.168.1.112)

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a build -m redis2

c、部署redis3节点(192.168.1.113)

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a build -m redis3

d、部署redis1节点(192.168.1.114)

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a build -m redis4

e、部署redis2节点(192.168.1.115)

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a build -m redis5

f、部署redis3节点(192.168.1.116)

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a build -m redis6

五、其它操作

5.1、启动

说明:分别在对应主机节点上执行。

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a start -m redis1
root@localhost:/opt/redis-cluster# ./op.sh -a start -m redis2
root@localhost:/opt/redis-cluster# ./op.sh -a start -m redis3
root@localhost:/opt/redis-cluster# ./op.sh -a start -m redis4
root@localhost:/opt/redis-cluster# ./op.sh -a start -m redis5
root@localhost:/opt/redis-cluster# ./op.sh -a start -m redis6

5.2、停止

说明:分别在对应主机节点上执行。

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a stop -m redis1
root@localhost:/opt/redis-cluster# ./op.sh -a stop -m redis2
root@localhost:/opt/redis-cluster# ./op.sh -a stop -m redis3
root@localhost:/opt/redis-cluster# ./op.sh -a stop -m redis4
root@localhost:/opt/redis-cluster# ./op.sh -a stop -m redis5
root@localhost:/opt/redis-cluster# ./op.sh -a stop -m redis6

5.3、检查

说明:分别在对应主机节点上执行。

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a check -m redis1
root@localhost:/opt/redis-cluster# ./op.sh -a check -m redis2
root@localhost:/opt/redis-cluster# ./op.sh -a check -m redis3
root@localhost:/opt/redis-cluster# ./op.sh -a check -m redis4
root@localhost:/opt/redis-cluster# ./op.sh -a check -m redis5
root@localhost:/opt/redis-cluster# ./op.sh -a check -m redis6

5.4、卸载

说明:分别在对应主机节点上执行。

bash 复制代码
root@localhost:/opt/redis-cluster# ./op.sh -a clear -m redis1
root@localhost:/opt/redis-cluster# ./op.sh -a clear -m redis2
root@localhost:/opt/redis-cluster# ./op.sh -a clear -m redis3
root@localhost:/opt/redis-cluster# ./op.sh -a clear -m redis4
root@localhost:/opt/redis-cluster# ./op.sh -a clear -m redis5
root@localhost:/opt/redis-cluster# ./op.sh -a clear -m redis6

5.5、连接

说明:分别在对应主机节点上执行。

bash 复制代码
root@localhost:/opt/redis-cluster# cd tools/
root@localhost:/opt/redis-cluster/tools# ./auto_connect.sh connect redis1

root@localhost:/opt/redis-cluster# cd tools/
root@localhost:/opt/redis-cluster/tools# ./auto_connect.sh connect redis2

root@localhost:/opt/redis-cluster# cd tools/
root@localhost:/opt/redis-cluster/tools# ./auto_connect.sh connect redis3

root@localhost:/opt/redis-cluster# cd tools/
root@localhost:/opt/redis-cluster/tools# ./auto_connect.sh connect redis4

root@localhost:/opt/redis-cluster# cd tools/
root@localhost:/opt/redis-cluster/tools# ./auto_connect.sh connect redis5

root@localhost:/opt/redis-cluster# cd tools/
root@localhost:/opt/redis-cluster/tools# ./auto_connect.sh connect redis6

总结:整理不易,如果对你有帮助,可否点赞关注一下?

更多详细内容请参考:《Linux运维篇:Linux系统运维指南》

相关推荐
前端不太难7 小时前
从 Navigation State 反推架构腐化
前端·架构·react
wanhengidc7 小时前
云手机的适配性怎么样?
运维·服务器·安全·智能手机·云计算
码农很忙7 小时前
HSAP一体化混合搜索与分析架构全解:重塑数据价值的新范式
架构
jimy17 小时前
安卓里运行Linux
linux·运维·服务器
川贝枇杷膏cbppg8 小时前
Redis 的 RDB 持久化
前端·redis·bootstrap
哟哟耶耶8 小时前
js-fetch流式实现中断重连
运维·服务器
爱凤的小光8 小时前
Linux清理磁盘技巧---个人笔记
linux·运维
源代码•宸8 小时前
goframe框架签到系统项目(BITFIELD 命令详解、Redis Key 设计、goframe 框架教程、安装MySQL)
开发语言·数据库·经验分享·redis·后端·mysql·golang
川贝枇杷膏cbppg8 小时前
Redis 的 AOF
java·数据库·redis
耗同学一米八9 小时前
2026年河北省职业院校技能大赛中职组“网络建设与运维”赛项答案解析 1.系统安装
linux·服务器·centos