redis啟動管理指令碼

來源:互聯網
上載者:User

標籤:啟動管理   redis   

親測好用的redis啟動管理指令碼,如果使用需要根據自己安裝的redis相關檔案進行調整

我是源碼安裝的redis-3.0.5

安裝路徑/usr/local/redis

編輯建立指令碼檔案:

vim /etc/init.d/redis

#!/bin/sh## chkconfig:   2345 85 15  # description: this script can manager the redis-server daemon#              Redis is a persistent key-value database# exec:        /usr/local/redis/bin/redis-server# config:      /usr/local/redis/conf/redis.conf  # pidfile:     /usr/local/redis/logs/redis.pid  # datafile:    /usr/local/redis/data/redis.rdb  redis="/usr/local/redis/bin/redis-server"REDIS_CONF_FILE="/usr/local/redis/conf/redis.conf"prog=$(basename $redis)lockfile=/var/lock/subsys/redis# Source function library.. /etc/rc.d/init.d/functions # Source networking configuration.. /etc/sysconfig/network # Check that networking is up.[ "$NETWORKING" = "no" ] && exit 0 start() {    [ -x $redis ] || exit 5    [ -f $REDIS_CONF_FILE ] || exit 6    echo -n $"Starting $prog: "    daemon $redis $REDIS_CONF_FILE    retval=$?    echo    [ $retval -eq 0 ] && touch $lockfile    return $retval}stop() {    echo -n $"Stopping $prog: "    killproc $prog -QUIT    retval=$?    echo    [ $retval -eq 0 ] && rm -f $lockfile    return $retval}restart() {    stop    start}reload() {    echo -n $"Reloading $prog: "    killproc $redis -HUP    RETVAL=$?    echo}rh_status() {    status $prog}rh_status_q() {    rh_status >/dev/null 2>&1}case "$1" in    start)        rh_status_q && exit 0        $1        ;;    stop)        rh_status_q || exit 0        $1        ;;    restart)        $1        ;;    reload)        rh_status_q || exit 7        $1        ;;    status)        rh_status        ;;    *)        echo $"Usage: $0 {start|stop|restart|reload|status}"        exit 2esac

修改指令碼操作許可權,添加可執行許可權

chmod 755 /etc/init.d/redis

##### END #####

本文出自 “刺秦手記” 部落格,請務必保留此出處http://ciqin.blog.51cto.com/10608412/1794671

redis啟動管理指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.