去掉redis的保护模式
时间:2021-08-08
本文章向大家介绍去掉redis的保护模式,主要包括去掉redis的保护模式使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
照着书本,学习node.js连接redis,报告下述错误
$ npm start
> 4-2-1@0.0.0 start C:\Users\DW\Dev\Study\web\nodejs\4-2-1
> node ./bin/www
events.js:377
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on RedisClient instance at:
at RedisClient.on_error (C:\Users\DW\Dev\Study\web\nodejs\4-2-1\node_modules\redis\index.js:342:14)
at Socket.<anonymous> (C:\Users\DW\Dev\Study\web\nodejs\4-2-1\node_modules\redis\index.js:223:14)
at Socket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 4-2-1@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 4-2-1@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
看上去是拒绝连接了,原因未知。
在redis-server上抓包:
[root@centos7 ~]# tcpdump -i eth0 -enn tcp port 6379
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
14:35:02.970452 00:15:5d:4d:52:87 > 00:15:5d:03:2e:01, ethertype IPv4 (0x0800), length 66: 172.17.160.1.61874 > 172.17.161.191.6379: Flags [S], seq 1228743096, win 64240, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
14:35:02.970531 00:15:5d:03:2e:01 > 00:15:5d:4d:52:87, ethertype IPv4 (0x0800), length 66: 172.17.161.191.6379 > 172.17.160.1.61874: Flags [S.], seq 2651139702, ack 1228743097, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0
14:35:02.971013 00:15:5d:4d:52:87 > 00:15:5d:03:2e:01, ethertype IPv4 (0x0800), length 54: 172.17.160.1.61874 > 172.17.161.191.6379: Flags [.], ack 1, win 8212, length 0
14:35:02.971441 00:15:5d:03:2e:01 > 00:15:5d:4d:52:87, ethertype IPv4 (0x0800), length 1155: 172.17.161.191.6379 > 172.17.160.1.61874: Flags [P.], seq 1:1102, ack 1, win 229, length 1101: RESP "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."
14:35:02.971592 00:15:5d:03:2e:01 > 00:15:5d:4d:52:87, ethertype IPv4 (0x0800), length 54: 172.17.161.191.6379 > 172.17.160.1.61874: Flags [F.], seq 1102, ack 1, win 229, length 0
14:35:02.972053 00:15:5d:4d:52:87 > 00:15:5d:03:2e:01, ethertype IPv4 (0x0800), length 54: 172.17.160.1.61874 > 172.17.161.191.6379: Flags [.], ack 1103, win 8208, length 0
14:35:02.982617 00:15:5d:4d:52:87 > 00:15:5d:03:2e:01, ethertype IPv4 (0x0800), length 68: 172.17.160.1.61874 > 172.17.161.191.6379: Flags [P.], seq 1:15, ack 1103, win 8208, length 14: RESP "info"
14:35:02.982685 00:15:5d:03:2e:01 > 00:15:5d:4d:52:87, ethertype IPv4 (0x0800), length 54: 172.17.161.191.6379 > 172.17.160.1.61874: Flags [R], seq 2651140805, win 0, length 0
这里就很清晰了,指定启动redis时,指定 --protected-mode no
选项即可。
$ npm start
> 4-2-1@0.0.0 start C:\Users\DW\Dev\Study\web\nodejs\4-2-1
> node ./bin/www
Hello Redis
原文地址:https://www.cnblogs.com/dw86/p/15114890.html
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法