1. 程式人生 > 實用技巧 >redis配置修改後不生效的原因

redis配置修改後不生效的原因

通過編譯安裝redis之後,修改配置檔案之後,發現裡面的配置不生效?

原因是:當我們在啟動redis的時候,需要加上redis.conf的配置檔案一起

我的redis-server在/usr/local/bin/redis-server ,然後配置檔案在/opt/redis-4.0.10/redis.conf

因此,啟動redis這樣啟動,才能生效配置檔案:

/usr/local/bin/redis-server /opt/redis-4.0.10/redis.conf

當以守護程序的方式啟動了redis之後,開啟session,連線redis:

redis-cli
# 報錯:
Could not connect to Redis at 
127.0.0.1:6379: Connection refused Could not connect to Redis at 127.0.0.1:6379: Connection refused # 通過ip和埠連線-配置檔案中設定的 redis-cli -h 192.168.6.128 -p 6379 ping # 不同,需要輸入密碼 (error) NOAUTH Authentication required. auth admin(admin是自己設定的密碼) # OK ping # 返回PONG 即可

詳情:

# Note that in order to read the configuration file, Redis must be
# started with the file path 
as first argument: # # ./redis-server /path/to/redis.conf

此外:停止redis命令是:

/usr/local/bin/redis-cli shutdown