独立缓存服务器: LinuxCentOS
Redis版本: 3.0
下面我们针对于Redis安装做下详细的记录:
编译和安装所需的包:
#yum install gcc tcl创建安装目录:贵州中医肝病医院http://3g.gyzygb.com/
#mkdir /usr/local/redis
解压:
#tar -zxvf 3.xx.tar.gz
#mv redis-3.xx redis3.0
#cd redis3.0安装(使用PREFIX指定安装目录):
#make PREFIX=/usr/local/redis install
安装完成后,可以看到/usr/local/redis目录下有一个bin目录,bin目录里就是redis的命令脚本:
redis-benchmark redis-check-aof redis-check-dumpredis-cli redis-server
将Redis配置成服务:
按上面的操作步骤,Redis的启动脚本为:/usr/local/src/redis3.0/utils/redis_init_script
将启动脚本复制到/etc/rc.d/init.d/目录下,并命名为redis贵州中医肝病医院http://3g.gyzygb.com/
#cp /usr/local/src/redis3.0/utils/redis_init_script/etc/rc.d/init.d/redis编辑/etc/rc.d/init.d/redis,修改相应配置,使之能注册成为服务:
#vi/etc/rc.d/init.d/redis
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.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
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
esac
查看以上redis服务脚本,关注标为橙色的几个属性,做如下几个修改的准备:
分布式的一些解决方案,有愿意了解的朋友可以找我们团队探讨
更多详细源码参考来源