You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.0 KiB

1、将所需包redis-2.8.16.tar.gz 放到/usr/local/software/路径下
2、安装redis
cd /usr/local/software/
tar zxvf redis-2.8.16.tar.gz
mv redis-2.8.16 /usr/local/redis
cd redis
make MALLOC=libc
make install
3、设置Redis的配置文件
vi /usr/local/redis/redis.conf
找到daemonize no修改为daemonize yes
找到
save 900 1
save 300 10
save 60 10000
将这三行前都加上#号变为
#save 900 1
#save 300 10
#save 60 10000
4、设置Redis开机自启
vi /etc/rc.d/init.d/redis
#!/bin/bash
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 80 12
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# pidfile: /var/run/redis.pid
source /etc/init.d/functions
BIN="/usr/local/bin"
CONFIG="/usr/local/redis/redis.conf"
PIDFILE="/var/run/redis.pid"
### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
RETVAL=0
prog="redis-server"
desc="Redis Server"
start() {
if [ -e $PIDFILE ];then
echo "$desc already running...."
exit 1
fi
echo -n $"Starting $desc: "
daemon $BIN/$prog $CONFIG
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}
stop() {
echo -n $"Stop $desc: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
5、保存退出
chmod 777 /etc/rc.d/init.d/redis
chkconfig redis on
service redis start