36

我已按照说明安装 resque,但现在当我尝试使用此命令生成工作人员时,出现连接错误:

$ QUEUE=mailer rake environment resque:work --trace

这是我得到的错误:

连接被拒绝 - 无法连接到 localhost:6379 上的 Redis

4

5 回答 5

55

您是否验证过 redis-server 正在运行?请不要让我剖析以下命令,但您可以在终端中键入:

ps aux | grep redis

然后,您应该会看到如下内容:

redis 13319 0.0 0.0 2884 1056 ? Ss 10:54 0:00 /usr/bin/redis-server /etc/redis/redis.conf

如果它没有运行,我建议发出以下命令:

nohup redis-server &

这将启动一个 redis-server 进程并将其与终端分离。否则,我相信您需要在希望 redis-server 运行的整个过程中将该终端保持打开状态。

(一旦启动它,验证进程是否正在运行总是一个好主意,所以再次使用第一个命令。)

更新:我不确定这是否适用于所有版本,但在 Ubuntu 16.04 上的 Redis Server 3.0.6 上,您也可以发布sudo service redis-server status。你会收到一些详细的输出,所以我不会全部发布,但这可能是我们中的一些人的另一种选择。

于 2012-01-04T17:05:52.007 回答
15

你安装了redis吗?

在 Ubuntu 上安装 REDIS

参考:http ://redis.io/download

  1. 下载、提取和编译 Redis:-

    $ cd ~/Installations
    $ curl -O http://redis.googlecode.com/files/redis-2.2.1.tar.gz
    $ tar xzf redis-2.2.1.tar.gz
    $ cd redis-2.2.1
    $ sudo make
    
  2. 安装 Tcl(工具命令语言)运行时

    $ sudo apt-get install tcl8.5
    
  3. 运行 Redis 服务器

    $ src/redis-server
    [31371] 24 Feb 10:14:03 # Warning: no config file specified, using the default config. In order to   specify a config file use 'redis-server /path/to/redis.conf'
    [31371] 24 Feb 10:14:03 * Server started, Redis version 2.2.1
    [31371] 24 Feb 10:14:03 # WARNING overcommit_memory is set to 0! Background save may  fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
    [31371] 24 Feb 10:14:03 * The server is now ready to accept connections on port 6379
    
于 2011-02-25T19:22:59.573 回答
11

去做就对了:-sudo apt-get install redis-server

于 2015-05-30T13:26:24.297 回答
3

用于redis-server启动服务器,然后用于redis-cli ping测试服务器是否已启动。如果服务器启动,您应该会收到一个 pong。这是直接从文档中获取的。在此处输入链接描述

于 2018-02-27T06:31:50.553 回答
1

您应该使用“127.0.0.1:6379”而不是“localhost:6379”来连接到 redis。所以,无论你想在哪里连接redis,都可以使用redis-server ip。

于 2014-11-27T08:01:32.903 回答