开发者社区> java牛> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

redis开启远程访问

简介: redis默认只允许本地访问,要使redis可以远程访问可以修改redis.conf   打开redis.conf文件在NETWORK部分有说明   ################################## NETWORK ###############################...
+关注继续查看
redis默认只允许本地访问,要使redis可以远程访问可以修改redis.conf
 
打开redis.conf文件在NETWORK部分有说明
 
################################## NETWORK #####################################
 
# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1
 
解决办法:注释掉bind 127.0.0.1可以使所有的ip访问redis
若是想指定多个ip访问,但并不是全部的ip访问,可以bind
 
注意
下面还有个说明
 
# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes
 
 
在redis3.2之后,redis增加了protected-mode,在这个模式下,即使注释掉了bind 127.0.0.1,再访问redisd时候还是报错,如下
 
(error) DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, 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: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
 
修改办法:protected-mode no
若转载请注明出处!若有疑问,请回复交流!

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Redis3.2开启远程访问
Redis3.2开启远程访问 环境 安装环境:win7系统  Redis版本:3.2.100  安装模式:msi文件安装 开启远程访问 Redis安装完之后,在服务中可以看到对应的Redis服务,打开属性,可以看到“可执行文件的路径”是:”D:\Program Files\Redis\redis-server.
1083 0
Centos7 安装Docker,常用命令,设置国内阿里云镜像,并且在docker中安装MySQL、Redis
Centos7 安装Docker,常用命令,设置国内阿里云镜像,并且在docker中安装MySQL、Redis
0 0
Redis分布式缓存学习篇一之安装篇
Redis分布式缓存学习篇一之安装篇
0 0
Docker:第四章:docker配置阿里云镜像加速并且安装mysql以及安装redis和安装ES
Docker:第四章:docker配置阿里云镜像加速并且安装mysql以及安装redis和安装ES
0 0
Redis安装和相关配置
Redis 是完全开源的,遵守 BSD 协议,是一个高性能的 key-value 数据库。 Redis 与其他 key - value 缓存产品有以下三个特点: - Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用。 - Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存储。 - Redis支持数据的备份,即master-slave模式的数据备份。
0 0
Redis安装(单机、主从、哨兵、集群)
Redis安装(单机、主从、哨兵、集群)
0 0
Docker安装tomcat, mysql,redis(单机版)
Docker安装tomcat, mysql,redis(单机版)
0 0
Redis学习10:linux下安装Redis进行基本操作
如果想起多台redis的服务,那么就需要通过这样来启动。
0 0
mac安装Redis可视化工具-Redis Desktop Manager
mac安装Redis可视化工具-Redis Desktop Manager
0 0
+关注
java牛
善于分享,乐于分享
文章
问答
文章排行榜
最热
最新
相关电子书
更多
阿里云Redis容灾体系介绍--夏周
立即下载
阿里云Redis服务助力游戏行业发展--王义成
立即下载
国内开发者与Redis开源社区的发展
立即下载