您好,登錄后才能下訂單哦!
這篇文章主要介紹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 2 esac
修改腳本操作權限,添加可執行權限
chmod 755 /etc/init.d/redis
以上是“redis啟動管理腳本怎么寫”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。