Redis Bad directive or wrong number of arguments

原文鏈接:https://www.cnblogs.com/ngamenl/p/12204588.html
先說結論:

不是日誌路徑指定錯誤, 而是啓動redis服務的命令裏, 用了環境變量裏指向的redis版本, 而不是你預期的當前目錄下. 使用./來指定當前目錄下的redis-server, 再啓動 .

[root@ngamenl src]# ./redis-server …/redis.conf

前言: 第一次安裝了redis-4.0.8 不知道是什麼時候把一些命令添加到了linux的環境變量裏:
[root@ngamenl src]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@ngamenl sbin]# cd /usr/local/bin
[root@ngamenl bin]# ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server

之後, 我準備用redis新版本redis-5.0.7, 安裝完成之後嘗試啓動新版本服務報錯:
[root@ngamenl src]# pwd
/opt/redis-5.0.7/src
[root@ngamenl src]# redis-server …/redis.conf
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 324

‘replica-read-only yes’
Bad directive or wrong number of arguments

報錯的意思是, 本次啓動指定的配置文件目錄是錯誤的或者配置文件的參數數量不對.
原因就出在, 第一次安裝redis-4.0.8時, 寫如了環境變量, 執行redis-server時, 會先去查詢環境變量裏有沒有配置這條指令, 發現有(還是舊的4.0.8的). 但是使用的配置文件是5.0.7的, 於是報錯;

解決方法是, 使用./指定爲當前目錄下的redis-server, 直接指定, 不讓系統查redis-server環境變量:
[root@ngamenl src]# ./redis-server …/redis.conf
17461:C 16 Jan 2020 22:22:51.751 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
17461:C 16 Jan 2020 22:22:51.751 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=17461, just started
17461:C 16 Jan 2020 22:22:51.751 # Configuration loaded
.
.-__ ''-._ _.- .. ‘’-._ Redis 5.0.7 (00000000/0) 64 bit
.-.-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.-.|’_.-'| Port: 6379 |-. ._ / _.-' | PID: 17461-._ -._-./ .-’ .-’
|-._-.
-.__.-' _.-'_.-'| |-.
-._ _.-'_.-' | http://redis.io-._ -._-..-’.-’ .-’
|-._-.
-.__.-' _.-'_.-'| |-.
-._ _.-'_.-' |-._ -._-.
.-’_.-’ _.-’
-._-..-’ _.-’
-._ _.-'-.
.-’

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章