1. 程式人生 > 其它 >學習隨筆——虛擬機器安裝redis出現的小問題解決

學習隨筆——虛擬機器安裝redis出現的小問題解決

技術標籤:redis

一、前言

之前使用redis都是在本機安裝,本機使用。這次在虛擬機器安裝redis並連線成功,踩了一些之前沒踩過的坑,特此記錄一下。

二、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在保護模式下執行,無法連線。並給出了四個解決方案。
這四個解決方案其實是用不同的方式把保護模式關閉。
這裡我直接修改redis的配置檔案,將如下欄位的值修改為no

protected-mode no

三、執行主機

在修改為非保護模式執行後,再次測試依然無法連線。
Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.74.128:6379
這次直接是無法連線主機埠,使telnet測試跳轉埠,也是無法連線。在這裡插入圖片描述


首先確認防火牆關閉後啟動redis。
其次檢視配置檔案,將如下欄位修改為(預設值為127.0.0.1)

bind 0.0.0.0