Redis3.2开启远程访问详细步骤

 更新时间:2018年03月04日 10:00:08   投稿:wdc  
redis默认只允许本地访问,要使redis可以远程访问可以修改redis.conf

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

使redis可以远程访问只要注释掉redis.conf配置文件中的 bind 127.0.0.1 即可以使所有的ip访问redis

若是想指定多个ip访问,但并不是全部的ip访问,可以bind多个IP

注意

在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 yes为protected-mode no

保存配置文件重启redis即可

相关文章

  • Redis中常见的几种集群部署方案

    Redis中常见的几种集群部署方案

    本文主要介绍了Redis中常见的几种集群部署方案,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-03-03
  • 详解Redis如何多规则限流和防重复提交

    详解Redis如何多规则限流和防重复提交

    市面上很多介绍redis如何实现限流的,但是大部分都有一个缺点,就是只能实现单一的限流,但是如果想一个接口两种规则都需要满足呢,使用本文就来介绍一下redis实现分布式多规则限流的方式吧
    2023-12-12
  • 如何打造redis缓存组件

    如何打造redis缓存组件

    文章介绍了如何使用热插拔AOP、反射、Redis自定义注解和SpringEL表达式来打造一个优雅的Redis缓存组件,通过这种方式,可以重构和简化缓存代码,并提供了Redis配置和自定义注解的详细说明,文章还包含了AOP测试的总结,并鼓励读者参考和支持
    2024-12-12
  • Redis缓存高可用集群详解

    Redis缓存高可用集群详解

    Redis集群提供了哨兵模式和高可用集群模式两种方案,前者适合低并发,配置复杂,主从切换可能导致瞬断;后者通过多主多从结构提高可用性和性能,支持线性扩展,配置简单,搭建Redis集群至少需要三个主节点
    2024-10-10
  • redis-copy使用6379端口无法连接到Redis服务器的问题

    redis-copy使用6379端口无法连接到Redis服务器的问题

    这篇文章主要介绍了redis-copy使用6379端口无法连接到Redis服务器的问题的相关资料,需要的朋友可以参考下
    2023-05-05
  • windows上修改redis端口号的操作步骤

    windows上修改redis端口号的操作步骤

    redis是一个开源的内存数据结构存储系统,常用做数据库、缓存和消息代理,默认的端口号为6379,那么如何在windows上修改redis端口号,接下来本文给大家详细介绍了windows上修改redis端口号的操作方法,需要的朋友可以参考下
    2024-02-02
  • 缓存替换策略及应用(以Redis、InnoDB为例)

    缓存替换策略及应用(以Redis、InnoDB为例)

    本文以Redis、InnoDB为例给大家讲解缓存替换策略及应用,本文给大家提到五种置换策略,通过实例代码给大家介绍的非常详细,需要的朋友参考下吧
    2021-07-07
  • Redis哨兵模式介绍

    Redis哨兵模式介绍

    这篇文章介绍了Redis哨兵模式,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2022-02-02
  • 解决Redis报错MISCONF Redis is configured to save RDB snapshots

    解决Redis报错MISCONF Redis is configured to save RDB snap

    这篇文章主要给大家介绍了关于如何解决Redis报错MISCONF Redis is configured to save RDB snapshots的相关资料,文中通过代码介绍的非常详细,需要的朋友可以参考下
    2023-11-11
  • 利用Redis如何实现自动补全功能

    利用Redis如何实现自动补全功能

    这篇文章主要给大家介绍了关于如何利用Redis如何实现自动补全功能的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用Redis具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
    2019-09-09

最新评论