wget http://download.redis.io/releases/redis-2.8.7.tar.gz
tar xzf redis-2.8.7.tar.gz
cd redis-2.8.7
注意:make指令是需要linux下安装gcc的 如果没有gcc可以尝试安装
yum -y install gcc
make
mkdir /usr/redis
cd src
cp redis-server /usr/redis
cp redis-benchmark /usr/redis
cp redis-cli /usr/redis
cp /usr/softs/redis-2.8.7/redis.conf /usr/redis
cd /usr/redis
./redis-server redis.conf
设置redis开机自启
默认的redis.conf文件参数是前台启动的,修改daemonize no为daemonize yes则为后台启动。
vi /usr/redis/redis.conf
vi /etc/rc.d/init.d/redis
# chkconfig: 2345 90 10
# description: redis is a persistent key-value databaseis
PROGDIR=/usr/redis #安装路径
PROGNAME=redis-server
DAEMON=$PROGDIR/$PROGNAME
CONFIG=/usr/redis/redis.conf #redis 的配置文件路径
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
chmod +x /etc/rc.d/init.d/redis
chkconfig --add redis
chkconfig --level 345 redis on
chkconfig --list redis
执行该脚本后,就可以开始start|stop|restart|list你的服务了。
安装Redis
最新推荐文章于 2024-08-27 17:07:27 发布