• 【redis】centos redis 安装


    .安装tcl支持

    yum install tcl 
    

      

    下载安装:redis

    wget http://download.redis.io/releases/redis-2.8.9.tar.gz  
    $ tar xzf redis-2.8.9.tar.gz  
    $ cd redis-2.8.9  
    $ make  
    $ make test  
    $ make install 
    

      测试通过后安装,安装后会自动把redis-server,redis-cli,redis-benchmark,redis-check-aof,redis-check-dump复制到/usr/local/bin目录下。

    编辑redis.conf文件

    修改daemonize no改成yes。

    我们手动复制redis.conf到/etc/redis(新建redis目录)目录下

    cp redis.conf /etc 

    编写自init.d脚本

    ###########################
    #chkconfig: 2345 10 90
    #description: Start and Stop redis
    PATH=/usr/local/bin:/sbin:/usr/bin:/bin
       
    REDISPORT=6379 //自己设置为准
    EXEC=/usr/local/bin/redis-server //根据 redis安装 配置
    REDIS_CLI=/usr/local/bin/redis-cli  //根据 redis安装 配置
       
    PIDFILE=/var/run/redis.pid 
    CONF="/etc/redis/redis.conf"  //根据 redis安装 配置
       
    case "$1" in
        start)
            if [ -f $PIDFILE ]
            then
                    echo "$PIDFILE exists, process is already running or crashed"
            else
                    echo "Starting Redis server..."
                    $EXEC $CONF
            fi
            if [ "$?"="0" ] 
            then
                  echo "Redis is running..."
            fi
            ;;
        stop)
            if [ ! -f $PIDFILE ]
            then
                    echo "$PIDFILE does not exist, process is not running"
            else
                    PID=$(cat $PIDFILE)
                    echo "Stopping ..."
                    $REDIS_CLI -p $REDISPORT SHUTDOWN
                    while [ -x ${PIDFILE} ]
                   do
                        echo "Waiting for Redis to shutdown ..."
                        sleep 1
                    done
                    echo "Redis stopped"
            fi
            ;;
       restart|force-reload)
            ${0} stop
            ${0} start
            ;;
      *)
        echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
            exit 1
    esac
    ##############################
    

      

    修改权限,可以运行

    chmod +x /etc/init.d/redis 
    chkconfig --add redis
    chkconfig --level 345 redis on
    

      

    启动redis服务

    redis-server
    redis-server /etc/redis/redis.conf &
    service redis start
    

    查看redis服务监听的地址和端口

    # netstat -tnlp |grep redis
    tcp        0      0 0.0.0.0:6379                0.0.0.0:*                   LISTEN      25350/redis-server
    

     

  • 相关阅读:
    [BZOJ3671][UOJ#6][NOI2014]随机数生成器
    [BZOJ3670][UOJ#5][NOI2014]动物园
    [UOJ#131][BZOJ4199][NOI2015]品酒大会
    [BZOJ4530][Bjoi2014]大融合 LCT + 启发式合并
    有趣的题目名称,有趣的题目
    [BZOJ2959]长跑——新技能:LCT+缩圈
    贴一下WC总结里提到的那道裸题吧。。。
    System and method for assigning a message
    http请求
    jQuery 语法
  • 原文地址:https://www.cnblogs.com/merlini/p/4028651.html
Copyright © 2020-2023  润新知