Centos 7最小化redis部署

配置源

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

安装

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.3.tar.gz -C /usr/local/
sh-4.2# mv /usr/local/redis-5.0.3 /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 1
fi

if [ ! -f /usr/local/redis/redis.conf ]
  then
    echo "Redis program configuration file is not exist!"
    exit 2
fi

start() {
    nohup /usr/local/redis/src/redis-server /usr/local/redis/redis.conf &> /var/log/redis.log &
    if [ $? -ne 0 ]
      then
        echo "redis start failed. Please check the program directory."
          else
        echo "redis start-up success."
    fi
}

stop() {
    /usr/bin/kill -9 /usr/local/redis/src/redis-server &> /dev/null
    sleep 3
    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

原文地址:https://www.cnblogs.com/guge-94/p/10490697.html