这篇文章主要介绍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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。