首页 > 其他 > 详细

CentOS 6.5 下安装 Redis 2.8.7

时间:2015-06-14 16:34:51      阅读:230      评论:0      收藏:0      [点我收藏+]

wget http://download.redis.io/redis-stable.tar.gz

tar xvzf redis-stable.tar.gz

cd redis-stable

make

 

前面3步应该没有问题,主要的问题是执行make的时候,出现了异常。

异常一:

make[2]: cc: Command not found

异常原因:没有安装gcc

解决方案:yum install gcc-c++

 

异常二:

zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory

异常原因:一些编译依赖或原来编译遗留出现的问题

解决方案:make distclean。清理一下,然后再make。

 

 

在make成功以后,需要make test。在make test出现异常。

异常一:

couldn‘t execute "tclsh8.5": no such file or directory

异常原因:没有安装tcl

解决方案:yum install -y tcl。或者:

  1. wget http://downloads.sourceforge.net/tcl/tcl8.5.10-src.tar.gz 
  2. tar xzvf tcl8.5.10-src.tar.gz 
  3. cd tcl8.5.10/unix/
  4. ./configure 
  5. make&&make install

 

运行make test

#cd /home/sandea/redis-stable

#make test

在make test成功以后,make install

#make install

测试通过后安装,安装后会自动把redis-server,redis-cli,redis-benchmark,redis-check-aof,redis-check-dump复制到/usr/local/bin目录下

编辑redis.conf文件

#mkdir /etc/redis
#cp redis.conf /etc/redis/redis.conf
#vi /etc/redis/redis.conf

daemonize yes

pidfile /var/run/redis.pid

logfile /etc/redis/redis.log

编写自init.d脚本

#vi /etc/init.d/redis

内容如下:

###########################
#chkconfig: 2345 10 90
#description: Start and Stop redis
PATH=/usr/local/bin:/sbin:/usr/bin:/bin

REDISPORT=6379
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli

PIDFILE=/var/run/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
if [ "$?"="0" ]
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_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
esac
##############################

保存,给redis授权:

#chmod +x /etc/init.d/redis

设置开机自动启动服务:

#chkconfig redis on

启动服务:

#service redis start

停止服务:

#service redis stop

 

CentOS 6.5 下安装 Redis 2.8.7

原文:http://www.cnblogs.com/sandea/p/4575145.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!