1. Installation Dependencies
Yum install-y wget gcc make tcl
2. Download the source code and install it into the Redis website
https://redis.io/download/
Download the latest version
wget http://download.redis.io/releases/redis-4.0.6.tar.gz
Tar xzf redis-4.0.6.tar.gz
CD redis-4.0.6
Make
Make Test
Make install
3. Modify the configurationCreate profile directory, dump file directory, process PID directory, log directory, etc.
Dump file, process PID, log directory, etc., usually placed in the/var/directory,
Mkdir-p/var/redis/data
Configuration files are generally placed under/etc/
CP redis.conf/etc/
Modify the/etc/redis.conf as follows:
Daemonize Yes
Dir/var/redis/data
Pidfile/var/run/redis.pid
Logfile/var/log/redis.log
Macro variable Settings
The above installation will store the Redis-related executable files redis-server,redis-cli and so on to/usr/local/bin
For convenience, it can be added to the system path
Vim/etc/profile
Modify
Export Path=/usr/local/bin: $PATH
Save exit, execute the following command to take effect
Source/etc/profile
4. Set up Redis for system service
Vim/etc/init.d/redis
The contents are as follows
#!/bin/bash
#
# Init file for Redis
#
# Chkconfig:-80 12
# Description:redis Daemon
#
# Processname:redis
# config:/etc/redis.conf
# Pidfile:/var/run/redis.pid
Source/etc/init.d/functions
Bin= "/usr/local/bin"
Config= "/etc/redis.conf"
Pidfile= "/var/run/redis.pid"
# # Read Configuration
[-R "$SYSCONFIG"] && source "$SYSCONFIG"
Retval=0
Prog= "Redis-server"
desc= "Redis Server"
Start () {
If [-e $PIDFILE];then
echo "$desc already running ..."
Exit 1
Fi
Echo-n $ "Starting $desc:"
Daemon $BIN/$prog $CONFIG
Retval=$?
Echo
[$RETVAL-eq 0] && touch/var/lock/subsys/$prog
Return $RETVAL
}
Stop () {
Echo-n $ "Stop $desc:"
Killproc $prog
Retval=$?
Echo
[$RETVAL-eq 0] && rm-f/var/lock/subsys/$prog $PIDFILE
Return $RETVAL
}
Restart () {
Stop
Start
}
Case "$" in
Start
Start
;;
Stop
Stop
;;
Restart
Restart
;;
Condrestart)
[-e/var/lock/subsys/$prog] && restart
Retval=$?
;;
Status
Status $prog
Retval=$?
;;
*)
echo $ "Usage: $ {Start|stop|restart|condrestart|status}"
Retval=1
Esac
Exit $RETVAL
And then execute
chmod 755/etc/init.d/redis
5. Start
Simple Start test
/usr/local/bin/redis-server/etc/redis.conf
Start as a system service
Service Redis Status
Service Redis Start
Chkconfig Redis on
Chkconfig--list Redis
6. References
[1].https://www.cnblogs.com/visec479/p/5148744.html Simple and good
[2].https://www.cnblogs.com/caoguo/p/4625662.html Good, System services script is available for reference
[3].http://blog.csdn.net/ludonqin/article/details/47211109