windows下远程访问Redis,windows Redis绑定ip无效,Redis设置密码无效,Windows Redis 配置不生效,Windows Redis requirepass不生效,windows下远程访问redis的配置
转载:http://fanshuyao.iteye.com/blog/2384074
一、Redis下载地址:
https://github.com/MicrosoftArchive/redis/releases
1、Redis-x64-3.2.100.msi 为安装版
2、Redis-x64-3.2.100.zip 为压缩包
二、由于我使用的是安装版,本次问题也是安装版的问题
1、安装后的目录

2、安装版的Redis安装后服务会自动启动。

三、问题所在:
由于安装版的Redis服务自启动,是直接通过redis-server.exe启动的,但是,启动时并没有加载Redis的配置文件(redis.windows.conf),导致redis 中bind配置和密码设置不生效。这导致我折腾了很久,后来才意识到这个问题。
四、Redis自启动导致的常见的问题有:
1、在CMD命令加载配置文件(redis.windows.conf)进行启动是不成功的。提示如下:
D:\soft\Redis>redis-server.exe redis.windows.conf
[13760] 11 Jul 16:39:51.067 # Creating Server TCP listening socket 127.0.0.1:6379: bind: No error
因为Redis服务已经自启动,这里是不会再新启动的,故加载配置文件是失败的。也没有出现Redis启动的小盒子(下面有图片,慢慢往下看),需要注意的是Windows版的Redis安装时,默认启动加载的配置文件是redis.windows-service.conf,如下图所示:

