linux 启动redis服务

centos服务器重启后启动redis服务
一、 未配置 系统 Unit 手动重启

1、查看redis配置文件路径
在这里插入图片描述
2、找到 redis-server 启动文件
在这里插入图片描述
3、 服务启动

 ./redis-server ../etc/redis.conf

4、查看服务状态

在这里插入图片描述

二、 配置 redis service 启动服务

1、创建服务(redis.conf 配置)

vim /lib/systemd/system/redis.service

[Unit]
Description=Redis
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf (配置自己redis 配置文件路径)
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
Alias=redis.service
[Install]
WantedBy=multi-user.target
[Unit] 表示这是基础信息
Description 是描述
After 是在那个服务后面启动,一般是网络服务启动后启动
[Service] 表示这里是服务信息 ExecStart 是启动服务的命令
ExecStop 是停止服务的指令
[Install] 表示这是是安装相关信息 WantedBy 是以哪种方式启动:
multi-user.target表明当系统以多用户方式(默认的运行级别)启动时,这个服务需要被自动运行

2、刷新配置
刚刚配置的服务需要让systemctl能识别,就必须刷新配置
systemctl daemon-reload

3、redis 启动、重启、停止

启动redis
systemctl start redis
systemctl restart redis
systemctl stop redis
systemctl status redis # 查看 redis 状态

4、开机自启动

redis服务加入开机启动
systemctl enable redis
禁止开机启动
systemctl disable redis

参考:https://blog.csdn.net/chwshuang/article/details/68489968

  • 1
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值