zoukankan      html  css  js  c++  java
  • 使用Redis启动脚本设置开机自启动

    推荐在生产环境中使用启动脚本方式启动redis服务。启动脚本 redis_init_script 位于位于Redis的 /utils/ 目录下。

    #大致浏览下该启动脚本,发现redis习惯性用监听的端口名作为配置文件等命名,我们后面也遵循这个约定。
    #redis服务器监听的端口
    REDISPORT=6379
    #服务端所处位置,在make install后默认存放与`/usr/local/bin/redis-server`,如果未make install则需要修改该路径,下同。
    EXEC=/usr/local/bin/redis-server
    #客户端位置
    CLIEXEC=/usr/local/bin/redis-cli
    #Redis的PID文件位置
    PIDFILE=/var/run/redis_${REDISPORT}.pid
    #配置文件位置,需要修改
    CONF="/etc/redis/${REDISPORT}.conf"

    配置环境

    1. 根据启动脚本要求,将修改好的配置文件以端口为名复制一份到指定目录。需使用root用户。

    mkdir /etc/redis
    cp redis.conf /etc/redis/6379.conf

     2. 将启动脚本复制到/etc/init.d目录下,本例将启动脚本命名为redisd(通常都以d结尾表示是后台自启动服务)。

    cp redis_init_script /etc/init.d/redisd

     3.  设置为开机自启动

    此处直接配置开启自启动 chkconfig redisd on 将报错误: service redisd does not support chkconfig 
    参照 此篇文章 ,在启动脚本开头添加如下两行注释以修改其运行级别:

    #!/bin/sh
    # chkconfig:   2345 90 10
    # description:  Redis is a persistent key-value database
    #

     再设置即可成功。

    #设置为开机自启动服务器
    chkconfig redisd on
    #打开服务
    service redisd start
    #关闭服务
    service redisd stop
  • 相关阅读:
    C语言中for循环的使用
    详解C语言的main函数
    计算机语言的发展(the history of computer's language)
    hdu 1001
    hoj 1002
    hdu 1000
    POJ 1000(水题)
    hoj 1001
    code hunt题解(1)
    《C和指针》学习笔记(3)
  • 原文地址:https://www.cnblogs.com/haorun/p/6994323.html
Copyright © 2011-2022 走看看