Centos 7最小化redis部署

时间:2021-06-06 08:20:50

配置源

[GuGe]
name=GuGe
baseurl=ftp://192.168.1.82
gpgcheck=
enable=

安装

sh-4.2# yum -y install gcc gcc-c++ wget
sh-4.2# wget http://download.redis.io/releases/redis-5.0.3.tar.gz
sh-4.2# tar -zxf redis-5.0..tar.gz -C /usr/local/
sh-4.2# mv /usr/local/redis-5.0. /usr/local/redis
sh-4.2# cd /usr/local/redis
sh-4.2# make

简单启动脚本

sh-4.2# cat /etc/init.d/redis
#!/bin/bash
source /etc/profile
if [ ! -d /usr/local/redis ]
then
echo "Redis program directory is not exist!"
exit
fi if [ ! -f /usr/local/redis/redis.conf ]
then
echo "Redis program configuration file is not exist!"
exit
fi start() {
nohup /usr/local/redis/src/redis-server /usr/local/redis/redis.conf &> /var/log/redis.log &
if [ $? -ne ]
then
echo "redis start failed. Please check the program directory."
else
echo "redis start-up success."
fi
} stop() {
/usr/bin/kill - /usr/local/redis/src/redis-server &> /dev/null
sleep
echo "The program to stop."
} case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: {start|stop|restart}"
esac

启动

sh-4.2# chmod a+x /etc/rc.local
sh-4.2# chmod a+x /etc/init.d/redis
sh-4.2# /etc/init.d/redis start
sh-4.2# echo "/etc/init.d/redis start" >> /etc/rc.local

参考地址

https://redis.io/download