1、下载
查看版本http://download.redis.io/releases/
wget http://download.redis.io/releases/redis-2.8.9.tar.gz
$ sudo tar xzf redis-2.8.9.tar.gz -C /usr/local
$ sudo mv redis-2.8.9 redis
make失败,是系统中还未安装gcc,那么需要安装gcc
sudo apt-get install gcc libc6-dev build-essential
cd /usr/local/redis
sudo make
sudo make test
提示以下信息
sudo wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
sudo tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
sudo ./configure
sudo make
sudo make install
#进入redis目录
cd /usr/local/redis
sudo make test
安装成功进入/usr/local/redis/bin可以看到
redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server
如果报如下错误
make MALLOC=libc
3、启动Redis服务
find / -name 'redis*'
/usr/local/bin/redis-server
========================================centos====
yum -y install gcc
make
报错
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
原因
http://www.phperz.com/article/14/1219/42002.html
解决
make MALLOC=libc
随机启动
cd ~/ide
touch redis
#!/bin/sh
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
#
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="/root/ide/redis-2.8.6/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
##############################
设置为开机自启动
cp ~/ide/redis /etc/init.d/redis
chkconfig redisd on