Could not connect to Redis at 127.0.0.1:6379: Connection refused

用命令(redis-cli)进入redis客户端时,报错

Could not connect to Redis at 127.0.0.1:6379: Connection refused

连接失败,这是要启动redis服务,以守护进程方式启动,步骤如下:

1.修改配置文件

vim  /etc/redis.conf

修改内容,把 daemonize no 修改为:

daemonize     yes

这是因为配置文件中,以守护进程方式启动,默认是关闭的,这是设置为允许以守护进程方式启动服务

2.启redis-server /etc/redis.conf看redis服务是否启动

ps aux|grep redis
[root@localhost ~]# ps aux | grep redis
root       3339  0.1  0.5 139524  5208 ?        Ssl  18:41   0:00 redis-server 127.0.0.1:6379 
root       3343  0.0  0.0 103324   848 pts/0    S+   18:41   0:00 grep redis

3.这时候再用命令

redis-cli

进入就可以了

[root@localhost ~]# redis-cli
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> keys *
1) "name"
2) "id"
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> 

猜你喜欢

转载自blog.csdn.net/xiejunna/article/details/79694150