在 CentOS 上启动 Redis,常见有以下几种方式,按使用场景说明(以 CentOS 7/8 为主,Redis 3.x/5.x/6.x 通用)。
常见服务名:
redis
redis-server
查看:
systemctl list-unit-files | grep redis
sudo systemctl start redis
或(如果服务名不同):
sudo systemctl start redis-server
sudo systemctl enable redis
sudo systemctl status redis
正常应看到:
Active: active (running)
redis-server
redis-server --daemonize yes
⚠️ 这种方式 不会随系统启动
/etc/redis.conf
/etc/redis/redis.conf
redis-server /etc/redis.conf
或 systemd 方式:
sudo systemctl start redis
ps -ef | grep redis
redis-cli
127.0.0.1:6379> ping
PONG
查看日志:
journalctl -u redis -xe
或:
tail -f /var/log/redis/redis.log
netstat -tunlp | grep 6379
检查:
redis-server /etc/redis.conf --test-config
service redis start
chkconfig redis on
| 场景 | 建议 |
|---|---|
| CentOS 7/8 | systemctl start redis ✅ |
| 生产环境 | 使用 systemd + 配置文件 |
| 临时测试 | redis-server --daemonize yes |
如果你愿意,可以告诉我:
cat /etc/centos-release)我可以给你 精确到命令级别 的启动方案 ✅