原文:【redis】redis的bind配置

在配置文件redis.conf中,默认的bind 接口是127.0.0.1,也就是本地回环地址。这样的话,访问redis服务只能通过本机的客户端连接,而无法通过远程连接,

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

在使用redis的时候出现连接不成功;

在项目中导入jar包jedis-2.7.2.jar,编写测试类

    @Testpublic void testJedisSingle() throws Exception {//创建一个jedis对象Jedis jedis = new Jedis("192.168.64.129",6379);jedis.set("test", "hello jedis");String string = jedis.get("test");System.out.println(string);jedis.close();}

根据redis.conf配置文件中bind的值的不同,出现不同的提示信息;但是不影响Linux系统中redis的正常使用;

当不存在bind时

redis.clients.jedis.exceptions.JedisDataException: 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.

当bind 本机ip地址时

代码可以测试通过,但是Linux系统中出现问题

[root@root redis]# ./bin/redis-cli -c
  Could not connect to Redis at 127.0.0.1:6379: Connection refused
  Could not connect to Redis at 127.0.0.1:6379: Connection refused

当bind 为默认的127.0.0.1时

代码测试不通过

redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect

Linux中操作正常

目前采用的方式,代码和Linux中的redis客户端都可以使用

1.在bind中配置多个IP地址,bind 192.168.64.129 127.0.0.1

2.将bind的值配置为bind 0.0.0.0

【redis】redis的bind配置相关推荐

  1. redis sentinel集群配置及haproxy配置

    ip分布情况: sentinel-1/redis 主 10.11.11.5 sentinel-2/redis 从 10.11.11.7 sentinel-3/redis 从 10.11.11.8 ha ...

  2. Redis安装及基本配置

    一.Redis介绍 1.Redis是一个key-value存储系统 2.官方站点http://redis.io 3.Redis和Memcached类似,但支持数据持久化 4.支持更多value类型,除 ...

  3. Linux下Redis的安装、配置操作说明

    Redis 是一个高性能的key-value数据库. redis的出现,很大程度补偿了memcached这类keyvalue存储的不足,在部分场合可以对关系数据库起到很好的补充作用.它提供了Pytho ...

  4. redis logfile 只读_docker 配置redis主从,哨兵sentinel

    注释:docker自行安装,主从使用一主两从,然后使用sentinel进行高可用配置,当主服务器挂掉,从服务器自动升为主服务器. 主从模式介绍 主从模式是三种模式中最简单的,在主从复制中,数据库分为两 ...

  5. 1 企业实战(3) Redis服务部署和配置详解 (资源)

    前言: 环境介绍: CentOS 7.5 Redis 5.0.0 gcc 下载: http://download.redis.io/releases/ 安装redis: [root@localhost ...

  6. redis应用之安装配置介绍

    一.redis介绍: 1.redis定义: Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年3月1 ...

  7. Redis——redis配置与优化

    文章目录 一.关系数据库与非关系型数据库 1.关系型数据库 2.非关系型数据库 二. Redis 简介 1.Redis的应用场景 2.Redis的优点 三.Redis 安装部署 1.安装Redis 2 ...

  8. mac使用Homebrew安装redis、mysql并配置

    mac使用Homebrew安装redis.mysql 安装Homebrew 安装Homebrew 校验安装 Homebrew基本使用 安装redis 开始安装 查看安装redis后的路径及配置文件位置 ...

  9. redis.conf 7.0 配置和原理全解,生产王者必备

    我是 Redis, 当程序员用指令 ./redis-server /path/to/redis.conf 把我启动的时候,第一个参数必须是redis.conf 文件的路径. 这个文件很重要,就好像是你 ...

  10. redis集群yml配置lettuce

    在springboot中使用redis很方便,只要在yml配置好reids的相关配置项就可以直接使用. 无论是单实例还是集群,都能配置: spring:application:name: gatere ...

最新文章

  1. linux系统命令学习系列-文件和目录管理
  2. 拼多多,一面,i++ 是线程安全的吗?一脸蒙逼
  3. java服务端的 极光推送
  4. 数字图像处理系统组成 及研究内容
  5. 语言列表导出xlxs_学习五分钟,掌握一种新语言。
  6. python合并多个pdf_python合并多个pdf文件
  7. cookie和session、web服务工作原理、Apache配置php扩展、php简介
  8. azure云数据库_从Azure Databricks将数据加载到Azure SQL数据库
  9. access里面的表达式运用_Access表达式
  10. c语言 数据结构面试题及答案,数据结构c语言版试题大全(含答案).docx
  11. 如何反编译dll,并生成新的dll
  12. html5页面关闭的回调函数,js回调函数例子 js 回调函数问题的执行结果想作为返回值...
  13. Cisco Packet Tracer---链路聚合简单配置
  14. php集成paypal付款流程,PHP整合PayPal支付_PHP教程
  15. AI视觉传感器作用和应用介绍
  16. 一文带你重新审视CAP理论与分布式系统设计
  17. gallery3D(3)
  18. 【1、雅思听力】何琼口语学习记录 第2节
  19. Lemon评测机的使用
  20. 陪审团问题_Oraclevs谷歌–陪审团僵局? 部分裁决? str?

热门文章

  1. ubuntu下安装 Source insight
  2. Solr进阶之Solr综合文本相似度的多因素权重排序实现
  3. Python datetime 格式化字符串:strftime()
  4. 在写易买网时产生的错误 JSTL标签库中c:choose/c:choose不能放JSP页面!-- --注释...
  5. 修改tomcat的部署名称
  6. com线程模型实验之三
  7. Nginx 安装与运行
  8. 记录.NET Core部署到Linux之.NET Core环境搭建(1)
  9. Ubuntu18.04安装
  10. Choosing Capital for Treeland codeforce 219-D