本地redis切至云平台redis失败
错误内容
将本地docker中运行的redis切至云平台redis,提示报错
org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR config set not open due to security
原因
云平台处于安全考虑,可能会禁用redis的congfig set命令;所以对于redis的参数修改只能通过平台的参数设置对固定参数进行修改;
后又出现报错
enableRedisKeyspaceNotificationsInitializer' defined in class path resource
报错原因
在Java代码中,我们使用了注解:
- @EnableRedisHttpSession,这个注解是用来开启Redis来集式式管理Session。
而在使用这种方式的时候,是需要Redis开启Keyspace Notifications功能的,默认是关闭的。(由于此功能会消耗cpu,所以默认关闭)
这个功能有一个参数来控制它,notify-keyspace-events,值为Egx。可以通过在Redis.Config中配置。也可以通过命令行来配置,如下所示:
redis-cli config set notify-keyspace-events Egx
然后重启Redis生效。