dnf install -y gcc make mkdir -p /data/redis # chown $USER:$USER /data/redis wget https://download.redis.io/releases/redis-7.2.4.tar.gz tar -zxf redis-7.2.4.tar.gz cd redis-7.2.4 make PREFIX=/data/redis install cp redis.conf /data/redis/ grep -v '^#' /data/redis/redis.conf | grep -v '^$' mv /data/redis/redis.conf /data/redis/redis.conf.bak vim redis.conf # 配置在文件redis.conf touch /data/redis/redis.log chown root:root /data/redis/redis.log chmod 644 /data/redis/redis.log chown -R root:root /data/redis chmod -R 755 /data/redis # systemd 配置 vim /etc/systemd/system/redis.service [Unit] Description=Redis In-Memory Data Store After=network.target [Service] User=root Group=root ExecStart=/data/redis/bin/redis-server /data/redis/redis.conf ExecStop=/data/redis/bin/redis-cli shutdown Restart=always WorkingDirectory=/data/redis [Install] WantedBy=multi-user.target # 重新加载 systemd 配置 sudo systemctl daemon-reload # 启动 Redis sudo systemctl start redis # 设置开机自启 sudo systemctl enable redis # 检查状态 sudo systemctl status redis