• 第十九章 Redis6.2.1脚本安装


    #!/usr/bin/bash
    # Author:jh
    # Time:2021-04-19  17:23:05
    # Name:redis-install.sh
    # Version: 1.0
    # Discription: To  
    
    #1.设置变量
    data_dir=/data/redis
    software_dir=/opt/software
    redsis_config_dir=/etc/redis
    reids_rely_software=(cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make tcl)
    
    #2.创建目录
    mkdir $data_dir
    mkdir $software_dir -p
    mkdir $redsis_config_dir
    
    #3.下载redis安装包
    cd $software_dir
    wget https://download.redis.io/releases/redis-6.2.1.tar.gz
    
    #4.安装依赖
    for i in ${reids_rely_software[*]}
    do
        rpm -q $i &>/dev/null
        if [ $? -eq 0 ];then
            echo "$i is installed" 
        else
            yum -y install $i  &>/dev/null                                     
            action "$i is installing"  /usr/bin/true
        fi         
    done
    
    #5.更新gcc版本
    yum -y install centos-release-scl
    yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
    
    scl enable devtoolset-9 bash
    echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
    
    #6.编译安装
    tar zxf redis-6.2.1.tar.gz  -C /opt/
    cd /opt/redis-6.2.1/
    make && make install
    
    #7.修改配置文件
    cp redis.conf  /etc/redis/
    
    #8.配置system启动
    cat >/etc/systemd/system/redis.service<<EOF
    [Unit]
    Description=Redis
    After=network.target
    
    [Service]
    Type=forking
    ExecStart=/opt/redis-6.2.1/src/redis-server /etc/redis/redis.conf
    #ExecReload=/opt/redis-6.2.1/src/redis-server -s reload
    #ExecStop=/opt/redis-6.2.1/src/redis-server -s stop
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    #9.重启redis
    systemctl daemon-reload
    systemctl  enable  redis.service 
    systemctl restart redis
    
    #10.查看服务状态
    systemctl status redis
    netstat  -lntp
    
  • 相关阅读:
    2016第17周四
    2016第17周三
    2016第17周二
    OSGI框架学习
    2016年第16周日
    2016第16周六
    如何培养技术洞见力
    2016第15周四
    深入浅出ClassLoader
    Linux智能小开关rfkill
  • 原文地址:https://www.cnblogs.com/jhno1/p/15689306.html
Copyright © 2020-2023  润新知