2、密码失效
虽然在配置文件(redis.windows.conf)设置了密码,密码为123456:
################################## SECURITY ###################################
……省略……
# requirepass foobared
requirepass 123456
但启动客户端进行Redis命令操作时,是不需要密码的,也没有提示无权限操作,这是一个严重的安全问题。
D:\soft\Redis>redis-cli.exe
127.0.0.1:6379> get name
"haha"
127.0.0.1:6379>
3、Redis访问IP绑定(bind)无效
Redis默认绑定的ip为127.0.0.1,但如果想内网的机器都能访问,则需要设置内网的ip地址,如192.168.100.66,然后redis.host则可以设置为192.168.100.66访问Redis。
Redis ip地址绑定默认说明:
################################## 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,只能通过绑定的地址访问Redis。
如果不设置bind,则所有地址都可以访问,如果在项目部署外网,所有人都可以访问到,所以这里也是个注意的地址,还是设置bind比较安全。
绑定多个ip地址:
bind 127.0.0.1 192.168.100.66
127.0.0.1和192.168.100.66之间通过空格分隔,不是逗号。
但如果Redis是自启动的,没有加载配置文件(redis.windows.conf)启动,这里的设置也是无效的。
如果不绑定ip地址(192.168.100.66),直接设置redis.host=192.168.100.66是访问不了的,出现以下的错误:
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
所以说,Redis由Windows自启动的,配置文件(redis.windows.conf)的设置都是无效的
五、解决方案:
1、禁用Redis的自启动,设置为手动
2、不要使用Redis安装版,使用压缩版
3、通过命令行CMD加载配置文件(redis.windows.conf)启动
- D:\soft\Redis>redis-server.exe redis.windows.conf
通过Cmd启动的界面都是不一样的,如下:
看到了正常启动的盒子。
4、再新打开一个cmd(不要关闭之前打的Cmd窗口),启动Redis客户端:
- D:\soft\Redis>redis-cli.exe
5、获取Redis中某个key的值,提示无权限。
127.0.0.1:6379> get name
(error) NOAUTH Authentication required.
127.0.0.1:6379>
这样才是对的。
6、通过密码进入访问,使用 auth + 密码,如下:
127.0.0.1:6379> get name
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> get name
"haha"
127.0.0.1:6379>
如果Redis设置了密码,Spring整合Redis也是需要设置密码的,具体的一些配置:
7、Spring整合Redis的一些配置(JedisPool单机版):
Spring.xml文件配置的JedisPool池:
<bean id="jedisPool" class="redis.clients.jedis.JedisPool">
<constructor-arg name="poolConfig" ref="jedisPoolConfig"></constructor-arg>
<constructor-arg name="host" value="${redis.host}" />
<constructor-arg name="port" value="${redis.port}" type="int" />
<constructor-arg name="timeout" value="${redis.timeout}" type="int" />
<constructor-arg name="password" value="#{'${redis.password}'!=''?'${redis.password}':null}" />
<!-- <constructor-arg name="database" value="${redis.db.index}" type="int" /> -->
</bean>
redis.properties配置文件
- #*****************jedis连接参数设置*********************#
- #redis服务器ip#
- redis.host=192.168.100.66
- #redis服务器端口号#
- redis.port=6379
- #超时时间:单位ms#
- redis.timeout=3000
- #授权密码,没有密码则不设置,但属性要保留#
- redis.password=123456
六、如果不是安装版的Redis,又想让Redis自启动的时候,可以向Windows添加自启动服务:
1、进入到Redis的安装目录
- D:\soft\Redis>
2、执行命令:
- redis-server --service-install redis.windows.conf --loglevel notice --service-name Redis
3、完整示例:
- D:\soft\Redis>redis-server --service-install redis.windows.conf --loglevel notice --service-name Redis
--service-install redis.windows.conf 指定redis配置文件
--loglevel notice 指定日志级别
--service-name Redis 指定服务名称
运行结果如下( Redis successfully installed as a service.):
- D:\soft\Redis>redis-server --service-install redis.windows.conf --loglevel notice --service-name Redis
- [7176] 12 Jul 09:34:50.730 # Granting read/write access to 'NT AUTHORITY\NetworkService' on: "D:\soft\Redis" "D:\soft\Redis\"
- [7176] 12 Jul 09:34:50.730 # Redis successfully installed as a service.
4、安装服务后,默认不是马上启动的,但启动类型是自启动,如果想马上启动,请执行命令:
- redis-server --service-start
- 服务成功启动显示如下:
- [9876] 12 Jul 09:57:41.251 # Redis service successfully started.
或者重启电脑。
停止服务:
- redis-server --service-stop
5、删除Redis服务:
- redis-server --service-uninstall
windows下远程访问Redis,windows Redis绑定ip无效,Redis设置密码无效,Windows Redis 配置不生效,Windows Redis requirepass不生效,windows下远程访问redis的配置的更多相关文章
- windows Redis绑定ip无效,Redis设置密码无效,Windows Redis 配置不生效, Windows Redis requirepass不生效
windows Redis绑定ip无效,Redis设置密码无效,Windows Redis 配置不生效, Windows Redis requirepass不生效 >>>>&g ...
- Windows 下如何设置 只允许固定IP远程访问
通过设置IP安全策略限制固定IP访问 说明: (1)以XP环境为例,步骤:先禁止所有IP,再允许固定IP访问. (2)配置过程中很多步骤图是重复的,一些没价值的图就省略了: (3)光看的话可能中间重复 ...
- redis绑定ip以及启动和查看启动状态
改绑定ip: 或许是对redis的了解还不够多的缘故,单单只是从安装和启动来讲,个人觉得好像是比mongodb和mysql要简单一些. 我的安装包是这个:http://download.csdn.ne ...
- 阿里云服务器redis启动绑定ip 开放端口仍无法访问问题
今天使用云服务器其redis 始终无法访问.redis.conf 这个配置文件也是改了又改.最后发现 执行redis启动命令时没有带上配置文件.仍然使用默认配置. src/redis-server ...
- Windows环境下修改Oracle实例监听IP地址
Windows环境下修改Oracle实例监听IP地址. 配置文件路径:<ORACLE_HOME>\NETWORK\ADMIN 如:C:\Oracle11gR2\product\11.2.0 ...
- 记一次企业级爬虫系统升级改造(六):基于Redis实现免费的IP代理池
前言: 首先表示抱歉,春节后一直较忙,未及时更新该系列文章. 近期,由于监控的站源越来越多,就偶有站源做了反爬机制,造成我们的SupportYun系统小爬虫服务时常被封IP,不能进行数据采集. 这时候 ...
- Windows Server 2012 NIC Teaming 网卡绑定介绍及注意事项
Windows Server 2012 NIC Teaming 网卡绑定介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Window ...
- arp命令(windows ),nmap查看局域网内所有主机IP和MAC
ARP命令详解 ARP是一个重要的TCP/IP协议,并且用于确定对应IP地址的网卡物理地址.实用arp命令,我们能够查看本地计算机或另一台计算机的ARP高速缓存中的当前内容.此外,使用arp命令,也可 ...
- 在windows系统和linux系统中查询IP地址命令的不同
在linux和windows系统上查询IP地址的命令是不一样的. 在linux中的命令行模式下,输入ifconfig即可查询到IP.而在windows系统下要查询IP地址需要先打开do ...
随机推荐
- Duilib第一步(II)-Hello World
My first Duilib program 1. Prepare for development 打开DuiFarm项目DuiFarm.cpp文件,将除_tWinMain函数之外所有内容删除.删除 ...
- 老男孩Python全栈开发(92天全)视频教程 自学笔记16
day16课程内容: 装饰器: def outer(): x=10 def inner(): print(x) return innerouter()() #inner 是局部变量,10闭包:如果在一 ...
- hdu 2553 N皇后
这题要打表,不然超时. AC代码 #include<cstdio> #include<cstring> int n,cnt; int vis[3][20]; int ans[1 ...
- duilib界面库学习(仿PC微信界面,有服务器,有数据库,可以网络通信)
客户端代码:https://github.com/TTGuoying/duilib_ChatClient 服务器代码:https://github.com/TTGuoying/duilib_ChatS ...
- Spark源码编译(未完待续)
在这里我们不需要搭建独立的Spark集群,利用Yarn Client调用Hadoop集群的计算资源. Spark源码编译生成配置包: 解压源码,在根去根目录下执行以下命令(sbt编译我没尝试) ./m ...
- linux 邮件服务器
邮件通信系统协议及概念:软件角色:MUA:邮件客户端MTA:邮件服务端MDA:邮件服务端模块邮件客户端:Mail User Agent,邮件用户代理邮件服务端:Mail Transfer Agent, ...
- JavaScript 使用闭包防止变量污染
javaScript在多人协作时,如果定义过多的全局变量 有可能造成全局变量命名冲突,使用闭包来解决功能对变量的调用 将变量写到一个独立的空间里面 就是闭包里面 var name = "外部 ...
- Array.reduce()学习
昨天遇到的一道题:1234567890 => 1,234,567,890 要求其实就是使用逗号做千分位将数字进行分隔. 当时没想到任何方法,但是以前看到过,印象很深刻,今天就找了一下. 看到其实 ...
- 【linux】linux下能ping通ip 但是不能ping通域名
经过一翻查找后解决了,原因和方法如下: [root@~]# grep host /etc/nsswitch.conf#hosts: db files nisplus nis dnshosts: ...
- am335x在ubuntu下使用StarterWare编写裸机程序并在CCS中用Jlink调试
StarterWare在AM335X上的烧录运行 步骤:1.下载安装StarterWare,我们团购的SK需要02.00.00.07版本.最近外网访问慢,我上传到论坛.2.找一张miniSD卡,不需要 ...