在Ubuntu14.04中的Redis服务器:绑定地址已被使用

85

我在Ubuntu终端中输入以下命令以启动Redis服务器:$redis-server

这将导致以下结果 > http://paste.ubuntu.com/12688632/

aruns ~ $ redis-server
27851:C 05 Oct 15:16:17.955 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
27851:M 05 Oct 15:16:17.957 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
27851:M 05 Oct 15:16:17.957 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
27851:M 05 Oct 15:16:17.958 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
27851:M 05 Oct 15:16:17.958 # Creating Server TCP listening socket *:6379: bind: Address already in use

我该如何解决这个问题,是否有手动或自动的过程来修复这个绑定。

17个回答

143
$ ps aux | grep redis

找出它运行的端口号... 在我的情况下...

MyUser  8821   0.0  0.0  2459704    596   ??  S    4:54PM   0:03.40 redis-server *:6379

然后手动关闭端口

$ kill -9 8821
重新运行 Redis。
$ redis-server

10
直接使用 killall redis-server 更简单。 - timthedev07
5
“sudo service redis-server stop”这个命令对我有效。 - Aditya Singh

135
sudo service redis-server stop

3
这个对我非常有效。我只是不知道为什么?它和“killall redis-server”有什么不同? - Vlad Hondru
3
我尝试了所有的方法,只有这一个在Ubuntu上有效。 - Paul Jurczyk
谢谢你,太棒了,对我很有效! - Youssef_Ayman168

33

我在Mac上解决了这个问题,只需键入redis-cli shutdown,然后重新打开终端并键入redis-server即可。


17

对我来说,在遇到许多问题后,这解决了我的问题:

 root@2c2379a99b47:/home/ ps -aux | grep redis
    redis     3044  0.0  0.0  37000  8780 ?        Ssl  14:59   0:00 /usr/bin/redis-server *:6379  

发现Redis后,杀掉它!

root@2c2379a99b47:/home# sudo kill -9 3044
root@2c2379a99b47:/homek# sudo service redis-server restart
Stopping redis-server: redis-server.
Starting redis-server: redis-server.
root@2c2379a99b47:/home# sudo service redis-server status 
redis-server is running

12
这对我有效:
$ killall redis-server

将所有东西组合成一行:

$ killall redis-server; redis-server

9

正如所说的那样,该进程已经在运行中,因此最好的方法是停止它、分析它并重新启动它,要执行此操作,请使用以下命令:

redis-cli ping #should return 'PONG'

这解决了我的问题:

$ ps -ef |grep redis

root      6622  4836  0 11:07 pts/0    00:00:00 grep redis
redis     6632     1  0 Jun23 ?        04:21:50 /usr/bin/redis-server *:6379

定位 Redis 进程并停止它!
$ kill -9 6632
$ service redis restart


Stopping redis-server: [  OK  ]
Starting redis-server: [  OK  ]


$ service redis status

否则,如果所有这些都不起作用,只需尝试键入 redis-cli。 希望能有所帮助 :)

8

我阅读了关于http://www.redis.io的文档,我打开了redis.conf文件来配置redis-server,它位于/etc/redis/redis.conf

$ sudo subl /etc/redis/redis.conf

您可以使用自己选择的编辑器,例如nano、vi、emacs、vim、gedit,而不是sublime编辑器。

在此文件中,我取消了#bind 127.0.0.1行的注释。 因此,现在它是127.0.0.1:6379而不是0.0.0.0:6379

重新启动redis服务器。

$ sudo service redis-server restart

它将说明,服务器已准备好在端口6379上接受连接。

这将启动您的服务器。有关更详细的配置和设置,请参阅Ubuntu上Redis服务器的配置


6

我更喜欢使用命令参数-ef

ps -ef|grep redis

-ef 的意思是:
-A      Display information about other users' processes, including those
         without controlling terminals.
-e      Identical to -A.

-f      Display the uid, pid, parent pid, recent CPU usage, process start
        time, controlling tty, elapsed CPU usage, and the associated com-
        mand.  If the -u option is also used, display the user name
        rather then the numeric uid.  When -o or -O is used to add to the
        display following -f, the command field is not truncated as se-
        verely as it is in other formats.

然后杀死该进程的pid

kill -9 $pid

3

您可以尝试以下步骤安装 Redis 和它的 redis-cli 命令:

1. 在终端中执行$ make命令。

2. 执行$ sudo cp src/redis-cli /usr/local/bin/命令。

3. 最后,您可以使用redis-cli shutdown命令来关闭 Redis。希望这个答案能对您有所帮助。


1

对我来说,在操作系统启动后运行的进程中杀死进程是有效的。为了防止redis在Ubuntu操作系统启动时启动:

sudo systemctl disable redis-server

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接