zoukankan      html  css  js  c++  java
  • centos 下安装redis 通过shell脚本

     
    #! /bin/bash
    
    
    echo -e "开始安装redis服务
    "
    
    download_url=http://download.redis.io/releases/redis-4.0.2.tar.gz
    file_name=${download_url##*/}
    file_dir=${file_name%.tar.gz*}
    
    cd /usr/local/src
    
    if [ ! -f "/usr/local/src/${file_name}" ];then
        echo -e "包不存在 下载: "${download_url}
        wget ${download_url}
    fi
    
    tar -zxvf ${file_name}
    
    rm -rf /usr/local/redis
    mv ${file_dir} /usr/local/redis
    
    cd /usr/local/redis && make && make install 
    
    echo -e "配置初始化脚本
    "
    
    cp /usr/local/redis/utils/redis_init_script /etc/init.d/redis
    
    echo -e "创建目录/etc/redis
    "
    
    if [ ! -d "/etc/redis" ]; then
        mkdir /etc/redis
    fi
    
    echo -e "创建目录/var/redis/6379
    "
    
    if [ ! -d "/var/redis/6379" ]; then
        mkdir -p /var/redis/6379
    fi
    
    echo -e "复制配置文件到/etc/redis/6379.conf
    "
    
    cp /usr/local/redis/redis.conf /etc/redis/6379.conf
    
    
    echo "daemonize yes" >> /etc/redis/6379.conf
    echo "bind 0.0.0.0" >> /etc/redis/6379.conf
    echo "pidfile /var/run/redis_6379.pid" >> /etc/redis/6379.conf
    echo "port 6379" >> /etc/redis/6379.conf
    echo "dir /var/redis/6379" >> /etc/redis/6379.conf
    
    #echo "杀死旧redis进程
    "
    #ps -ef|grep redis|grep -v grep|cut -c 9-15|xargs kill -9
    #rm -rf /var/run/redis_6379.pid
    
    echo -e "启动 /etc/init.d/redis start|stop"
    /etc/init.d/redis start
    

      

    保存 添加执行条件 

    chmod +x  redis.sh

    链接: 去百度网盘下载 提取码: 8t15

  • 相关阅读:
    第01组 Alpha冲刺 (1/6)
    第01组(17) 需求分析报告
    第01组(17) 团队展示
    结对编程作业
    05 RDD编程
    第九次作业
    HDFS
    Hadoop安装 与 HDFS体系结构
    第三次作业
    作业2
  • 原文地址:https://www.cnblogs.com/brady-wang/p/12836306.html
Copyright © 2011-2022 走看看