关于redis:Ubuntu20-WSL-安装Redis-报错Connection-refused

原本想在windows上装置一个Redis,然而发现官网都没有提供预编译好的二进制发行版本,这就很让人头疼了。
那就想着在WSL上装置吧,美滋滋。
Ubuntu20.04 WSL上装置redis有两种形式:

  • 应用apt包管理器
  • 自行编译源代码

先说第一种方法,通过apt包管理器装置Redis是最不便的
只需如下两行命令即可

sudo apt update
sudo apt install redis-server

然而实际上不行,你会发现一些谬误:

csy@Yoga14S-yjc:~$ systemctl status redis-server
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

以及

csy@Yoga14S-yjc:~$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
not connected>
not connected>
not connected>
not connected>
not connected> dsa
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>

这就很麻烦,为了解决Connection refused谬误
能够执行一下命令

sudo service redis-server start

这是便能够失常应用redis-cli了

csy@Yoga14S-yjc:~$ redis-cli
127.0.0.1:6379> exit

然而输出systemctl status redis-server查看redis-server的运行状态还是不行
然而通过service命令是能够的。

csy@Yoga14S-yjc:~$ sudo service redis-server status
 * redis-server is running

对于servicesystemctl的区别能够参考这篇文章Linux 服务治理两种形式service和systemctl

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理