Redis7.X Centos集群搭建
下载#
https://download.redis.io/redis-stable.tar.gz
部署#
-
上传解压
tar -zxvf redis-stable.tar.gz -
编译安装
cd redis-stable make && make install -
创建6个节点的目录
# 创建日志目录 mkdir /usr/local/redis-cluster/{6379,6380,6381,6382,6383,6384}/log # 创建配置文件目录 mkdir /usr/local/redis-cluster/{6379,6380,6381,6382,6383,6384}/config -
写入配置文件
# 6379节点配置文件 cat << EOF > /usr/local/redis-cluster/6379/config/redis.conf protected-mode no bind 0.0.0.0 port 6379 # 服务监听端口 daemonize yes # 后台启动 dir /usr/local/redis-cluster/6379/ pidfile /usr/local/redis-cluster/6379/redis_6379.pid masterauth test-cluster # 启动 redis 密码验证,主要是针对 master 对应的 slave 节点设置的,在 slave 节点数据同步的时候用到 requirepass test-cluster # redis密码,#启动 redis 密码验证,一定要 requirepass 和 masterauth 同时设置。对登录权限做限制,redis每个节点的requirepass可以是独立、不同的,但建议和 masterauth 设置成一样 appendonly yes # 启用守护进程 cluster-enabled yes # 启用集群 cluster-config-file "nodes.conf" # 关联集群的配置文件 cluster-node-timeout 5000 # 集群超时时间 cluster-require-full-coverage no # 只要有结点宕机导致 16384 个槽没全被覆盖,整个集群就全部停止服务,所以一定要改为 no EOF # 6380节点配置文件 cat << EOF > /usr/local/redis-cluster/6380/config/redis.conf protected-mode no bind 0.0.0.0 port 6380 daemonize yes dir /usr/local/redis-cluster/6380/ pidfile /usr/local/redis-cluster/6380/redis_6380.pid masterauth test-cluster requirepass test-cluster appendonly yes cluster-enabled yes cluster-config-file "nodes.conf" cluster-node-timeout 5000 cluster-require-full-coverage no EOF # 6381,6382,6383,6384配置文件参考上面的 -
创建集群
redis-cli -a "test-cluster" --cluster create 192.168.137.10:6379 192.168.137.10:6380 192.168.137.10:6381 192.168.137.10:6382 192.168.137.10:6383 192.168.137.10:6384 --cluster-replicas 1 -
验证集群
redis-cli -h 192.168.137.10 -c -p 6380 -a "test-cluster" -
集群查看相关命令
1.集群状态 redis-cli -h ip -p 6401 -a password cluster info 2.集群节点信息 redis-cli -h ip -p 6401 -a password cluster nodes 3.节点内存、cpu、key数量等信息(每个节点都需查看) redis-cli -h ip -p 6401 -a password info
作者:jruing
出处:https://www.cnblogs.com/jruing/p/17669694.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
本文来自博客园,作者:Jruing,转载请注明原文链接:https://www.cnblogs.com/jruing/p/17669694.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)