原文:【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. shell判断和比较

    http://blog.chinaunix.net/uid-7553302-id-183648.html 1  shell 的$! ,$?, $$,$@ $n        $1 the first ...

  2. 小强的HTML5移动开发之路(29)—— JavaScript回顾4

    一.变量的作用域 javascript脚本的执行过程分为两个阶段: 第一阶段,js引擎()先扫描整个javascript代码.当碰到<script>时,会先创建一个全局的活动对象,将< ...

  3. spring boot打包后在tomcat无法访问静态资源问题

    我的spring boot项目中前端页面的资源引用 我的静态文件夹是 我的application.yml中资源路径配置了 同时我在WebMvcConfig中配置了addResourceHandlers ...

  4. windows 下使用 virtualenv 创建虚拟环境

    virtualenv虚拟环境为每个项目隔离了一套运行类库,不同的项目在各自的虚拟环境中使用不同的类库,避免了将所有类库都安装到系统环境中导致的不同项目需要不同(版本)类库的问题,项目与项目之间的类库依 ...

  5. Windows 7 X64位平台下,VC6调试运行程序,中断调试无法退出

    用VC6在64位Windows7下调试的时候,如果中断(Shift+F5)调试,程序无法退出. 问题描述: 当点击F5开始一个项目的调试时,程序在设置的断点处停止,这时按下Shift+F5后,vc6可 ...

  6. CSS 中的高度百分比

    CSS 中可以使用%来给定指定元素的大小,也就是高度.宽度.margin,padding 等等,但是相信很多人都对百分比表示法的具体含义并不清楚,那么不懂就练,毕竟是检验真理的唯一标准(考研党举个手我 ...

  7. 图像块的访问(填充 padding,步长 stride,窗 Window/kernel/filter)

    无填充是有填充的特例(填充为 1). utilities(matlab)-- 图像分块(image2cols.cols2image)(未填充) 1. 一个图像块 ⇒ 返回一个值 输出矩阵的大小: ou ...

  8. 在嵌入式程序中QT去掉鼠标指针

    在像arm的QT编程当中,一般都是使用触摸来操作,当是我们运行程序的时候会发现总是有个鼠标箭头在那里,下面介绍种方法将其给去掉.这样就漂亮多了.在main()函数加入 #include <QWS ...

  9. numpy 辨异(二) —— np.identity()/np.eye()

    import numpy as np; 两者在创建单位矩阵上,并无区别,两者的区别主要在接口上: np.identity(n, dtype=None):只能获取方阵,也即标准意义的单位阵: np.ey ...

  10. /var/tmp/.oracle 和 oracle listener (监听)的一点理解

    关于 /var/tmp/.oracle 的作用測试 ~---查看 /var/tmp 的权限 [root@lixora var]# ll total 164 ... drwxrwxrwt  3 root ...