2013-02-27 114 views
4
$ redis-cli -h ec2-75-101-204-XXX.compute-1.amazonaws.com 
Could not connect to Redis at ec2-75-101-204-XXX.compute-1.amazonaws.com:6379: Operation timed out 

这就是我从主机上得到的结果。我成立了安全小组在该机器上。当我Redis的服务器上运行netstat是开放的端口6379.与Redis的连接超时

,我看到它听:

$ netstat -nlp 
(No info could be read for "-p": geteuid()=1000 but you should be root.) 
Active Internet connections (only servers) 
Proto Recv-Q Send-Q Local Address   Foreign Address   State  PID/Program name 
tcp  0  0 127.0.0.1:6379   0.0.0.0:*    LISTEN  -    
tcp  0  0 0.0.0.0:22    0.0.0.0:*    LISTEN  -    
tcp6  0  0 :::22     :::*     LISTEN  -    
udp  0  0 0.0.0.0:68    0.0.0.0:*       -    
Active UNIX domain sockets (only servers) 

redis.conf样子:

daemonize yes 
pidfile /var/run/redis.pid 
port 6379 
timeout 300 
loglevel notice 
logfile /var/log/redis.log 
databases 16 

save 900 1 
save 300 10 
save 60 10000 

stop-writes-on-bgsave-error yes 
rdbcompression yes 

那么,为什么我会从另一台机器超时?

回答

8

redis只在localhost端口上侦听:127.0.0.1:6379

您需要配置redis以绑定到0.0.0.0

在redis.conf(最有可能在/etc/redis/redis.conf,取代(或添加如果不存在)

bind 127.0.0.1 

bind 0.0.0.0 
+0

我改变了它。不知道是否改变任何东西,但。 – Shamoon 2013-02-27 02:44:34

+0

什么'netstat -nl'的新输出?然后你重新启动了redis,对吧? – 2013-02-27 02:49:16