zoukankan      html  css  js  c++  java
  • Centos7 设置redis开机自启

    Centos7 设置redis开机自启

    标签(空格分隔):Linux

    环境

    Centos7.1
    redis-3.0.6
    

    chkconfig方式

    **service和chkconfig命令的功能好像都被阉割了,而且好像已经被systemctl命令取代了**
    
    1. 找到redis安装包

    2. 复制redis_init_script文件到/etc/init.d/

    3. 修改下文件内容

    4. 设置可执行权限

    5. 开自启

    6. 弃用[提示不能用]

    systemctl方式

    1. 新建redis.service服务文件
      vim /usr/lib/systemd/system/redis.service

    2. 修改redis.service文件内容

    3. 创建软连接
      ln -s /usr/lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service

    4. 刷新systemctl
      systemctl daemon-reload

    5. 设置开机自启动
      systemctl enable redis
      systemctl disable redis

    6. 启动redis
      systemctl start redis
      systemctl stop redis

    7. 重启
      reboot
      7.常用命令
      systemctl 查看正在运行的服务
      systemctl list-units 查看激活的单元
      systemctl --failed 查看运行失败的单元
      systemctl list-unit-files 查看所有已安装服务
      8.配置文件
      Unit]:服务的说明
      Unit]:服务的说明
      Description:描述服务
      After:依赖,当依赖的服务启动之后再启动自定义的服务

      [Service]服务运行参数的设置
      Type=forking|Simple 父进程fork,此方式必须指定PIDFile=,|主进程启动
      ExecStart为服务的具体运行命令
      ExecReload为重启命令
      ExecStop为停止命令
      PrivateTmp=True表示给服务分配独立的临时空间
      注意:启动、重启、停止命令全部要求使用绝对路径

      [Install]服务安装的相关设置,可设置为多用户

  • 相关阅读:
    图形合并
    启动脚本
    图形合并
    :(){:|:&};:
    C言语教程第八章:列举,位运算(5)
    C言语图形情势编程,赋性鼠标(4)
    C言语教程第十章:文件(6)
    C言语教程第十章:文件(4)
    红帽为什么要连结桌面Linux
    阶乘较劲争论器改善版
  • 原文地址:https://www.cnblogs.com/yanweifeng/p/11571871.html
Copyright © 2011-2022 走看看