原文:【redis】redis的bind配置

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

  这样可以避免将redis服务暴露于危险的网络环境中,防止一些不安全的人随随便便通过远程

连接到redis服务。

  如果bind选项为空的话,那会接受所有来自于可用网络接口的连接。

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

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

	@Test
public 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集群配置中的一些细节

    今天在配置Redis集群,用作Tomcat集群的缓存共享.关于Redis集群的配置网上有很多文章,这里只是记录一下我在配置过程中遇到的一些小的细节问题. 1. 关于Protected Mode的问题 ...

  2. Redis学习笔记4-Redis配置详解

    在Redis中直接启动redis-server服务时, 采用的是默认的配置文件.采用redis-server   xxx.conf 这样的方式可以按照指定的配置文件来运行Redis服务.按照本Redi ...

  3. redis主从 以及认证配置

    以前用redis用的很多,各种数据类型用的飞起,算是用得很溜了.不过那都是封装好的方法,自己直接调用.以前的公司比较规范,开发只是开发,很少去做跟运维相关的事情. 换了一份工作,不过这边项目刚开始起步 ...

  4. Redis安装及基本配置

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

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

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

  6. redis的安装与配置

    官网 http://redis.io/download 管理工具 http://docs.redisdesktop.com/en/latest/quick-start/ https://redisde ...

  7. Redis:安装、配置、操作和简单代码实例(C语言Client端)

    Redis:安装.配置.操作和简单代码实例(C语言Client端) - hj19870806的专栏 - 博客频道 - CSDN.NET Redis:安装.配置.操作和简单代码实例(C语言Client端 ...

  8. mac与centos下redis的安装与配置

    前言 最近在用redis,下面简单写一下mac和centos下redis的安装与配置方法. 安装 mac下面 安装命令:brew intall redis 运行命令:brew services sta ...

  9. 最新版redis的安装及配置 linux系统

    1.redis下载 官网地址:https://redis.io/download 百度云地址:链接:http://pan.baidu.com/s/1c1Hu2gK 密码:h17z 2.解压 [root ...

随机推荐

  1. python3 numpy基本用法归纳总结

    安装numpy : pip install numpy numpy数组生成方法总结 In [4]: import numpy as np #使用列表生成一个一维数组 data = [1,2,3,4,5 ...

  2. php取两位小数的几种方法

    php取两位小数的几种方法 一.总结 一句话总结: 1.round   四舍五入 2.sprintf   c语言方式 3.number_format 千分位数字格式化的那个函数 二.php取两位小数的 ...

  3. echarts多条折线图和柱状图实现

    参考链接:echarts官网:http://echarts.baidu.com/原型图(效果图): 图片.png 代码: <!DOCTYPE html> <html> < ...

  4. 今天犯了个小错误:_dataArray.count>1 和_dataArray.count>0搞混淆了

    _dataArray.count>1 和_dataArray.count>0搞混淆了:当数据为一条时,条件不成立.应该_dataArray.count>=1  或者>0   ( ...

  5. WPF 使用鼠标拖动一个控件的实现[2018.7.15]

    原文:WPF 使用鼠标拖动一个控件的实现[2018.7.15] Q:已经把一个Shape和一个TextBlock组合起来放到了一个Grid中,现在想要实现用鼠标拖动这个Grid到任意位置的功能,如何做 ...

  6. SpringBoot集成PageHelper时出现“在系统中发现了多个分页插件,请检查系统配置!”

    近日在项目中使用SpringBoot集成PageHelper后,跑单元测试时出现了"在系统中发现了多个分页插件,请检查系统配置!"这个问题. 如下图所示: org.mybatis. ...

  7. react持续记录零散笔记

    根据 React 的设计,所有的 DOM 变动,都先在虚拟 DOM 上发生,然后再将实际发生变动的部分,反映在真实 DOM上,这种算法叫做 DOM diff 这些生命周期在深入项目开发阶段是非常重要的 ...

  8. JSON.parse(JSON.stringify()) 实现对对象的深度拷贝,从而互不影响

    JSON.parse(JSON.stringify({"key": "value"})) 根据不包含引用对象的普通数组深拷贝得到启发,不拷贝引用对象,拷贝一个字 ...

  9. jvm常用优化方案和方法

    新生代 GC(Minor GC):指发生在新生代的垃圾收集动作,因为 Java 对象大多都具备朝生夕灭的特性,所以 Minor GC 非常频繁,一般回收速度也比较快. 老年代 GC(Major GC ...

  10. sklearn 下距离的度量 —— sklearn.metrics

    1. pairwise from sklearm.metrics.pairwise import pairwise_distance 计算一个样本集内部样本之间的距离: D = np.array([n ...