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

Redis 集群三主三从配置

1:安装 

Redis安装Linux ubuntu_ubuntu离线安装redis7.2.5-CSDN博客

2:主从复制配置

参考  Redis主从同步配置-CSDN博客

3:哨兵配置

参考 Redis 哨兵模式配置-CSDN博客

4:集群配置

Redis 集群三主三从配置-CSDN博客

5:创建文件夹

到达redis 根目录
cd /usr/redis/# 创建主从工作目录
mkdir -p replication/6401
mkdir -p replication/6402
mkdir -p replication/6403
mkdir -p replication/6404
mkdir -p replication/6405
mkdir -p replication/6406# 创建日志目录
mkdir -p log/6401
mkdir -p log/6402
mkdir -p log/6403
mkdir -p log/6404
mkdir -p log/6405
mkdir -p log/6406# 创建pid目录
mkdir -p run/6401
mkdir -p run/6402
mkdir -p run/6403
mkdir -p run/6404
mkdir -p run/6405
mkdir -p run/6406

6:复制配置

mkdir -p /usr/redis/config
cp /usr/redis/redis.conf /usr/redis/config/reids_6401.conf

7: 修改配置

sed -i 's/6379/6401/g' redis_6401.confvi /usr/redis/config/redis_6401.conf# cluster节点端口号
port 6401# 开启集群模式
cluster-enabled yes# 节点超时时间
cluster-node-timeout 15000# 需要注释
# replicaof 127.0.0.1 6377#redis.conf 复制的源文件 有修改下面的配置忽略 可参考 #https://blog.csdn.net/qq_36577291/article/details/141288857# 修改后台启动
daemonize yes# pid号写入哪个配置文件
pidfile /usr/redis/run/6401/redis.pid
# 日志提示
logfile "/usr/redis/log/6401/redis.log"# 指定数据文件的存放位置,因为需要在一台机器启动两个实例,所以必须指定不同的位置,不然会丢失数据
dir /usr/redis/replication/6401/# 注释上允许所有网卡访问
# bind 0:0:0:0# 关闭保护模式
protected-mode no# 开启 AOF 存储 (可以关闭)
appendonly yes#设置密码
requirepass 123456#设置同步主节点的密码 (如果作为主节点 可以不设置)
masterauth 123456

8:增加其他节点配置

cp redis_6401.conf  redis_6402.conf
cp redis_6401.conf  redis_6403.conf
cp redis_6401.conf  redis_6404.conf
cp redis_6401.conf  redis_6405.conf
cp redis_6401.conf  redis_6406.confsed -i 's/6401/6402/g' redis_6402.conf
sed -i 's/6401/6403/g' redis_6403.conf
sed -i 's/6401/6404/g' redis_6404.conf
sed -i 's/6401/6405/g' redis_6405.conf
sed -i 's/6401/6406/g' redis_6406.conf

9:启动 6个节点

/usr/redis/redis-7.2.5/src/redis-server /usr/redis/config/redis_6401.conf  
/usr/redis/redis-7.2.5/src/redis-server /usr/redis/config/redis_6402.conf
/usr/redis/redis-7.2.5/src/redis-server /usr/redis/config/redis_6403.conf 
/usr/redis/redis-7.2.5/src/redis-server /usr/redis/config/redis_6404.conf 
/usr/redis/redis-7.2.5/src/redis-server /usr/redis/config/redis_6405.conf 
/usr/redis/redis-7.2.5/src/redis-server /usr/redis/config/redis_6406.conf 

10:关联集群


/usr/redis/redis-7.2.5/src/redis-cli -a 123456 --cluster create 127.0.0.1:6401 127.0.0.1:6402 127.0.0.1:6403 127.0.0.1:6404 127.0.0.1:6405 127.0.0.1:6406 --cluster-replicas 1

 查看配置


/usr/redis/redis-7.2.5/src/redis-cli -p 6401 -a 123456
127.0.0.1:6401> info/usr/redis/redis-7.2.5/src/redis-cli -p 6404 -a 123456
127.0.0.1:6404> info

 6401节点的信息

6404节点的信息

 

11:测试可用性

ps -ef |grep redis
kill -9  6401端口的pid重新启动 6401
/usr/redis/redis-7.2.5/src/redis-server /usr/redis/config/redis_6401.conf

查看节点信息


/usr/redis/redis-7.2.5/src/redis-cli -p 6401 -a 123456
127.0.0.1:6401> info/usr/redis/redis-7.2.5/src/redis-cli -p 6404 -a 123456
127.0.0.1:6404> info

6404节点的信息

12:6401 和 6404 接口主从切换成功,收工

参考资料

A:安装

Redis安装Linux ubuntu_ubuntu离线安装redis7.2.5-CSDN博客

B:主从复制配置

参考  Redis主从同步配置-CSDN博客

C:哨兵配置

参考 Redis 哨兵模式配置-CSDN博客

D:集群配置

Redis 集群三主三从配置-CSDN博客


http://www.mrgr.cn/news/539.html

相关文章:

  • Shell脚本发送邮件的详细步骤与配置方法?
  • 长短期记忆网络(LSTM)预测模型及其Python和MATLAB实现
  • 打破接口壁垒:适配器模式让系统无缝对接
  • AVI-Talking——能通过语音生成很自然的 3D 说话面孔
  • android13禁用打开wifi ap 热点
  • list使用及底层模拟实现
  • 海康VisionMaster使用学习笔记5-开机自启动
  • GORM 模型定义及代码示例
  • 线程的概念
  • 《学会 SpringBoot 系列 · spring.factories 详解》
  • WEB漏洞-SQL注入之简要SQL注入
  • HTTPS 详解
  • 看图学sql之sql 中的窗口函数
  • 融合创新:EasyCVR视频汇聚平台云计算技术与AI技术共筑雪亮工程智能防线
  • RabbitMQ发布订阅模式Publish/Subscribe详解
  • 了解Android
  • 客户端登录逻辑
  • WLAN射频调优
  • 物流快递外卖管理平台系统-计算机毕设Java|springboot实战项目
  • OpenHarmony网络协议通信—libevent [GN编译] - 事件通知库