网站 ip pv,宁波网站推广运营,wordpress 调用略缩图,一个空间怎么做两个网站 跳转在写《Redis怎样保证数据安全#xff1f;》这篇文章#xff0c;我是有对redis设置密码需要哪些步骤#xff0c;设置密码的性能损耗有验证的。这就涉及到要对redis的配置做修改。 开始时我是打算采用直接使用redis配置文件的方式。所以我从redis官网下载了一个默认的配置文件… 在写《Redis怎样保证数据安全》这篇文章我是有对redis设置密码需要哪些步骤设置密码的性能损耗有验证的。这就涉及到要对redis的配置做修改。 开始时我是打算采用直接使用redis配置文件的方式。所以我从redis官网下载了一个默认的配置文件就打算只将这个配置文件的requirepass注释打开设置一个密码。 redis我用docker启动如果 docker run -p 6379:6379 --name ai-redis -v c:/docker/redis.conf:/etc/redis/redis.conf -d redis/redis-stack-server redis-server /etc/redis/redis.conf 使用本机的redis.conf文件拷贝一份到docker容器中启动docker里可以正常运行用docker内的redis-cli可以正常访问服务端但是使用主机的java程序访问就会报 Unexpected end of stream.; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream. 我到咱们「编程一生」用户交流群里问出了我的问题。咱们群里的朋友提示我说telnet 可以验证下redis响应 我其实在他说之前是验证过的当时telnet没有反应。既然人家说了我就又试了一下。其实这次测试的配置和上次不一样了。我为了测试是不是我redis.conf文件的格式或者编码有问题。redis.conf直接弄了一个空文件自然也是没有密码的。这时候给出了下面的提示java客户端连提示和telnet的是一样的 DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. 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) Set up an authentication password for the default user. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside. 这么具体的问题第一反应当然是问AI工具了。AI给了这个答案 您所描述的信息是Redis的一个安全特性。当Redis在没有设置密码的情况下运行时它会进入保护模式protected mode。在这种模式下Redis仅接受来自本地回环接口loopback interface的连接这通常意味着只能从运行Redis的同一台机器上进行连接。这是为了防止未经授权的外部访问。 如果您希望从外部计算机连接到Redis您有几个选择 禁用保护模式您可以通过在本地回环接口上连接到Redis并发送命令CONFIG SET protected-mode no来禁用保护模式。但是请注意这会增加安全风险因为任何能够访问Redis服务器的机器都可以进行连接除非您还实施了其他安全措施如防火墙规则。设置密码您可以在Redis配置文件中设置密码方法是修改requirepass字段。例如在redis.conf文件中您可以添加或修改以下行requirepass your_strong_password然后您需要重启Redis服务器以使更改生效。设置密码后您需要在连接到Redis时提供该密码。 根据提示redis配置改成不允许本地接口外运行 protected-mode yes。同样docker里可以正常运行。但从客户端连接结果是 ERR AUTH password called without any password configured for the default user. Are you sure your configuration is correct? 另外一个朋友提示我抓包看一下我就犯愁犯懒了。我是在windows上做的验证默认不能使用tcmpdump。我是安装了wireshark的。wireshark貌似只能抓tcp和udp协议的包不支持redis协议。有朋友能给点思路对我这种懒人在这种情况下怎么抓包吗 但是根据目前的情况Redis仅接受来自本地回环接口loopback interface的连接我想到了bind的配置 实际验证默认bind是127.0.0.1。手动加上 bind 0.0.0.0 问题解决。回归验证时我建立了一个空redis.conf只有两样配置也同样验证问题解决 但实际上这个问题与我真正的验证目标对redis设置密码需要哪些步骤设置密码的性能损耗做验证是跑题的。 所以当时我并没有先全力去解决这个问题而是使用了另外一种验证方式不使用redis.conf文件而是启动参数里直接指定参数先验证了真正的目标之后再来解决的。启动参数如下 docker run -p 6379:6379 --name ai-redis -d redis/redis-stack-server redis-server --requirepass 123456 --protected-mode yes 之后我重新看了一下群里的聊天记录 群里朋友都给出我正确答案了我没有领会到 总结 总结一下本次排查的过程步骤 我的整个排查过程使用的是《性能之巅》里介绍的科学法。 科学法采用以下框架问题-假设-预测-实验-分析。在分析过程中可以有效利用各种资源AI技术、网上资料、仔细阅读Redis的错误提示咨询群里的朋友。此外在验证问题的过程中不要因为新的问题迷失了原本的目标这里就根据具体目标和问题特点采取合适的验证方法如直接指定启动参数来验证目标。