在 CentOS 上启动 Redis,常见有两种情况:单机启动 和 通过 systemd 启动。下面按最常见的方式一步步说明。
redis-server --version
或
rpm -qa | grep redis
如果未安装,可先安装:
yum install -y redis
或(CentOS 8 / Rocky / Alma)
dnf install -y redis
systemctl start redis
设置开机自启:
systemctl enable redis
查看运行状态:
systemctl status redis
redis-server
redis-server /etc/redis.conf
默认配置文件路径通常是:
/etc/redis.conf
ss -lntp | grep 6379
或
netstat -lntp | grep 6379
redis-cli
127.0.0.1:6379> ping
PONG
查看日志:
journalctl -u redis -xe
或
cat /var/log/redis/redis.log
lsof -i:6379
编辑:
vim /etc/redis.conf
确保:
daemonize yes
systemctl stop redis
systemctl restart redis
如果你愿意,可以告诉我:
我可以给你更精确的配置方案(如密码、远程访问、性能优化)。