Ubuntu14.04server 下安装redis

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
[img]http://dl2.iteye.com/upload/attachment/0102/3941/135df476-8569-3450-8fc5-57ba93394503.jpg[/img]


sudo apt-get install gcc libc6-dev build-essential

cd /usr/local/redis
sudo make
sudo make test

提示以下信息

[img]http://dl2.iteye.com/upload/attachment/0102/3963/76d39ea2-a645-306c-b4df-f891856eb81d.jpg[/img]


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


如果报如下错误

[img]http://dl2.iteye.com/upload/attachment/0103/5320/1626fc6f-f9a7-3328-83ea-fc849379107f.jpg[/img]

make MALLOC=libc



3、启动Redis服务

find / -name 'redis*'


[img]http://dl2.iteye.com/upload/attachment/0102/3965/e2a34eb1-65d7-3ba8-a41d-45d2b94c953f.jpg[/img]

/usr/local/bin/redis-server



[img]http://dl2.iteye.com/upload/attachment/0102/3967/19ea3db5-aa37-31e3-9ae4-28853c8f7efa.jpg[/img]


========================================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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值