In the previous article, Redis was introduced, and the following is the record for installing Redis on CentOS. For later in doing the improvement.
1, installation needs of the support environment
The first thing to do before installing Redis is to install the Tcl tool for UNIX, which will not be able to test Redis later if it is not installed. The following error message is returned when the make test is executed later: you need TCL 8.xuyao De5 or newer in order to run the Redis test, the specific process is:
Copy Code code as follows:
Cd/usr/local/src
wget http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz
TAR-ZXVF tcl8.6.3-src.tar.gz
CD tcl8.6.3/unix/
./configure
Make
Make install
2. Installation Redis
The process of installing Redis is very simple, the website of specific tutorial also has. Specifically as follows: Http://redis.io/download
Copy Code code as follows:
Cd/usr/local/src
wget http://download.redis.io/releases/redis-2.8.19.tar.gz
Tar zxvf redis-2.8.19.tar.gz
CD redis-2.8.19
Make
Make Prefix=/usr/local/redis Install
Where Prefix=/usr/local/redis can be omitted, Redis will be installed by default to the/usr/local/bin directory.
3. Test Redis
Copy Code code as follows:
The above command will allow the Redis to be tested.
4. Configure Redis
A, copy and modify the configuration document
Copy Code code as follows:
CP./redis.conf/usr/local/redis/
Vim/usr/local/redis/redis.conf
I have only modified the following two items:
Daemonize Yes #redis将以守护进程的方式运行, the default is no to take up your terminal
Timeout #当 turn off the connection after a client has been idle for a long time, if specified as 0, to turn off the feature
More configuration content, subsequent carding is completed and then released.
B, set up auto start
Copy Code code as follows:
The following contents are saved in the file:
Copy Code code as follows:
#!/bin/sh
#
# redis Startup script for Redis Server
#
# Chkconfig:-80 12
# Description:redis is an open source, Advanced Key-value store.
#
# Processname:redis-server
# config:/etc/redis.conf
# Pidfile:/var/run/redis.pid
Source/etc/init.d/functions
Bin= "/usr/local/redis/bin"
Config= "/usr/local/redis/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
C, start or close services
Copy Code code as follows:
Service Redis Start
Service Redis Stop
5. Use Redis
Copy Code code as follows:
[Root@localhost redis]# Cd/usr/local/redis/bin
[Root@localhost bin]#./redis-cli
127.0.0.1:6379> set Foo Bar
Ok
127.0.0.1:6379> get foo
"Bar"
127.0.0.1:6379>