Redis启动报错: Bad directive or wrong number of arguments

先说结论:

  不是日志路径指定错误, 而是启动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        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                  
|    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                                

猜你喜欢

转载自www.cnblogs.com/ngamenl/p/12204588.html