redis operation and maintenance manual

Version uses: redis-3.2.11.tar.gz
official website Download: https: //redis.io/download

 

1.redis server resources

redis server Basic Configuration CPU2 core, memory-demand, system disk 50G, 100G disk data 

 

`` ` 
# 1. Install 
CD / usr / local / the src 
the tar-3.2.11.tar.gz -xf Redis -C /usr/local/redis-3.2.11/ 
CD /usr/local/redis-3.2.11 / 
the make 
the make the install 
LN /usr/local/redis-3.2.11/ -s / usr / local / Redis 
mkdir / usr / local / Redis / bin 
mkdir / usr / local / Redis / Data 
CP / usr / local / bin / * redis- / usr / local / Redis / bin / 

# 2. configuration changes 
# listen addresses 
the bind 0.0.0.0 
# backstage start 
daemonize yes   
# PID file 
the PidFile /usr/local/redis/redis_6379.pid   
# logging 
logfile / usr / local /redis/redis.log   
# data storage path 
dir / usr / local / Redis / the data /   
# to access password 
requirepass Redis   

# 3. authorization 
the useradd Redis -s / sbin / nologin -M
chown -R redis.redis /usr/local/redis*

#4.启动脚本
[root@erpdev01 ~]# cat /etc/init.d/redis_6379 
#!/bin/sh
#Configurations injected by install_server below....

EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/usr/local/redis/redis_6379.pid
CONF="/usr/local/redis/redis.conf"
REDISPORT="6379"
###############
# SysV Init 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
### END INIT INFO


case "$1" in
    start)
        if [ -f $PIDFILE ]
        then
            echo "$PIDFILE exists, process is already running or crashed"
        else
            echo "Starting Redis server..."
            sudo -u redis $EXEC $CONF
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
            echo "$PIDFILE does not exist, process is not running"
        else
            PID=$(cat $PIDFILE)
            echo "Stopping ..."
            $CLIEXEC -p $REDISPORT shutdown
            while [ -x /proc/${PID} ]
            do
                echo "Waiting for Redis to shutdown ..."
                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

  

Guess you like

Origin www.cnblogs.com/luchuangao/p/11514713.html