Redis配置文件中关于bind参数

注:此文章内容有误,正确请参考http://blog.csdn.net/hel12he/article/details/46911159


在配置文件redis.conf中,默认的bind 接口是127.0.0.1,也就是本地回环地址。

这样的话,访问redis服务只能通过本机的客户端连接,而无法通过远程连接,
这样可以避免将redis服务暴露于危险的网络环境中,防止一些不安全的人随随便便通过远程
连接到redis服务。
如果bind选项为空的话,那会接受所有来自于可用网络接口的连接。

例子:
比如有两台redis服务器,ip分别为:192.168.1.101和192.168.1.103,如何在101上通过redis-cli访问103上的redis呢?在远程连接103之前,先讲下redis-cli的几个关键参数:

用法:redis-cli [OPTIONS] [cmd [arg [arg ...]]]

-h <主机ip>,默认是127.0.0.1
-p <端口>,默认是6379
-a <密码>,如果redis加锁,需要传递密码

--help,显示帮助信息


当在101上通过redis-cli访问103上的redis时,首先要修改103上的redis.conf文件,在bind下加一行:bind 192.168.1.101
这样103上的redis服务就可以listen来自192.168.1.101的连接。

通过对rendis-cli用法介绍,在101上连接103应该很简单:

[plain]  view plain  cop
  1. [root@xsf001 ~]# redis-cli -h 192.168.1.103 -p 6379  
  2. redis 192.168.1.103:6379>   

官方文档介绍:

Protected mode

Unfortunately many users fail to protect Redis instances from being accessed from external networks. Many instances are simply left exposed on the internet with public IPs. For this reasons since version 3.2.0, when Redis is executed with the default configuration (binding all the interfaces) and without any password in order to access it, it enters a special mode called proteced mode. In this mode Redis only replies to queries from the loopback interfaces, and reply to other clients connecting from other addresses with an error, explaining what is happening and how to configure Redis properly.


评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值