【REdis】如何让Redis能供外界访问

【前篇】

 https://www.cnblogs.com/heyang78/p/15962970.html

【Deny提示】

如果没有进行设置,redis只能本机操作,从外界访问您迟早会看到下列文字:

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.

因此,不进行设置还不行。

【修改redis.conf文件】

vi redis.conf

将bind 127.0.0.1 -::1 一句屏蔽掉,变成 #bind 127.0.0.1 -::1

将protected-mode yes 改写成 protected-mode no

daemonize no一句,保持,如果是yes请改为no

【运行redis】

[hy@localhost ~]$ cd redis-6.2.6
[hy@localhost redis-6.2.6]$ ls
00-RELEASENOTES  COPYING   MANIFESTO   runtest-cluster    src
BUGS             deps      README.md   runtest-moduleapi  tests
CONDUCT          INSTALL   redis.conf  runtest-sentinel   TLS.md
CONTRIBUTING     Makefile  runtest     sentinel.conf      utils
[hy@localhost redis-6.2.6]$ vi redis.conf
[hy@localhost redis-6.2.6]$ cd src
[hy@localhost src]$ ./redis-server ../redis.conf

前面是步骤,粗体是关键。

此后,外界访问redis的路径便通达了。

END

 

posted @ 2022-03-04 10:34  逆火狂飙  阅读(558)  评论(0)    收藏  举报
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东