114 字
1 分钟
CentOS 编译安装 Redis 6.2 并配置 Systemd 服务
Redis 版本:6.2.6
通过源码下载本地编译,配置 systemd 服务文件,使用 systemctl 进行管理。
一、下载解压
# 下载 rediswget https://cdn.olinl.com/redis-6.2.6.tar.gz# 官方地址# wget https://download.redis.io/releases/redis-6.2.6.tar.gz
# 解压并移动到 /opttar xzf redis-6.2.6.tar.gzmv redis-6.2.6 /opt/redis二、编译安装
# 安装编译依赖yum -y install gcc automake autoconf libtool make
# 进入目录并编译cd /opt/redismake MALLOC=libc
# 安装到指定目录make install PREFIX=/opt/redis
# 验证启动./bin/redis-server redis.conf三、修改配置文件
编辑 /opt/redis/redis.conf:
设置访问密码(第 901 行附近)
requirepass your_password允许外部访问(第 75 行附近)
bind 0.0.0.0设置后台运行(第 257 行附近)
daemonize yes四、注册 Systemd 服务
创建服务文件:
[Unit]Description=redis-serverAfter=network.target
[Service]Type=forkingExecStart=/opt/redis/bin/redis-server /opt/redis/redis.confPrivateTmp=true
[Install]WantedBy=multi-user.target服务操作命令:
# 重载 systemd 配置systemctl daemon-reload
# 启动systemctl start redis# 停止systemctl stop redis# 重启systemctl restart redis# 查看状态systemctl status redis# 开机自启systemctl enable redis
# 确认进程是否运行ps -ef | grep redis 分享
如果这篇文章对你有帮助,欢迎分享给更多人!
CentOS 编译安装 Redis 6.2 并配置 Systemd 服务
https://blog.olinl.com/posts/centos-redis-install/ 相关文章 智能推荐
1
CentOS 安装 MongoDB 3.4 并配置认证
服务与应用运维 在 CentOS 上通过 YUM 仓库安装 MongoDB 3.4,配置外部访问与用户密码认证,适合内网开发环境快速搭建。
2
CentOS 安装 MySQL 5.7 完整指南
服务与应用运维 详解在 CentOS 7 上通过 RPM 包安装 MySQL 5.7 的完整流程,涵盖自定义数据目录、外部访问配置及用户权限管理。
3
CentOS 安装与服务器初始化配置完整指南
Linux 系统管理 详述 CentOS 从零安装、分区到网络与防火墙配置全流程。助你快速构建稳定、安全的生产级 Web 服务器环境。
4
CentOS 安装 Nginx 及生产环境配置指南
服务与应用运维 介绍在 CentOS 上通过 YUM 安装 Nginx,并整理多站点、SSL、反向代理、Stream TCP 代理等常用生产配置模板。
5
CentOS 安装 Samba 实现跨系统文件共享
服务与应用运维 在 CentOS 上安装 Samba 服务,配置 SMB 共享目录与专用访问用户,实现 Windows 与 Linux 之间的文件互访。
