redis 安装问题汇总

问题:

1  连接失败  

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect

需要关闭服务器防火墙 

查看防火墙状态:
/etc/init.d/iptables status
暂时关闭防火墙:
/etc/init.d/iptables stop
禁止防火墙在系统启动时启动
/sbin/chkconfig --level 2345 iptables off
重启iptables:
/etc/init.d/iptables restart


2  Redis连接报错:DENIED Redis is running in protected mode because protected mode is enabled

Redis目前处于受保护模式,不允许非本地客户端链接,可以通过给redis设置密码,然后客户端链接的时候,写上密码就可以了

127.0.0.1:6379> config set requirepass 123456
OK
127.0.0.1:6379> 
 
 
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

客户端连接代码如下:

public static void main(String[] args) {
        Jedis jedis = new Jedis("ip地址",6379);
        jedis.auth("123456");
        String keys = "name";
        jedis.del(keys);
        jedis.set(keys, "aaaaa");
        String value = jedis.get(keys);
        System.out.println(value);
    }


3  MISCONF redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

大意为:(错误)misconf redis被配置以保存数据库快照,但misconf redis目前不能在硬盘上持久化。用来修改数据集合的命令不能用,使用日志的错误详细信息


这是由于强制停止redis快照,不能持久化引起的,运行info命令查看redis快照的状态,如下:


解决方案如下:

运行 config set stop-writes-on-bgsave-error no 命令

关闭配置项stop-writes-on-bgsave-error解决该问题。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值