• centos 安装redis2.8.9


    1没有安装gcc

      yum install gcc-c++

    2. 安装tcl

       yum install -y tcl

    3.安装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

    4.编辑redis.conf文件

       把 daemonize no 改成 yes。(redis以守护进程的方式运行

       然后把redis.cong复制到/etx

       cp redis.conf /etc

    5.编写一个自启动脚本(网上摘抄)

       

    ###########################
    PATH=/usr/local/bin:/sbin:/usr/bin:/bin
       
    REDISPORT=6379
    EXEC=/usr/local/bin/redis-server
    REDIS_CLI=/usr/local/bin/redis-cli
       
    PIDFILE=/var/run/redis.pid
    CONF="/etc/redis.conf"
       
    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
    ##############################
    

     把这段保存成redis,放到/etc/init.d/下面

       chmod +x /etc/init.d/redis (修改权限)

       sudo chkconfig redis on

    6.启动和停止

       service redis start #或者 /etc/init.d/redis start
       service redis stop #或者 /etc/init.d/redis stop

    7.测试  

       redis-cli
       redis 127.0.0.1:6379> set name fu
       OK
       redis 127.0.0.1:6379> get name
       "fu"
       redis 127.0.0.1:6379> exit

    8.哦了,继续学习,加油!

  • 相关阅读:
    数据库学习笔记5---MySQL字符串函数、日期时间函数
    关于hibernate的AnnotationConfiguration的问题
    浅谈Java web 中request的setAttribute()用法
    JAVA常见面试题之Forward和Redirect的区别
    JSP页面中<%!%>与<%%>与<%=%>
    Servlet的生命周期
    JavaEE学习路线图
    java web项目WEB-INF与META-INF的作用
    iOS-申请邓白氏编码的超详细流程介绍
    从高版本JDK换成低版本JDK报错
  • 原文地址:https://www.cnblogs.com/781811964-Fighter/p/4262821.html
Copyright © 2020-2023  润新知