zoukankan      html  css  js  c++  java
  • redis

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://qiangsh.blog.51cto.com/3510397/1733029

    1、安装编译工具

    yum -y install wget  make gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel kernel keyutils  patch perl

    2、安装tcl组件包(安装Redis需要tcl支持)

    cd /usr/local/src
    wget 
    http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz
    tar -zxvf tcl8.6.3-src.tar.gz
    cd tcl8.6.3/unix/
    ./configure
    make &&make install

    3、安装Redis

    cd /usr/local/src
    w
    get http://download.redis.io/releases/redis-2.8.24.tar.gz
    tar zxvf redis-2.8.24.tar.gz

    mv redis-2.8.24  /usr/local/redis 

    cd /usr/local/redis 

    make &&make install

    ls /usr/local/bin/

    #######如果有以下文件则安装成功#######

    redis-benchmark

    redis-check-aof

    redis-check-dump

    redis-cli

    redis-sentinel

    redis-server

    #######测试Redis,可以对redis进行加大的测试#######

    cd src
    make test 

    #######配置redis#######

    ln -s /usr/local/redis/redis.conf /etc/redis.conf

    vi /etc/redis.conf

    我只修改了如下两项:

    daemonize yes #redis将以守护进程的方式运行,默认为no会暂用你的终端
    timeout 300 #当 客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能

    4、设置自动启动

    vi /etc/init.d/redis

    代码如下:


    #!/bin/sh
    #
    # redis        Startup script for Redis Server
    #
    # chkconfig: - 80 12
    # description: Redis is an open source, advanced key-value store.
    #
    # processname: redis-server
    # config: /etc/redis.conf
    # pidfile: /var/run/redis.pid
    source /etc/init.d/functions
    BIN="/usr/local/bin/"
    CONFIG="/usr/local/redis/redis.conf"
    PIDFILE="/var/run/redis.pid"
    ### Read configuration
    [ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
    RETVAL=0
    prog="redis-server"
    desc="Redis Server"
    start() {
            if [ -e $PIDFILE ];then
                 echo "$desc already running...."
                 exit 1
            fi
            echo -n $"Starting $desc: "
            daemon $BIN/$prog $CONFIG
            RETVAL=$?
            echo
            [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
            return $RETVAL
    }
    stop() {
            echo -n $"Stop $desc: "
            killproc $prog
            RETVAL=$?
            echo
            [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE
            return $RETVAL
    }
    restart() {
            stop
            start
    }
    case "$1" in
      start)
            start
            ;;
      stop)
            stop
            ;;
      restart)
            restart
            ;;
      condrestart)
            [ -e /var/lock/subsys/$prog ] && restart
            RETVAL=$?
            ;;
      status)
            status $prog
            RETVAL=$?
            ;;
       *)
            echo $"Usage: $0 {start|stop|restart|condrestart|status}"
            RETVAL=1
    esac
    exit $RETVAL

    5、启动或关闭服务

    chmod +x /etc/init.d/redis

    service redis start
    service redis stop


    6、使用redis

    [root@localhost redis]# cd /usr/local/bin
    [root@localhost bin]# ./redis-cli
    127.0.0.1:6379> set foo bar
    OK
    127.0.0.1:6379> get foo
    "bar"
    127.0.0.1:6379>

     

    本文出自 “IT·奋斗” 博客,请务必保留此出处http://qiangsh.blog.51cto.com/3510397/1733029

  • 相关阅读:
    JS高级拖拽
    JS高级Date类
    JS高级闭包
    JS笔记整理
    JS高级解决函数内的this指向
    JS高级事件委托
    JS高级 事件对象
    JS中级面向对象
    JS中级
    JS高级
  • 原文地址:https://www.cnblogs.com/Hei-po/p/6928181.html
Copyright © 2011-2022 走看看