首页 > 解决方案 > 提示闪烁为空时如何使redis工作?

问题描述

所以我想用redis作为一个工具,在用不同语言编写的多个脚本之间传递数据。

我通过我的操作系统上的包管理器安装了redis(opensuse,如果它有助于调试......)。

我跑了 sudo redis-server 和 redis-cli 我得到了这个

wawa@linux-79q8:~/Desktop> sudo redis-server
[sudo] password for root: 
26824:C 08 May 01:37:37.913 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
26824:C 08 May 01:37:37.913 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=26824, just started
26824:C 08 May 01:37:37.913 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
26824:M 08 May 01:37:37.915 * Increased maximum number of open files to 10032 (it was originally set to 1024).
26824:M 08 May 01:37:37.915 # Creating Server TCP listening socket *:6379: bind: Address already in use
wawa@linux-79q8:~/Desktop> redis-cli ping

空无一物 !!!提示只是闪烁为空。我不知道如何调试这个。我是redis的新手。

请帮忙 !

编辑:netsat 给我这个:

wawa@linux-79q8:~/Desktop> sudo netstat -antp | grep 6379
[sudo] password for root: 
tcp        7      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      23836/redis-server  
tcp        0      0 127.0.0.1:44128         127.0.0.1:6379          ESTABLISHED 27034/redis-cli     
tcp       14      0 127.0.0.1:6379          127.0.0.1:44128         ESTABLISHED -                   
tcp        0      0 127.0.0.1:43878         127.0.0.1:6379          ESTABLISHED 24530/redis-cli     
tcp       17      0 127.0.0.1:6379          127.0.0.1:43878         ESTABLISHED -                   
tcp       15      0 127.0.0.1:6379          127.0.0.1:43850         CLOSE_WAIT  -                   
tcp       17      0 127.0.0.1:6379          127.0.0.1:43976         ESTABLISHED -                   
tcp       17      0 127.0.0.1:6379          127.0.0.1:43886         ESTABLISHED -                   
tcp       18      0 127.0.0.1:6379          127.0.0.1:43862         CLOSE_WAIT  -                   
tcp       18      0 127.0.0.1:6379          127.0.0.1:43854         CLOSE_WAIT  -                   
tcp        0      0 127.0.0.1:43886         127.0.0.1:6379          ESTABLISHED 24786/redis-cli     
tcp        0      0 127.0.0.1:43976         127.0.0.1:6379          ESTABLISHED 26551/redis-cli     
tcp6       0      0 :::6379                 :::*                    LISTEN      23836/redis-server  
wawa@linux-79q8:~/Desktop> 

标签: redis

解决方案


看来您的 redis 服务器已经在运行并正在侦听 port 6379

tcp 7 0 0.0.0.0:6379 0.0.0.0:* LISTEN 23836/redis-server

现在您可以终止现有的 redis 服务器并重新运行该过程。

然后,您可以通过redis-cli连接到 redis 。然后尝试一些 get/set 命令。


$ redis-cli

127.0.0.1:6379> set a "asdfasdf"
OK
127.0.0.1:6379> get a
"asdfasdf"

推荐阅读