redis - 00 在centos安装
1、redis 官方安装
$ wget http://download.redis.io/releases/redis-3.0.6.tar.gz
$ tar xzf redis-3.0.6.tar.gz
$ cd redis-3.0.6
$ make
2、测试redis
$ src/redis-server
$ src/redis-cli
3、进入安装目录的src文件夹下,有四个可执行文件redis-server、redis-benchmark、redis-cli和redis.conf,复制到同一个目录下
# mkdir /usr/redis
# cp redis-server /usr/redis
# cp redis-benchmark /usr/redis
# cp redis-cli /usr/redis
# cp ../redis.conf /usr/redis
# cd /usr/redis
4、再次测试redis
# cd /usr/redis
# ./redis-server redis.conf
5、后台服务
编辑 /etc/sysctl.conf , 添加一项 vm.overcommit_memory = 1,重启生效。
6、redis 加入服务
把redis脚本文件放在 /etc/rc.d/init.d/ 目录下
#!/bin/sh
#chkconfig: 345 86 14
#description: Startup and shutdown script for Redis
PROGDIR=/usr/redis #安装路径
PROGNAME=redis-server
DAEMON=$PROGDIR/$PROGNAME
CONFIG=/usr/redis/redis.conf
PIDFILE=/var/run/redis.pid
DESC="redis daemon"
SCRIPTNAME=/etc/rc.d/init.d/redis
start()
{
if test -x $DAEMON
then
echo -e "Starting $DESC: $PROGNAME"
if $DAEMON $CONFIG
then
echo -e "OK"
else
echo -e "failed"
fi
else
echo -e "Couldn't find Redis Server ($DAEMON)"
fi
}
stop()
{
if test -e $PIDFILE
then
echo -e "Stopping $DESC: $PROGNAME"
if kill `cat $PIDFILE`
then
echo -e "OK"
else
echo -e "failed"
fi
else
echo -e "No Redis Server ($DAEMON) running"
fi
}
restart()
{
echo -e "Restarting $DESC: $PROGNAME"
stop
start
}
list()
{
ps aux | grep $PROGNAME
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
list)
list
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|list}" >&2
exit 1
;;
esac
exit 0
$mkdir /etc/rc.d/init.d/redis
$vi /etc/rc.d/init.d/redis
# chmod +x /etc/rc.d/init.d/redis
# chkconfig --add redis
# chkconfig --level 345 redis on
# chkconfig --list redis
------------------------------------------其他解决———————————————————————
需要tcl 8.5 那就安装吧
># yum install tcl
># yum install gcc
># make MALLOC=libc
(清理make)
># make distclean
># make
># sudo make install
># cp redis.conf /etc
install的时候,redis的命令会被拷贝到/usr/local/bin下面
sudo useradd redis
sudo mkdir -p /var/lib/redis
sudo mkdir -p /var/log/redis
sudo chown redis.redis /var/lib/redis #db文件放在这里,要修改redis.conf
sudo chown redis.redis /var/log/redis