- 更新 apt 软件包索引:
sudo apt update 更新过就不需要在更新了
- 安装 Redis:
sudo apt install redis-server
- 安装完成后,Redis 服务会自动启动。你可以使用以下命令检查是否正在运行:
systemctl status redis
如果输出中看到 “Active: active (running)” ,则表示 Redis 服务正在运行。
- 另外,你也可以通过以下命令启动、停止和重启 Redis 服务:
sudo systemctl start redis
sudo systemctl stop redis
sudo systemctl restart redis
至此,Redis 已经成功安装并且运行在系统上了。
测试:
redis-cli
set ttd 123
get ttd 123
del ttd