Redis服务器端口已在使用中

时间:2011-09-14 13:37:03

标签: redis

我正在使用Redis版本2.2.13

jack@ubuntu:~/redis$ src/redis-server
[23900] 14 Sep 14:28:52 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'
[23900] 14 Sep 14:28:52 # Opening port: bind: Address already in use

所以我按照上面的说明尝试

redis-server $HOME/redis/redis.conf

这给了我以下错误:

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 135
>>> 'slave-serve-stale-data yes'
Bad directive or wrong number of arguments

该文件包含以下注释:

# When a slave lost the connection with the master, or when the replication
# is still in progress, the slave can act in two different ways:
#
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
#    still reply to client requests, possibly with out of data data, or the
#    data set may just be empty if this is the first synchronization.
#
# 2) if slave-serve-stale data is set to 'no' the slave will reply with
#    an error "SYNC with master in progress" to all the kind of commands
#    but to INFO and SLAVEOF.

解决

5 个答案:

答案 0 :(得分:91)

我有同样的问题,但我忘了redis仍然存在。如果出现此错误,请尝试以下命令:

redis-cli ping

如果您将PONG作为响应,则Redis正在运行,并且Redis正在使用该端口。

答案 1 :(得分:55)

运行redis-cli ping并获得肯定回复后,只需运行redis-cli shutdown

即可

答案 2 :(得分:9)

我的机器上必须安装另一个版本的redis服务器,我使用以下命令运行它:

$HOME/redis/src/redis-server $HOME/redis/redis.conf

一切似乎都在起作用。

答案 3 :(得分:2)

尝试使用另一个端口并将其设置为daemonize ./redis-server --port 6379 --daemonize yes

答案 4 :(得分:1)

尝试在您的计算机上搜索redis文件夹,以我为例,我的redis-server在另一个应用程序中运行。切换到该目录并运行:

redis-cli ping

如果返回PONG,请运行:

redis-cli shutdown

这应该关闭redis,然后转到您的项目并尝试运行:

redis-server