安装redis 3 cluster

一.系统版本和软件版本信息

1.系统版本和内核信息
    RHEL 6.3 X86_64  2.6.32-279.el6.x86_64 
   
2.软件版本信息
    tcl-8.5.7-6.el6.x86_64
    ruby-1.8.7.352-7.el6_2.x86_64
    redis-3.0.0
    rubygems-2.4.6
    redis-3.2.1.gem

二:安装

Redis cluster的集群管理命令依赖ruby,所以需要先安装相应的ruby软件

    1.安装ruby和tcl
        系统自带了tcl和ruby,不需要在单独的安装
       
    2.安装rubygems-2.4.6
        该软件安装依赖ruby
        cd rubygems-2.4.6
        ruby setup.rb
        看见RubyGems 2.4.6 installed 表明安装成功,默认安装在/usr/bin/gem
       
        注意:
        如果在RubyGems 2.4.6 installed后提示
        ERROR:  While executing gem … (Gem::DocumentError)
                RDoc is not installed: no such file to load — rdoc/rdoc 
        不影响安装成功,此处是因为没有安装ruby-rdoc包的原因
        yum install ruby-rdoc即可,否则在安装redis-3.2.1.gem也会提示
       
    3.安装redis-3.2.1.gem
        该软件安装依赖rubygems
        gem install -l ./redis-3.2.1.gem
        看见Successfully installed redis-3.2.1 表明安装成功
       
        注意:
        必须使用-l参数,否则安装不成功
       
    4.安装redis-3.0.0
   
        注意:
        必须把tcl,ruby,gem等安装成功才能安装,否则即使redis安装成功了,在使用redis-trib.rb创建集群的时候也会失败.
       
        cd redis-3.0.0
        make && make install
        cp src/redis-trib.rb /usr/bin
        默认安装成功后redis-server,redis-cli在/usr/local/bin下.
        cp redis.conf /tol/app/redis/6379/etc/redis-6379.conf
        修改相应的port,daemon yes,cluster-enabled yes
       
        cp utils/redis_init_script /etc/init.d/redis-6379
        chmod +x /etc/init.d/redis-6379
       
        vim /etc/init.d/redis-6379
        #!/bin/sh下增加
            # chkconfig:   – 85 15
            # description:  Redis server
            修改相应的port端口
           
            完整内容如下:
           
                #!/bin/bash
                #
                # chkconfig:   – 85 15
                # description:  Redis server
                # Simple Redis init.d script conceived to work on Linux systems
                # as it does use of the /proc filesystem.

                REDISPORT=6379
                EXEC=/usr/local/bin/redis-server
                CLIEXEC=/usr/local/bin/redis-cli

                PIDFILE=”/tol/app/redis/${REDISPORT}/run/redis.pid”
                CONF=”/tol/app/redis/${REDISPORT}/etc/redis-${REDISPORT}.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
                    ;;
                    stop)
                    if [ ! -f $PIDFILE ]
                    then
                        echo “$PIDFILE does not exist, process is not running”
                    else
                        PID=$(cat $PIDFILE)
                        echo “Stopping …”
                        $CLIEXEC -p $REDISPORT shutdown
                        while [ -x /proc/${PID} ]
                        do
                            echo “Waiting for Redis to shutdown …”
                            sleep 1
                        done
                        echo “Redis stopped”
                    fi
                    ;;
                    *)
                    echo “Please use start or stop as first argument”
                    ;;
                esac
               
    5.启动redis和开机启动redis
        /etc/init.d/redis-6379 start
        chkconfig redis-6379 on
   
    6.检查redis的运行信息
        redis-cli -c -p 6379
        127.0.0.1>info
到此单个实例的redis已经运行,复制相应的redis配置文件和init.d启动6380以及其他的端口实例

此条目发表在Redis分类目录,贴了, 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注