redis哨兵模式

redis持久化

Redis的所有数据都是保存在内存中,然后不定期的通过异步方式保存到磁盘上(这称为"半持久化模式"RDB);也可以把每一次数据变化都写入到一个 append only file(AOF)里面(这称为"全持久化模式")。

下载redis: yum install -y redis
启动redis:systemctl start redis
编译文件:vim /etc/redis.conf (搜索APPEND)

编译文件:vim /etc/redis.conf

重启redis服务:systemctl restart redis

在/etc/下复制文件:cp redis.conf redis_6379.conf

更改文件内309行

355行 改成自己文件名

cp redis_6379.conf redis_6380.conf

编辑文件 vim redis_6380.conf(改自己文件名,两处)

端口号138行

533行 写主的IP端口号

创建目录:mkdir /etc/redis

mv redis_63* redis

创建6381:cp redis_6379.conf redis_6381.conf

更改6381文件:sed -i 's/6379/6381/' redis_6381.conf

启动所有redis服务:for i in 6379 6380 6381; do redis-server /etc/redis/redis_${i}.conf;done
注意!!!其他IP地址改从同理

创建哨兵文件:mkdir redis_sentinel

cp /etc/redis-sentinel.conf /etc/redis_sentinel/

mv redis-sentinel.conf redis-sentinel_26379.conf (更改3处)

再复制两个文件

cp redis-sentinel_26379.conf redis-sentinel_26380.conf

cp redis-sentinel_26379.conf redis-sentinel_26381.conf

sed -i 's/6379/6380/' redis-sentinel_26380.conf

sed -i 's/6379/6381/' redis-sentinel_26381.conf

sed -i 's/127.0.0.1 6379/192.168.11.133 6379/' redis-sentinel_26379.conf

sed -i 's/127.0.0.1 6380/192.168.11.133 6379/' redis-sentinel_26380.conf

sed -i 's/127.0.0.1 6381/192.168.11.133 6379/' redis-sentinel_26381.conf

验证

grep -r '192.168.11.133 6379' ./

轮个登录指向主:

redis-cli -h 192.168.11.133 -p 6380

slaveof 192.168.11.133 6379

redis-cli -h 192.168.11.133 -p 6381

slaveof 192.168.11.133 6379

验证:

开启哨兵:

redis-sentinel /etc/redis_sentinel/redis-sentinel_26379.conf

redis-sentinel /etc/redis_sentinel/redis-sentinel_26380.conf

redis-sentinel /etc/redis_sentinel/redis-sentinel_26381.conf

关闭主

验证:


在从的redis-cli中写入slaveof no one就可以摆脱从身份

相关推荐
用户3169353811832 天前
Java连接Redis
redis
倔强的石头_2 天前
《Kingbase护城河》——数据库存储空间全景探测与精细化瘦身实战
数据库
冬奇Lab2 天前
每日一个开源项目(第134篇):Zvec - 阿里开源的嵌入式向量数据库,向量搜索界的 SQLite
数据库·人工智能·llm
ClouGence3 天前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle
无响应de神3 天前
三、用户与权限管理
数据库·mysql
小小工匠3 天前
Redis - 事务机制:能实现 ACID 属性吗
数据结构·redis·性能优化·并发·持久化
麦聪聊数据3 天前
数据服务化时代:企业数据能力输出的核心路径
数据库
shushangyun_3 天前
2026年快消品B2B系统推荐:支持终端门店订货、促销政策自动化的工具?
java·运维·网络·数据库·人工智能·spring·自动化
DARLING Zero two♡3 天前
【MySQL数据库】数据类型与表约束
数据库·mysql
曹牧3 天前
Oracle EXPLAIN PLAN
数据库·oracle