先說結論:
不是日志路徑指定錯誤, 而是啟動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
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'