下载
wget --quiet http://download.redis.io/releases/redis-2.8.24.tar.gz
安装
安装/配置过程中需要用到
gcc
,tcl
等软件包。直接通过yum安装即可
yum install -y tcl
yum groupinstall -y "development tools"
tar -xf redis-2.8.24.tar.gz
cd redis-2.8.24
make MALLOC=libc
make test
make install PREFIX=/usr/local/redis
配置
// 运行命令:
utils/install_server.sh
...
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /data/redis_data
Executable : /usr/local/redis/bin/redis-server
Cli Executable : /usr/local/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
## 重命名启动脚本
mv /etc/init.d/redis_6379 /etc/init.d/redis
启动脚本中有一点需要作如下修改:
vim /etc/init.d/redis
...
status)
# PID=$(cat $PIDFILE) #####
# if [ ! -x /proc/${PID} ] #####
if [ ! -f $PIDFILE ]
then
echo 'Redis is not running'
else
echo "Redis is running ..." #####
fi
;;
启动
chkconfig redis on
service redis restart
常见报错
执行make
命令时报错:
root@localhost:~/redis-2.8.24# make
cd src && make all
make[1]: Entering directory `/root/redis-2.8.24/src'
CC adlist.o
在包含自 adlist.c:34 的文件中:
zmalloc.h:50:31: 错误:jemalloc/jemalloc.h:没有那个文件或目录
zmalloc.h:55:2: 错误:#error "Newer version of jemalloc required"
make[1]: *** [adlist.o] 错误 1
make[1]: Leaving directory `/root/redis-2.8.24/src'
make: *** [all] 错误 2
解决:
## 在make后加上:"MALLOC=libc",即:
make MALLOC=libc