First, download and compile
cd / usr / local / bin
directory can choose their own, I will redis installed to / usr / local / bin directory.
wget http://download.redis.io/releases/redis-5.0.5.tar.gz
xzf Redis-5.0.5.tar.gz tar
cd-Redis 5.0.5
the make
after the completion of the first step, redis-cli redis-server and both clients and service files to be placed redis-5.0.5 / src below , redis.conf file redis-5.0.5 below
Second, the configuration startup script
vim /etc/init.d/redis
#!/bin/sh # chkconfig: 2345 80 90 # description: Start and Stop redis # PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 #端口 EXEC=/usr/local/bin/redis-5.0.5/src/redis-server #redis-server路径 REDIS_CLI=/usr/local/bin/redis-5.0.5/src/redis-cli #redis_cli路径 PIDFILE=/var/run/redis_$REDISPORT.pid CONF="/usr/local/bin/redis-5.0.5/redis.conf" #redis.conf路径 AUTH="mypassword123" #密码信息 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 does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." if [ -z $AUTH ] then $REDIS_CLI -p $REDISPORT SHUTDOWN else $REDIS_CLI -a $AUTH -p $REDISPORT SHUTDOWN fi 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
After the startup script configuration is complete, use the following command to give permission
chmod 755 /etc/init.d/redis
add startup service using the following command
systemctl enable redis