配置redis自启动脚本
生活随笔
收集整理的這篇文章主要介紹了
配置redis自启动脚本
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
? ?在redis源碼目錄下有一個(gè)utils文件夾,提供了install_server.sh安裝工具,可生成自啟動(dòng)的redis腳本。
? ? ? ? ?
[root@huntdbredis-2.8.19]#?cd?utils/ [root@huntdb?utils]#?./install_server.sh? Welcometo?the?redis?service?installer Thisscript?will?help?you?easily?set?up?a?running?redis?serverPleaseselect?the?redis?port?for?this?instance:?[6379]? Selectingdefault:?6379 Pleaseselect?the?redis?config?file?name?[/etc/redis/6379.conf]?/usr/local/redis/etc/redis.conf Pleaseselect?the?redis?log?file?name?[/var/log/redis_6379.log]?/usr/local/redis/log/redis.log Pleaseselect?the?data?directory?for?this?instance?[/var/lib/redis/6379]?/usr/local/redis/data/ Pleaseselect?the?redis?executable?path?[/usr/local/redis/bin/redis-server]? Selectedconfig: Port???????????:?6379 Configfile????:?/usr/local/redis/etc/redis.conf Logfile???????:/usr/local/redis/log/redis.log Datadir???????:?/usr/local/redis/data/ Executable?????:?/usr/local/redis/bin/redis-server CliExecutable?:?/usr/local/redis/bin/redis-cli Is?thisok??Then?press?ENTER?to?go?on?or?Ctrl-C?to?abort. Copied/tmp/6379.conf?=>?/etc/init.d/redis_6379 Installingservice... Successfullyadded?to?chkconfig! Successfullyadded?to?runlevels?345! StartingRedis?server... Installationsuccessful!根據(jù)實(shí)際情況分別填寫配置文件、日志文件、rdb/aof數(shù)據(jù)存儲(chǔ)目錄
腳本內(nèi)容如下:
[root@huntdb?utils]#?cat?/etc/init.d/redis_6379 #!/bin/sh #Configurationsinjected?by?install_server?below....EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis_6379.pid CONF="/usr/local/redis/etc/redis.conf" REDISPORT="6379" ############### #?SysVInit?Information #chkconfig:?-?58?74 #description:?redis_6379?is?the?redis?daemon. ###BEGIN?INIT?INFO #Provides:?redis_6379 #Required-Start:?$network?$local_fs?$remote_fs #Required-Stop:?$network?$local_fs?$remote_fs #Default-Start:?2?3?4?5 #Default-Stop:?0?1?6 #Should-Start:?$syslog?$named #Should-Stop:?$syslog?$named #Short-Description:?start?and?stop?redis_6379 #Description:?Redis?daemon ###?ENDINIT?INFOcase"$1"?instart)if?[?-f?$PIDFILE?]thenecho?"$PIDFILE?exists,?processis?already?running?or?crashed"elseecho?"Starting?Redisserver..."$EXEC?$CONFfi;;stop)if?[?!?-f?$PIDFILE?]thenecho?"$PIDFILE?does?not?exist,process?is?not?running"elsePID=$(cat?$PIDFILE)echo?"Stopping?..."$CLIEXEC?-p?$REDISPORT?shutdownwhile?[?-x?/proc/${PID}?]doecho?"Waiting?for?Redis?toshutdown?..."sleep?1doneecho?"Redis?stopped"fi;;status)PID=$(cat?$PIDFILE)if?[?!?-x?/proc/${PID}?]thenecho?'Redis?is?not?running'elseecho?"Redis?is?running($PID)"fi;;restart)$0?stop$0?start;;*)echo?"Please?use?start,?stop,restart?or?status?as?first?argument";; esac添加服務(wù)并更改運(yùn)行級(jí)別:
[root@huntdb?utils]#?chkconfig?--add?redi_6379[root@huntdb?utils]#?chkconfig?--level?redi_6379?35?on轉(zhuǎn)載于:https://blog.51cto.com/hunt1574/1631780
總結(jié)
以上是生活随笔為你收集整理的配置redis自启动脚本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: javascript高程3 学习笔记(二
- 下一篇: 北漂周记--终结篇