wget https://redis.googlecode.com/files/redis-2.6.12.tar.gz
Tar zxvf redis-2.6.12.tar.gz
CD redis-2.6.12
Make
Make Prefix=/usr/local/redis Install
(problems encountered during the make process:)
When the installation is complete, Cd/usr/local/redis will see a bin directory in which the directory
They are redis-server, REDIS-CLI, Redis-benchmark, Redis-stat, respectively, and their functions are as follows:
Redis-server:redis Server Daemon Startup program
Redis-cli:redis command-line operation tool. Of course, you can also use Telnet to operate on its plain text protocol.
Redis-benchmark:redis Performance testing tools to test the read and write performance of Redis in your system and in your configuration
Redis-stat:redis Status Detection Tool to detect Redis current status parameters and delay status
Next you need to define your Redis configuration file
mkdir/usr/local/redis/etc/
vim/usr/local/redis/etc/redis.conf//write the following:
Daemonize Yes
Pidfile/usr/local/redis/var/redis.pid
Port 6379
Timeout 300
LogLevel Debug
Logfile/usr/local/redis/var/redis.log
Databases 16
Save 900 1
Save 300 10
Save 60 10000
Rdbcompression Yes
Dbfilename Dump.rdb
dir/usr/local/redis/var/
AppendOnly No
Appendfsync always
The following are the meanings of the main configuration parameters of redis.conf:
Daemonize: Whether to run daemon mode later
Pidfile:pid File Location
Port: Port number for listening
Timeout: Request time-out
Loglevel:log Information level
Logfile:log File Location
Databases: number of open databases
Save *: How often the snapshot is saved, the first * indicates how long, and the third * indicates how many times the write operation is performed. Snapshots are automatically saved when a certain number of writes are performed within a certain amount of time. You can set multiple conditions.
Rdbcompression: Whether to use compression
Dbfilename: Data Snapshot file name (only file name, excluding directory)
Dir: Save directory for Data snapshot (this is the directory)
AppendOnly: If the appendonlylog is turned on, each write will record a log, which will improve the data anti-risk ability, but affect the efficiency.
Appendfsync:appendonlylog How to sync to disk (three options, each write is forced to call Fsync, Fsync per second, do not call Fsync wait for the system to synchronize itself)
mkdir/usr/local/redis/var/
chmod 777/usr/local/redis/var/
The commands to start Redis are:
/usr/local/redis/bin/redis-server/usr/local/redis/etc/redis.conf
We can also write a Redis startup script.
Vi/etc/init.d/redis//Add the following:
#!/bin/sh
#
# Redis init file for starting up the Redis daemon
#
# Chkconfig:-20 80
# Description:starts and stops the Redis daemon.
# Source function library.
. /etc/rc.d/init.d/functions
Name= "Redis-server"
Basedir= "/usr/local/redis"
exec= "$basedir/bin/$name"
pidfile= "$basedir/var/redis.pid"
redis_config= "$basedir/etc/redis.conf"
[-e/etc/sysconfig/redis] &&. /etc/sysconfig/redis
Lockfile=/var/lock/subsys/redis
Start () {
[-F $REDIS _config] | | Exit 6
[-X $exec] | | Exit 5
Echo-n $ "Starting $name:"
Daemon--user ${redis_user-redis} "$exec $REDIS _config"
Retval=$?
Echo
[$retval-eq 0] && Touch $lockfile
Return $retval
}
Stop () {
Echo-n $ "Stopping $name:"
Killproc-p $pidfile $name
Retval=$?
Echo
[$retval-eq 0] && rm-f $lockfile
Return $retval
}
Restart () {
Stop
Start
}
Reload () {
False
}
Rh_status () {
Status-p $pidfile $name
}
Rh_status_q () {
Rh_status >/dev/null 2>&1
}
Case "$" in
Start
Rh_status_q && Exit 0
$
;;
Stop
Rh_status_q | | Exit 0
$
;;
Restart
$
;;
Reload
Rh_status_q | | Exit 7
$
;;
Force-reload)
Force_reload
;;
Status
Rh_status
;;
Condrestart|try-restart)
Rh_status_q | | Exit 0
Restart
;;
*)
echo $ "Usage: $ {Start|stop|status|restart|condrestart|try-restart}"
Exit 2
Esac
Exit $?
########### #到此结束
Because the script starts with a Redis user, you need to increase the Redis user
Useradd-s/sbin/nologin Redis
Mkdir/usr/local/redis/var
chmod 777/usr/local/redis/var
chmod 755/etc/init.d/redis
Simple Test Redis
/USR/LOCAL/REDIS/BIN/REDIS-CLI (Quick mode: Alise redis-cli= '/usr/local/redis/bin/redis-cli ' can also be placed in. BASHRC permanently saved)
Redis 127.0.0.1:6379> Set K1 v1
Ok
Redis 127.0.0.1:6379> Get K1
"V1"
That means there's no problem.
Redis installation Configuration