先說結論:linux
不是日誌路徑指定錯誤, 而是啓動redis服務的命令裏, 用了環境變量裏指向的redis版本, 而不是你預期的當前目錄下. 使用./來指定當前目錄下的redis-server, 再啓動 .redis
[root@ngamenl src]# ./redis-server ../redis.confspa
前言: 第一次安裝了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
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'