windows Redis绑定ip无效,Redis设置密码无效,Windows Redis 配置不生效, Windows Redis requirepass不生效...
windows Redis绑定ip无效,Redis设置密码无效,Windows Redis 配置不生效,
Windows Redis requirepass不生效
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
©Copyright 蕃薯耀 2017年7月11日
http://www.cnblogs.com/fanshuyao/
一、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启动的小盒子(下面有图片,慢慢往下看)
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自启动的,配置文件的设置都是无效的
五、解决方案:
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
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
©Copyright 蕃薯耀 2017年7月11日
http://www.cnblogs.com/fanshuyao/
windows Redis绑定ip无效,Redis设置密码无效,Windows Redis 配置不生效, Windows Redis requirepass不生效...相关推荐
- Redis 绑定Ip和设置密码
1.在配置文件redis.conf 中添加 daemonize yes//运行后台启动bind 192.168.0.104 //绑定IP 可以在下面继续绑定默认IP 127.0.0.1 下次 redi ...
- windows 域名绑定ip
有时候访问网站会出现网站拒绝访问的情况,如果知道这个网站的IP,我们可以尝试用域名绑定ip的做法来解决,windows下域名与ip绑定的方式如下: 打开hots文件,路径为C:\Windows\Sys ...
- python 基于UDP协议的socket 报错:WinError 10022 提供了一个无效的参数(原因:服务端没有绑定ip)
如图: 原因: 服务端socket没有绑定ip和端口,绑定一下就好了 udp_server_sock.bind(ip_port) 参考文章:python socket 使用错误:WinError 10 ...
- Redis高可用集群-哨兵模式(Redis-Sentinel)搭建配置教程【Windows环境】
================================================= 人工智能教程.零基础!通俗易懂!风趣幽默!大家可以看看是否对自己有帮助! 点击查看高清无码教程 == ...
- redis 公网ip访问_阿里云Redis公网连接的解决办法
ECS Windows 篇 目前云数据库 Redis 需要通过 ECS 的内网进行连接访问,如果您本地需要通过公网访问云数据库 Redis,可以在 ECS Windows 云服务器中通过 netsh ...
- [CentOS7]redis设置开机启动,设置密码
简介 上篇文章介绍了如何安装redis,但每次重启服务器之后redis不会自启,这里将介绍如何进行自启设置,以及如何设置redis的密码,进行密码验证登陆. 上篇文章: Centos7安装Redis ...
- php redis ip查找,php+redis实现ip白名单并提供可配置ip页面
ip白名单或者黑名单,目的是为了达到一种受限访问,希望在名单内用户可以访问,就把名单叫白名单:希望在名单内用户拒绝访问,就是黑名单.无论我们希望使用哪种名单方式,实现方式都一样. 在nginx下我们通 ...
- windows下 cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”的解决办法
Mask R-CNN学习(三):windows下 cl: 命令行 error D8021 :无效的数值参数"/Wno-cpp"的解决办法 2018年07月20日 11:11:06 ...
- redis 公网ip访问_Redis很重要,怎么只允许指定IP访问?
在 Linux 中安装了redis 服务,当在客户端通过远程连接的方式连接时,报could not connect错误. 错误的原因很简单,就是没有连接上redis服务,由于redis采用的安全策略, ...
最新文章
- 批标准归一化(Batch Normalization)解析
- 抗生素抗性基因研究进展PPT分享
- 再谈querySelector和querySelectorAll
- jfinal上传文件
- html怎么把一段文字设置为连接到下一个网页的按钮,网页设计三合一模拟试题(一)...
- Python学习笔记——GIF倒放处理
- python 除法取模_跟我一起学python | 探究05
- The P4 Language Specification v1.0.2 Parser
- Python实现Word文档翻译
- 互联网平台掘金三四五线城市,你需要知道的9.9个真相
- 刚斩获头条美团的offer,Java开发面试题详解(带答案)
- matlab生成的fig文件名字修改
- python中的xbari表示_R语言实现Xbar-R控制图
- 软件工程(C编码实践篇)学习总结
- 联想y430p黑苹果之自定义屏幕亮度
- 鱼眼畸变矫正-S样板图处理小记
- 数学物理方法·基础③复数基本运算法则
- 【JS】307- 复习 Object.assign 原理及其实现
- 探讨“对称数”的判断算法
- 到了2023年,PMP项目管理师证书含金量会如何?考试难度大么?
热门文章
- 函数调用栈 剖析+图解
- 纯 CSS 实现三角形尖角箭头的实例
- Xshell利用Xftp传输文件,使用pure-ftpd搭建ftp服务
- 《中国人工智能学会通讯》——8.2 自然界中的鸽群导航行为
- Qt Charts基本组成
- Zabbix监控 之 OID动态索引
- asp.net中将Excel文件(.xls)绑定到DataGrid
- android 单选框 icon,Android中的普通对话框、单选对话框、多选对话框、带Icon的对话框、以及自定义Adapter和自定义View对话框详解...
- yum的方式安装mysql_Linux安装mysql之yum安装方式
- mysql字段获取当前日期格式_mysql数据库,获取当前日期及格式化