Installing Redis 4.0.6 on the CentOS 6.9 x86_64

Source: Internet
Author: User
Tags redis centos redis server
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





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.