共計 1542 個字符,預計需要花費 4 分鐘才能閱讀完成。
這篇文章主要介紹 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 啟動管理腳本怎么寫”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注丸趣 TV 行業資訊頻道!
正文完