CentOS_7.2安装Redis_3.0

一、安装依赖包和开发工具:

yum install vim vim-enhanced wget zip unzip telnet ntsysv compat* apr* nasm* gcc gcc* gcc-c++ ntp make imake cmake automake autoconf python-devel zlib zlib-devel glibc glibc-devel glib2 libxml glib2-devel libxml2 libxml2-devel bzip2 bzip2-devel libXpm libXpm-devel libidn libidn-devel libtool libtool-ltdl-devel* libmcrypt libmcrypt-devel libevent-devel libmcrypt* libicu-devel libxslt-devel postgresql-devel curl curl-devel perl perl-Net-SSLeay pcre pcre-devel ncurses ncurses-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers krb5 krb5-devel e2fsprogs e2fsprogs-devel libjpeg libpng libjpeg-devel libjpeg-6b libjpeg-devel-6b libpng-devel libtiff-devel freetype freetype-devel fontconfig-devel gd gd-devel kernel screen sysstat flex bison nss_ldap pam-devel compat-libstdc++-

二、解压、编译、安装redis_3.0:

tar zxvf redis-.tar.gz -C /usr/src/
cd /usr/src/redis-/
make && make install

三、创建redis相关目录:

mkdir -p /home/redis/log
mkdir -p /home/redis/pid
mkdir -p /home/redis/db
mkdir -p /etc/redis/

四、编辑redis.conf配置文件:

cp /usr/src/redis-/redis.conf /etc/redis/redis.conf
ln -s /etc/redis/redis.conf /etc/redis.conf
vim /etc/redis.conf
daemonize yes
pidfile "/home/redis/pid/redis.pid"
port
tcp-backlog
timeout
tcp-keepalive
loglevel notice
logfile "/home/redis/log/redis.log"
databases
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "dump.rdb"
dir "/home/redis/db"
requirepass "redis-Passw0rd!"
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay
repl-disable-tcp-nodelay no
slave-priority
rename-command CONFIG ""
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command KEYS ""
maxmemory 1G
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit
slowlog-log-slower-than
slowlog-max-len
latency-monitor-threshold
notify-keyspace-events ""
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-entries
list-max-ziplist-value 

zset-max-ziplist-entries
zset-max-ziplist-value
hll-sparse-max-bytes
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes

五、编写redis启动脚本:

vim /etc/init.d/redis
#!/bin/sh
# chkconfig:
# Description:        Start and Stop redis
# Provides:        redis
# Default-Start:
# Default-Stop:
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli
PIDFILE=/home/redis/pid/redis.pid
CONF="/etc/redis/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping Redis server..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep
done
echo "Redis is stopped"
fi
;;
restart|reload)
${} stop
${} start
;;
*)
echo
exit
esac

六、添加redis系统服务:

chmod a+x /etc/init.d/redis
chkconfig --add redis
chkconfig --level  redis on
chkconfig --list | grep redis

七、启动redis服务:

service redis start
ps -aux | grep redis
netstat -anptu | grep 

八、测试:

redis-cli -h  -a redis-Passw0rd!

九、防火墙启用6379端口:

iptables -A INPUT -p tcp --dport  -j ACCEPT
上一篇:python学习之路-7 模块configparser/xml/shutil/subprocess以及面向对象初级入门


下一篇:win7中VS2010中安装CSS3.0问题解决方法