利用Jedis远程连接Redis出错解决方案

本文详细介绍了在CentOS 6.9环境下配置Redis 4.0.1版本以支持远程连接的过程。包括调整防火墙设置、修改配置文件、设置密码等步骤。

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

环境:

Redis 4.0.1

CentOS 6.9

jdk1.8

dependencies:commons-pool2-2.4.2;jedis-2.9.0    

 

今天搞了将近一个小时的时间用于排查错误,现将排查步骤记录下来:

一、一般情况下。redis默认端口号6379是不允许进行远程连接的,所以在防火墙中设置6379开启远程服务:

/sbin/iptables -I  INPUT -p tcp  -dport  6379  -j ACCEPT

/etc/rc.d/init.d/iptables save

二、重启redis 

    到安装目录(前提是bin下面有redis.conf,没有就到解压缩出来的包中复制一个)

./redis-cli shutdown

./redis-server redis.conf

三、如果还不行,修改redis.conf文件中的bind 127.0.0.1,将其注释掉 ,并restart redis

四、如果出现

  1.  DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified,   
  2. no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions:   。。。

    那么一般情况下有两种解决方案:

    在redis.conf中:

    1)设置 protected-mode no

    2)设置密码 requirepass  xxxxxx(或者到redis客户端set requirepass xxxxxx);

 

到这里基本上都可以使用了。

 

转载于:https://my.oschina.net/u/3544275/blog/1526818

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值