redis开启远程访问

redis默认只允许本地访问,要使redis可以远程访问可以修改redis.conf

打开redis.conf文件在 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

Original: https://www.cnblogs.com/Gyoung/p/6678702.html
Author: Gyoung
Title: redis开启远程访问

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/529192/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • Docker-资源限制(Cgroup)

    Docker-资源限制 1.Cgroup简介 _cgroups,是一个非常强大的linux内核工具,他不仅可以限制被namespace隔离起来的资源,还可以为资源设置权重、计算使用…

    Linux 2023年6月13日
    087
  • 总结

    门诊:11张 张张是主表,主表之王是患者信息住院:12张 张张由入院登记开始,外挂处方点评一张电子病历:12张 病历概要打头来,紧接门(急)病历,急诊留观放尾中,住院病历放最后检验…

    Linux 2023年6月13日
    0117
  • 在 IconFont 上获取图标资源的操作方法与感悟

    如何在 IconFont 上获取图标资源 阿里巴巴矢量图标库网站(https://www.iconfont.cn/)上提供了非常丰富的图标资源,包括 SVG、AI、PNG、字体图标…

    Linux 2023年6月7日
    0116
  • windows环境下启动多个redis服务(搭建redis集群)

    windows环境下启动多个redis服务(搭建redis集群一) 最终效果:本地安装好3个(多个)端口的redis服务。 1.下载并安装Redis 下载地址:https://gi…

    Linux 2023年5月28日
    0102
  • [转] OSDI, SOSP与美国著名计算机系的调查报告

    看到一个很久之前的文章,重新排版后转发一下,希望能带来一些帮助;文章有时效性,出现的数据多为历史数据。资源来源自网络,侵删。 序言 按照USnews的分类,Computer Sci…

    Linux 2023年6月13日
    0110
  • 分布式系统下的CAP定理

    本文参考EricBrewer博客加上自己的理解整理。 CAP定理又被成为布鲁尔定理,是加州大学计算机科学家埃里克·布鲁尔提出来的猜想,后来被证明成为分布式计算领域公认的定理。 CA…

    Linux 2023年6月13日
    097
  • 我叫MongoDb,不懂我的看完我的故事您就入门啦!

    这是mongo基础篇,后续会连续更新4篇 大家好我叫MongoDb,自从07年10月10gen团队把我带到这个世界来,我已经13岁多啦,现在越来越多的小伙伴在拥抱我,我很高兴。我是…

    Linux 2023年6月14日
    0132
  • lambda跨账号调用elasticache redis调查结果

    1.本地lambda与被调用方的redis都要绑定一个VPC,至少设定一个子网和路由表,设定好安全组; 2.本地VPC创建对等连接,被调用方接受连接; 3.将各自的IPv4 CID…

    Linux 2023年5月28日
    079
  • 原码反码补码

    3.1 知识点补充 在计算机内部,所有信息都是用二进制数串的形式表示的。整数通常都有正负之分,计算机中的整数分为无符号的和带符号的。无符号的整数用来表示0和正整数,即自然数;带符号…

    Linux 2023年6月13日
    0113
  • C++的回调函数

    一、简介 本文主要介绍C++中如何使用回调函数。 二、回调函数介绍 回调函数主要在”回”字,和正常的函数调用方式不太一样。正常的函数由开发者自己定义返回类型…

    Linux 2023年6月7日
    0107
  • linux的启动流程详解

    linux启动流程 一、第一阶段:BIOS 上个世纪70年代初,”只读内存”(read-only memory,缩写为ROM)发明,开机程序被刷入ROM芯片…

    Linux 2023年6月7日
    091
  • Linux系统卡死后紧急处理

    前言:Linux系统卡死了的情况有很多,最常见的是系统负载过高导致的。还可以运行内存耗用极大的程序(如虚拟机),也会迅速提升系统负载。注意:不能再试图依赖任何图形界面的东西,如 G…

    Linux 2023年6月7日
    0108
  • CentOS7 源码安装Nginx及Nginx基本管理设置

    CentOS7 安装 参考文档 CentOS7最小安装后初始化安装工具 1:yum install net-tools 参考文档 2:源码安装wget 参考文档 或者执行 yum …

    Linux 2023年5月27日
    0124
  • 华为IPv6 GRE隧道

    IPv6 over IPv4 GRE封装隧道 实验目标: 该实验参考了华为官网案例配置https://support.huawei.com/enterprise/zh/doc/ED…

    Linux 2023年6月7日
    090
  • docker容器编排原来这么丝滑~

    前言: 请各大网友尊重本人原创知识分享,谨记本人博客:南国以南i 概念介绍: Docker 这个东西所扮演的角色,容易理解,它是一个容器引擎,也就是说实际上我们的容器最终是由Doc…

    Linux 2023年6月14日
    0106
  • k8安装

    1.安装k8s之前需要安装docker,etcd 因为要在k8s的pod中运行容器,需要先安装 容器运行时(Container Runtimes ) 几种常见的容器运行时与 Kub…

    Linux 2023年6月13日
    0101
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球