Configure Redis self-boot scripts

Source: Internet
Author: User

There is a Utils folder under the Redis source directory , which provides the Install_server.sh installation tool to generate a self-booting Redis script.

[[email protected]]# cd utils/[[email protected] utils]# ./install_server.sh  Welcometo the redis service installerThisscript will help you  easily set up a running redis server pleaseselect the redis  port for this instance: [6379] selectingdefault: 6379pleaseselect the  redis config file name [/etc/redis/6379.conf] /usr/local/redis/etc/ redis.confpleaseselect the redis log file name [/var/log/redis_6379.log] / Usr/local/redis/log/redis.logpleaseselect 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            : 6379configfile    : /usr/local/redis/etc/redis.conflogfile        :/usr/local/redis/log/redis.logdatadir       : /usr/local/ redis/data/executable     : /usr/local/redis/bin/redis-servercliexecutable  :  /usr/local/redis/bin/redis-cliis thisok? then press enter to go on  or ctrl-c to abort. Copied/tmp/6379.conf => /etc/init.d/redis_6379installingservice ... successfullyadded to chkconfig! successfullyadded to runlevels 345! Startingredis server ... installationsuccessful!

According to the actual situation, fill in the configuration file, log file, rdb/aof data storage directory


The script reads as follows:

[[email protected] utils]# cat /etc/init.d/redis_6379#!/bin/sh#configurationsinjected  by install_server below.... exec=/usr/local/redis/bin/redis-servercliexec=/usr/local/ redis/bin/redis-clipidfile=/var/run/redis_6379.pidconf= "/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 info  case "$"  in     start)         if [ -f  $PIDFILE  ]         then            echo  "$PIDFILE   Exists, processis already running or crashed "         else            echo  "Starting  redisserver              $EXEC   $CONF         fi        ;;     stop)         if [ ! -f $ pidfile ]        then             echo  "$PIDFILE  does not exist,process is not  Running "        else            pid=$ (cat   $PIDFILE)             echo  "stopping &nbsp              $CLIEXEC  -p $ redisport shutdown            while [  -x /proc/${pid} ]            do                 echo  " WAITING FOR REDIS TOSHUTDOWN&NBSP: "                sleep 1             done            echo  "redis  Stopped "        fi        ;;     status)         pid=$ (cat  $PIDFILE)          if [ ! -x /proc/${PID} ]         then            echo   ' redis is not running '         else             echo  "redis is running ($PID)"          fi        ;;     restart)         $0 stop         $0 start        ;;     *)         echo  "PleAse use start, stop,restart or status as first argument "         ;; Esac

To add a service and change the run level:

[[email protected] utils]# chkconfig--add redi_6379[[email protected] utils]# chkconfig--level redi_6379


This article is from the "HUNT" blog, make sure to keep this source http://hunt1574.blog.51cto.com/1390776/1631780

Configure Redis self-boot scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.