redis installed in linux boot

1. Drag under / usr / local

2. Extract    

    takes zxf redis -4.0 .8.tar.gz

3. mkdir /usr/redis

4.  Compile

    cd redis-4.0.8/src
    make

    After redis-4.0.8 make in the SRC directory, there are four executable files redis-server, redis-benchmark, redis-cli and redis.conf.

   Four copies of these files to / usr / redis inside

  mv redis-server /usr/redis
  mv redis-benchmark /usr/redis
  mv redis-cli /usr/redis
  mv redis.conf /usr/redis

5. yum install redis

   Then write a script

# chkconfig: 2345 10 90  
# description: Start and Stop redis   
  
PATH=/usr/local/bin:/sbin:/usr/bin:/bin   
REDISPORT=6379  
EXEC=/usr/bin/redis-server   
REDIS_CLI=/usr/bin/redis-cli   
 
PIDFILE=/var/run/redis.pid   
CONF="/etc/redis.conf"  
#AUTH="1234" 设置的redis的密码  

case "$1" in   
        start)   
                if [ -f $PIDFILE ]   
                then   
                        echo "$PIDFILE exists, process is already running or crashed."  
                else  
                        echo "Starting Redis server..."  
                        $EXEC $CONF   
                fi   
                if [ "$?"="0" ]   
                then   
                        echo "Redis is running..."  
                fi   
                ;;   
        stop)   
                if [ ! -f $PIDFILE ]   
                then   
                        echo "$PIDFILE exists, process is not running."  
                else  
                        PID=$(cat $PIDFILE)   
                        echo "Stopping..."  
                       $REDIS_CLI -p $REDISPORT  SHUTDOWN    
                        sleep 2  
                       while [ -x $PIDFILE ]   
                       do  
                                echo "Waiting for Redis to shutdown..."  
                               sleep 1  
                        done   
                        echo "Redis stopped"  
                fi   
                ;;   
        restart|force-reload)   
                ${0} stop   
                ${0} start   
                ;;   
        *)   
               echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2  
                exit 1  
esac

6. Set permissions

    chmod 755 redis

7. Set the boot from Kai

     chkconfig redis on

8. permanently turn off the firewall

linux permanently turn off the firewall 
# close iptable 
/etc/init.d/iptables STOP 
# iptables to see whether to close 
/etc/init.d/iptables Status 
# iptables to close the boot from the start 
chkconfig iptables off

9. Restart Linux

    reboot

 

Guess you like

Origin www.cnblogs.com/sjzxxy/p/11725824.html
Recommended