redis安装配置

安装

http://redis.io/download 这儿有,不多说。要注意的一点,redis没有make install;所以安装包直接放在/usr/local/redis目录下就好了。

配置

cd /usr/local/redis
cp redis.conf /etc/redis.conf
cd /usr/local/redis/src
ln -s redis-cli /usr/bin/redis-cli
ln -s redis-server /usr/bin/redis-server

对配置文件进行修改

daemonize yes
logfile /dev/null
# 设置最大内存
maxmemory 

开机启动脚本

#!/bin/bash
source /etc/init.d/functions
BIN=/usr/bin
CONFIG=/etc/redis.conf
PIDFILE=/var/run/redis.pid

[ -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

存为redis文件,放到/etc/init.d/redis, chmod +x redis

标签: none

添加新评论