CENTOS7 源码安装Redis,并配置
2017-10-26 本文已影响0人
旋转马达
一:从Redis的官方网站下载Redis的源码
http://download.redis.io/releases/redis-3.2.11.tar.gz
二:编译Redis源码
make
三:安装Redis
make install
四:配置服务(可选)
将redis源码目录下的utils文件夹中的redis_init_script 脚本copy一份到 /etc/init.d/redisd当中,配置其中的安装路径
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
# chkconfig: 2345 10 90
# description: Start and Stop redis
REDISPORT=6379
#将以下四个配置修改为自己的目录,注意PIDFILE不要去新建这个文件
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_6379.pid
CONF=/etc/redis/redis.conf
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
然后使用chkconfig命令使其成为一个服务
chkconfig redisd on
接下来就可以使用以下命令运行redis服务
service redisd start
当然这种方式仅限于service命令管理服务,如果是centos7的systemctl命令管理服务,这个配置不起作用,也可以配置systemctl管理redis服务,具体细节可以百度