zoukankan      html  css  js  c++  java
  • redis单机版安装

    #!/bin/bash
    
    #######################install redis scripts#############################################
    
    REDIS_VERSION='2.8.13'
    REDIS_GZIP='redis-'$REDIS_VERSION'.tar.gz'
    REDIS_URL='http://download.redis.io/releases/'$REDIS_GZIP
    REDIS_HOME='/usr/local/redis/latest'
    
    REDIS_PORT='6379'
    REDIS_SENTINEL_PORT='26379'
    
    ####################functions ----------------------------------------------
    function logMessageToFile(){
            echo '[ '$1' ] - ['$(date "+%Y-%m-%d %H:%M:%S")'] - '$2 >> /var/log/redis.log
    }
    
    function installRedis(){
    logMessageToFile "INFO"  'installRedis'
    mkdir /usr/local/redis
    cd /usr/local/redis
    logMessageToFile "DEBUG" "Downloading redis archive from: $REDIS_URL"
    wget $REDIS_URL
    tar xzf $REDIS_GZIP
    rm -f $REDIS_GZIP
    ln -s /usr/local/redis/redis* latest
    cd $REDIS_HOME
    yum install -y gcc-c++ jemalloc-devel
    checkRPMWasInstalled gcc-c++
    checkRPMWasInstalled jemalloc-devel
    logMessageToFile "DEBUG" "Compiling redis..."
    make
    }
    
    function configureRedis(){
    logMessageToFile "INFO"  "configureRedis"
    mkdir /etc/redis
    mkdir /var/redis
    cd $REDIS_HOME
    cp src/redis-server /usr/local/bin
    cp src/redis-cli /usr/local/bin
    cp utils/redis_init_script /etc/init.d/redis_$REDIS_PORT
    sed -i '2i # chkconfig: 234 95 20' /etc/init.d/redis_$REDIS_PORT
    sed -i '3i # description:  Redis is a persistent key-value database' /etc/init.d/redis_$REDIS_PORT
    sed -i '4i # processname: redis' /etc/init.d/redis_$REDIS_PORT
    sed 's/^REDISPORT=.*/REDISPORT='$REDIS_PORT'/' -i /etc/init.d/redis_$REDIS_PORT
    cp redis.conf /etc/redis/$REDIS_PORT.conf
    mkdir /var/redis/$REDIS_PORT
    sed 's/^daemonize .*/daemonize yes/' -i /etc/redis/$REDIS_PORT.conf
    sed 's/^pidfile .*/pidfile /var/run/redis_'$REDIS_PORT'.pid/' -i /etc/redis/$REDIS_PORT.conf
    sed 's/^port .*/port '$REDIS_PORT'/' -i /etc/redis/$REDIS_PORT.conf
    sed 's/^loglevel .*/loglevel notice/' -i /etc/redis/$REDIS_PORT.conf
    sed 's/^logfile .*/logfile /var/log/redis_'$REDIS_PORT'.log/' -i /etc/redis/$REDIS_PORT.conf
    sed 's/^dir .*/dir /var/redis/'$REDIS_PORT'/' -i /etc/redis/$REDIS_PORT.conf
    chkconfig --add redis_$REDIS_PORT  
    chkconfig --level 234 redis_$REDIS_PORT on
    
    }
    
    function startRedis(){
    logMessageToFile "INFO"  "Starting redis on port $REDIS_PORT..."
    service redis_$REDIS_PORT start
    }
    
    function installAndConfigureRedis(){
    logMessageToFile "INFO" "installAndConfigureRedis"
    installRedis
    configureRedis
    }
    
    installAndConfigureRedis
    startRedis
    在尝试学习新的语言之前先理解这门语言的设计原理能够让你在探索这门新语言时保持一个清醒而且开发的状态。
  • 相关阅读:
    Solr使用初探——SolrJ的使用
    Solr使用初探——Solr的安装环境与配置
    solr教程,值得刚接触搜索开发人员一看
    2013已过去,迎来2014,我们该如何规划自己的生活及职业生涯
    搭建集群必备:windows如何使用Xshell远程连接(SSH)Linux
    集群搭建:主机宽带拨号上网,虚拟机使用桥接模式,该如何ping通外网
    什么是Zookeeper,Zookeeper的作用是什么,在Hadoop及hbase中具体作用是什么
    如何搭建云平台,云平台搭建,需要学习什么云技术
    hadoop入门必备基础知识
    如何进行Hadoop二次开发指导视频下载
  • 原文地址:https://www.cnblogs.com/jackchen001/p/6807038.html
Copyright © 2011-2022 走看看