Linux Redis启用远程连接

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011132987/article/details/79744558

远程程序(例如:telnet 或 redis desktop manager)通过6379访问Linux上Redis。

一:配置redis.conf

bind 127.0.0.1 #这一行注释(说明:bind指的是只有指定的网段才能远程访问这个redis。  注释掉后,就没有这个限制了)。

protected-mode #设置成no(默认是设置成yes的, 防止了远程访问,在redis3.2.3版本后)

二:配置防火墙

1.vim /etc/sysconfig/iptables,添加:

-A INPUT -p tcp -m state --state NeW -m tcp --dport 6379 -j ACCEPT
2.重启防火墙:

service iptables restart
3.查看配置是否生效:

iptables -L


三:重启redis,测试连接

1.重启redis

netstat -tunpl #查看redis进程PID
kill -9 redis进程PID
redis-server redis.conf
2.测试连接

telnet IP地址 6379

四:若仍无法连接,则配置redis.conf设置redis密码:

1.去掉注释并且吧foobared改为自己的密码:

#requirepass foobared

2.重复步骤三

============end==============



猜你喜欢

转载自blog.csdn.net/u011132987/article/details/79744558