远程启动Redis,报错不能配置键空间通知(keyspace notifications)

本文详细介绍了如何解决Spring Session在使用Redis时遇到的通知配置错误。通过调整redis.conf配置文件、sentinel.conf设置及正确启动Redis服务的方法,最终解决了无法启用keyspace notifications的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

启动服务器上面的redis,报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Unable to configure Redis to keyspace notifications. See http://docs.spring.io/spring-session/docs/current/reference/html5/#api-redisoperationssessionrepository-sessiondestroyedevent

在网上找了好久的原因

1.redis.conf文件中修改  bind为0.0.0.0,

2.

 1、修改reids配置文件(redis.conf)
        redis默认不会开启keyspace notifications,因为开启后会对cpu有消耗
        备注:
            E:keyevent事件,事件以__keyevent@<db>__为前缀进行发布;
            x:过期事件,当某个键过期并删除时会产生该事件;
        配置如下:
            notify-keyspace-events "Ex"

3.sentinel.conf中加入    protected-mode no

然而都不管用 ,依然报之前的错

最后在启动redis的时候用命令  redis-server ../redis.conf   即在原来的命令后面加上配置文件,然后可以了!!

  1. pro
  2. tected-mode no  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值