我按照安装 Resque 的说明进行了操作,但现在当我尝试使用这个命令启动一个 worker 时,出现连接错误:
$ QUEUE=mailer rake environment resque:work --trace
我得到的错误信息如下:
连接被拒绝 - 无法连接到本地主机的 Redis 6379 端口
我按照安装 Resque 的说明进行了操作,但现在当我尝试使用这个命令启动一个 worker 时,出现连接错误:
$ QUEUE=mailer rake environment resque:work --trace
我得到的错误信息如下:
连接被拒绝 - 无法连接到本地主机的 Redis 6379 端口
您是否已验证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
命令。您将收到一些冗长的输出,因此我将不会全部发布,但对于我们中的一些人来说,这可能是另一个选项。
你已经安装了redis吗?
在Ubuntu上安装REDIS
下载、提取并编译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
安装 Tcl(工具命令语言)运行时
$ sudo apt-get install tcl8.5
运行 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
只要做就行了:- sudo apt-get install redis-server
在连接Redis时,应该使用"127.0.0.1:6379"而不是"localhost:6379"。因此,无论您想在哪里连接Redis,都应该使用redis-server的IP地址。