我已按照说明安装 resque,但现在当我尝试使用此命令生成工作程序时,出现连接错误:
$ 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
您应该使用“127.0.0.1:6379”而不是“localhost:6379”来连接到redis。 所以,无论你想在哪里连接redis,都使用redis-server ip。
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${spring-data-redis.version}</version>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>${lettuce.version}</version>
</dependency>
如果您使用这种旧方式连接到 Redis,请尝试在 application.properties 中设置 'use-ssl=false'
redis.host=localhost
redis.port=6379
redis.use-ssl=false