CentOS_6.5安装Redis_3.0.2

前端之家收集整理的这篇文章主要介绍了CentOS_6.5安装Redis_3.0.2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.解压、编译、安装redis-3.0.2

tarzxvfredis-3.0.2.tar.gz-C/usr/local/redis/
cd/usr/local/redis/
make&&makeinstall

2.创建redis相关目录

mkdir-p/usr/local/redis/log
mkdir-p/usr/local/redis/pid
mkdir-p/usr/local/redis/db

3.编辑redis.conf配置文件

cpredis.conf/etc/redis.conf
vim/etc/redis.conf
daemonizeyes
pidfile/usr/local/redis/pid/redis.pid
port6379
tcp-backlog511
timeout600
tcp-keepalive0
loglevelnotice
logfile/usr/local/redis/log/redis.log
databases16
save9001
save30010
save6010000
rdbcompressionyes
dbfilenamedump.rdb
dir/usr/local/redis/db
slave-serve-stale-datayes
appendonlyyes
appendfilename"appendonly.aof"
appendfsynceverysec
no-appendfsync-on-rewriteno
auto-aof-rewrite-percentage100
auto-aof-rewrite-min-size64mb
slowlog-log-slower-than10000
slowlog-max-len128
latency-monitor-threshold0
notify-keyspace-events""
hash-max-ziplist-entries512
hash-max-ziplist-value64
list-max-ziplist-entries512
list-max-ziplist-value64
set-max-intset-entries512
zset-max-ziplist-entries128
zset-max-ziplist-value64
hll-sparse-max-bytes3000
activerehashingyes
client-output-buffer-limitnormal000
client-output-buffer-limitslave256mb64mb60
client-output-buffer-limitpubsub32mb8mb60
hz10
aof-rewrite-incremental-fsyncyes

4.创建redis服务脚本,并赋予权限

vim/etc/init.d/redis
#!/bin/sh
#chkconfig:23456040
#Description:StartandStopredis
#Provides:redis
#Default-Start:2345
#Default-Stop:016
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli
PIDFILE=/usr/local/redis/pid/redis.pid
CONF="/etc/redis.conf"
case"$1"in
start)
if[-f$PIDFILE]
then
echo"$PIDFILEexists,processisalreadyrunningorcrashed"
else
echo"StartingRedisserver..."
$EXEC$CONF
fi
if["$?"="0"]
then
echo"Redisisrunning..."
fi
;;
stop)
if[!-f$PIDFILE]
then
echo"$PIDFILEdoesnotexist,processisnotrunning"
else
PID=$(cat$PIDFILE)
echo"StoppingRedisserver..."
$REDIS_CLI-p$REDISPORTSHUTDOWN
while[-x${PIDFILE}]
do
echo"WaitingforRedistoshutdown..."
sleep1
done
echo"Redisisstopped"
fi
;;
restart|force-reload)
${0}stop
${0}start
;;
*)
echo"Usage:/etc/init.d/redis{start|stop|restart|force-reload}">&2
exit1
esac

5.添加redis服务开机启动

chmoda+x/etc/init.d/redis
chkconfig--addredis
chkconfig--level2345redison
chkconfig--list|grepredis

6.启动redis服务

serviceredisstart
ps-aux|grepredis
netstat-anptu|grep6379

7.防火墙启用6379端口

iptables-AINPUT-ptcp--dport6379-jACCEPT

猜你在找的CentOS相关文章