Linux Debian 安装与卸载 Redis 服务
Redis 是一个著名的开源键值对(Key-Value)存储数据库。今天来演示一下如下在 Linux Debian/Ubuntu 服务器上安装与卸载 Redis服务。
安装 Redis
(1)查看服务器系统与版本:
1 | $ lsb_release -a |
可以看到本机使用 Debian 11.5 系统。
(2)要在 Debian 系统安装 Redis ,可以 apt 命令直接安装:
1 | $ apt update |
(3)查看安装的版本:
1 | $ redis-server -v |
(4)检查服务状态:
使用 systemctl 命令查看 redis 服务状态:
1 | $ systemctl status redis |
更多 systemctl 命令如下:
1 | systemctl start redis-server # 启动 |
查看 Redis 服务器系统进程
1 | $ ps -ef|grep redis |
检查 Redis 端口状态
1 | $ netstat -nlt | grep 6379 |
Redis 默认监听 6379 端口。
(5) 使用 redis-cli 客户端工具操作redis
1 | $ redis-cli -h 127.0.0.1 -p 6379 |
(6) 配置文件
通过 apt 安装的 Redis 的默认配置路径在: /etc/redis/redis.conf
我可以修改 redis.conf 配置文件,找到 port 行,将原默认端口号 6379 改成 6001:
1 | #port 6379 |
重启并重新连接 redis 服务:
1 | # 重启 |
卸载 Redis 服务
直接使用 apt 卸载:
1 | $ apt purge --auto-remove redis-server |
或者手动删除Redis命令与配置文件等:
1 | $ whereis redis-server |
参考链接
https://www.cnblogs.com/architectforest/p/15737927.html
Thanks for reading.