侧边栏壁纸
博主头像
高大北博主等级

所有的再见中,我最喜欢明天见

  • 累计撰写 208 篇文章
  • 累计创建 151 个标签
  • 累计收到 20 条评论
标签搜索

目 录CONTENT

文章目录

centos7一键离线安装脚本-redis

高大北
2022-04-18 / 0 评论 / 0 点赞 / 307 阅读 / 2,033 字 / 正在检测是否收录...

使用说明

source install_redis.sh

install_redis.sh接收$1参数,可指定安装路径,默认安装路径为/usr/local

install_redis.sh

#!/bin/bash

directory=$1
current_dir=`pwd`

function select_installation_directory(){
  if [[ -z ${directory} ]];
  then
    directory='/usr/local'
  fi
}

function check_gcc(){
  if [[ -z $(rpm -qa | grep ^gcc | grep -v grep) ]];
  then
    cd gcc && rpm -Uvh *.rpm --nodeps --force && cd ..
  fi
}

function install_redis(){
  tar -zxvf "${current_dir}"/redis-5.0.3.tar.gz
  cd redis-5.0.3 && make install PREFIX=${directory}/redis
  cp "${current_dir}"/redis-5.0.3/redis.conf ${directory}/redis/bin/
  sed -i 's/^daemonize no/daemonize yes/g' ${directory}/redis/bin/redis.conf
  sed -i 's/^protected-mode yes/protected-mode no/g' ${directory}/redis/bin/redis.conf
  sed -i 's/^bind 127.0.0.1/# bind 127.0.0.1/g' ${directory}/redis/bin/redis.conf
  #${directory}/redis/bin/redis-server ${directory}/redis/bin/redis.conf
}

function install_redis(){
  tar -zxvf "${current_dir}"/redis-5.0.3.tar.gz
  cd redis-5.0.3 && make install PREFIX=${directory}/redis
  cp "${current_dir}"/redis-5.0.3/redis.conf ${directory}/redis/bin/
  sed -i 's/^daemonize no/daemonize yes/g' ${directory}/redis/bin/redis.conf
  sed -i 's/^protected-mode yes/protected-mode no/g' ${directory}/redis/bin/redis.conf
  sed -i 's/^bind 127.0.0.1/# bind 127.0.0.1/g' ${directory}/redis/bin/redis.conf
  #${directory}/redis/bin/redis-server ${directory}/redis/bin/redis.conf
}

function powered_up_redis(){
  sed -i "s:^EXEC=/usr/local/bin/redis-server:EXEC=${directory}/redis/bin/redis-server:g" ./utils/redis_init_script
  sed -i "s:^CLIEXEC=/usr/local/bin/redis-cli:CLIEXEC=${directory}/redis/bin/redis-cli:g" ./utils/redis_init_script
  sed -i  "$(sed -n '/^CONF=/=' ./utils/redis_init_script)a  CONF=${directory}/redis/bin/redis.conf" ./utils/redis_init_script
  cp ./utils/redis_init_script /etc/init.d/redis
  service redis start
  chkconfig redis on
  cd ..
}

function Main(){
  select_installation_directory;
  check_gcc;
  install_redis;
  powered_up_redis;
}
Main;

资源下载

https://www.sky12580.cn/upload/2022/04/redis.zip

0

评论区