1、下载安装包
wget http://download.redis.io/releases/redis-3.0.3.tar.gz、
2、解压
tar -xf redis-3.0.3.tar.gz
cd redis-3.0.3
./runtest
You need tcl 8.5 or newer in order to run the Redis test
3、编译安装
安装依赖环境
yum install gcc
yum install tcl
make test
看到如下则证明可以正常编译安装了
\o/ All tests passed without errors!
Cleanup: may take some time... OK
安装
make PREFIX=/usr/local/redis install
查看安装
cd /usr/local/redis/bin
#ll
总用量 15444
-rwxr-xr-x 1 root root 4587411 8月 3 18:33 redis-benchmark
-rwxr-xr-x 1 root root 22233 8月 3 18:33 redis-check-aof
-rwxr-xr-x 1 root root 45443 8月 3 18:33 redis-check-dump
-rwxr-xr-x 1 root root 4690510 8月 3 18:33 redis-cli
lrwxrwxrwx 1 root root 12 8月 3 18:33 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 6458191 8月 3 18:33 redis-server
编辑配置文件
cp /root/jksoftware/redis-3.0.3/redis.conf /usr/local/redis
创建日志路径和日志文件
mkdir log
cd log
touch redis.log
vim redis.conf
################################ GENERAL #####################################
daemonize yes
pidfile /mnt/redis/pid/redis.pid
dbfilename dump.rdb
dir /mnt/redis/db
port 6379
timeout 0
tcp-keepalive 0
loglevel notice
logfile /mnt/redis/log/redis.log
databases 16
################################ SNAPSHOTTING ################################
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
################################# REPLICATION #################################
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
################################## SECURITY ###################################
maxmemory 10240mb
maxmemory-policy allkeys-lru
############################## APPEND ONLY MODE ###############################
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
################################ LUA SCRIPTING ###############################
lua-time-limit 5000
################################ REDIS CLUSTER ###############################
################################## SLOW LOG ###################################
slowlog-log-slower-than 10000
slowlog-max-len 128
################################ LATENCY MONITOR ##############################
############################### ADVANCED CONFIG ###############################
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
编写启动脚本
vim /ect/init.d/redis
#!/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 "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
加入开机自启
chmod +x /etc/init.d/redis
chkconfig redis on
chkconfig --list | grep redis
启动redis
service redis start
ss -tnl