• 第十九章 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
    
  • 相关阅读:
    vue2手写vuex
    200.岛屿数量(DFS M-岛屿系列)
    739.每日温度(栈M)
    150.逆波兰表达式求值(栈M)
    20.有效的括号(栈L)
    前端性能优化与SEO优化整理
    Typescript:类型断言
    如何在浏览器中快速调试Typescript
    Typescript:枚举
    Typescript:接口
  • 原文地址:https://www.cnblogs.com/jhno1/p/15689306.html
Copyright © 2020-2023  润新知