您好,登錄后才能下訂單哦!
這篇文章主要介紹redis啟動(dòng)管理腳本怎么寫,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
我是源碼安裝的redis-3.0.5
安裝路徑/usr/local/redis
編輯創(chuàng)建腳本文件:
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 2 esac
修改腳本操作權(quán)限,添加可執(zhí)行權(quán)限
chmod 755 /etc/init.d/redis
以上是“redis啟動(dòng)管理腳本怎么寫”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。