windows下创建Ubuntu子系统并安装redis

当前使用的本是windows系统,最近需要使用redis,但redis对windows的支持又不好,所以打算装个子系统来跑redis

1. 安装ubuntu

1)启用Linux子系统

打开“控制面板”,点击“程序和功能”,再点击“启用或关闭Windows功能”。在弹出的对话框中,选中功能列表中的“适用于Linux的Windows子系统”,点击“确定”。重启电脑。


2)安装Ubuntu子系统

打开 Windows10 的微软商店,搜索“Linux”,我们会发现微软已经为我们提供了众多的 Linux 发行版本。选择 Ubuntu ,点击安装。

安装结果如下

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: chen
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

2. 安装并运行redis

依次运行如下命令

sudo apt update
sudo apt install redis
redis-cli --version

出现

redis-cli 4.0.9

安装成功

本想使用

sudo systemctl start redis-server

来运行,结果出现

System has not been booted with systemd as init system (PID 1). Can't operate.

这是因为咱们用的是子系统的原因。可以换成以下命令来启动redis

sudo service redis-server start

然后在windows下的RDM中就可以使用127.0.0.1的ip来连redis了


如果不清楚service的名称,可以使用

service --status-all

来展示所有已经安装的service

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容