这篇文章主要介绍redis启动管理脚本怎么写,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

我是源码安装的redis-3.0.5

安装路径/usr/local/redis

编辑创建脚本文件:

vim /etc/init.d/redis

#!/bin/sh##chkconfig:23458515#description:thisscriptcanmanagertheredis-serverdaemon#Redisisapersistentkey-valuedatabase#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.rdbredis="/usr/local/redis/bin/redis-server"REDIS_CONF_FILE="/usr/local/redis/conf/redis.conf"prog=$(basename$redis)lockfile=/var/lock/subsys/redis#Sourcefunctionlibrary../etc/rc.d/init.d/functions#Sourcenetworkingconfiguration../etc/sysconfig/network#Checkthatnetworkingisup.["$NETWORKING"="no"]&&exit0start(){[-x$redis]||exit5[-f$REDIS_CONF_FILE]||exit6echo-n$"Starting$prog:"daemon$redis$REDIS_CONF_FILEretval=$?echo[$retval-eq0]&&touch$lockfilereturn$retval}stop(){echo-n$"Stopping$prog:"killproc$prog-QUITretval=$?echo[$retval-eq0]&&rm-f$lockfilereturn$retval}restart(){stopstart}reload(){echo-n$"Reloading$prog:"killproc$redis-HUPRETVAL=$?echo}rh_status(){status$prog}rh_status_q(){rh_status>/dev/null2>&1}case"$1"instart)rh_status_q&&exit0$1;;stop)rh_status_q||exit0$1;;restart)$1;;reload)rh_status_q||exit7$1;;status)rh_status;;*)echo$"Usage:$0{start|stop|restart|reload|status}"exit2esac

修改脚本操作权限,添加可执行权限

chmod 755 /etc/init.d/redis

以上是“redis启动管理脚本怎么写”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!