redis开机自启脚本

vi /etc/systemd/system/redis.service

Unit

Description=Redis persistent key-value database

After=network.target

After=network-online.target

Wants=network-online.target

Service

如果 redis.conf 中 daemonize 为 yes,则 Type 为 forking

如果 daemonize 为 no,则 Type 为 simple,且不需要 PIDFile

Type=simple

ExecStart=/opt/redis-8.0.0/bin/redis-server /opt/redis-8.0.0/redis.conf

ExecStop=/opt/redis-8.0.0/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown

Restart=always

PIDFile=/var/run/redis_6379.pid

TimeoutStopSec=0

Install

WantedBy=multi-user.target

systemctl daemon-reload

systemctl enable redis

systemctl start redis

systemctl status redis

相关推荐
上位机妹子2 小时前
EF Core 两种继承映射:每层次一张表(TPH)与每类型一张表(TPT)
数据库·c#·.netcore·ef core
小马同学-2 小时前
Redis消息队列与客户端编程
数据库·redis
weixin199701080162 小时前
《1688图片空间API踩坑:img.upload 与 album.* 的防盗链与CDN缓存问题》(附Python源码)
开发语言·python·缓存
for_ever_love__3 小时前
MySQL 高频面试题 30 问:索引、事务、锁、日志、主从与分库分表(MySQL 8.0 版)
java·数据库·spring boot·mysql·spring cloud·面试·总结
染指11103 小时前
140.Agent-多Agent框架-Agent执行Skills流程
数据库·人工智能·设计模式·langchain·agents
fengkai45453 小时前
十二、Redis -2
运维·数据库·redis·容器
hweiyu003 小时前
Redis命令:BLPOP
redis·缓存
余槐i4 小时前
200万行表加索引锁死写入:PostgreSQL CONCURRENTLY 的三类等待与重建路径
数据库·postgresql·性能优化·索引·explain