zoukankan      html  css  js  c++  java
  • 基于redis 3.x搭建集群环境

    由于我团队开发的在线坐席系统,即将面对线上每周3000W的下行投放客户,产品的咨询量可能会很大,基于前期,200W的投放时,前10分钟,大概800问题量,平均一个客户大概8个问题,也就是说每分钟10个客户,折算3000W的话,就是每分钟150客户。系统容量应该问题不是太大,考虑一下极端情况(叠加效应),或者留下富余5倍,也就不到800吧,我们的生产环境,需要扩容消费者服务器,redis作为调度,需要扩容,由现在的一主从升级到一个集群(3对主从的cluster)。

    这里大概记录下我们开发环境的redis集群的配置和安装过程,这些属于运维的工作,但是也是系统架构的范畴,这些若没有实战的经验,不要和我说什么架构设计。。。我就是搞这个的,我要对我的系统负责,但是又不会出现系统的过度设计。

    有三台机器,准备搭建redis集群环境,redis的版本是3.2.8,源码安装,安装过程略去。

    10.90.7.2
    10.90.7.10
    10.90.2.102

    每个上面部署两个redis的实例,端口配置信息如下:

    10.90.7.2 7000/7010
    10.90.7.10 7001/7011
    10.90.2.102 7002/7012

    三台的redis的配置采用近乎一样的配置,除了因为端口的不同造成的一点点差异。这里拿10.90.7.2的配置7000为例:

    在/opt/redis-3.2.8下面创建目录tkcluster。将/opt/redis-3.2.8下面的redis.conf文件copy到tkcluster目录下,重命名为7000.conf,修改的内容如下,其他的采用默认值。

    bind 10.90.7.2
    protected-mode no
    port 7000
    daemonize yes
    pidfile /var/run/redis_7000.pid
    appendonly yes
    appendfilename "appendonly7000.aof"
    cluster-enabled yes
    cluster-config-file nodes-7000.conf
    cluster-node-timeout 15000
    notify-keyspace-events Ex

    配置完后,copy一下7000.conf到7010.conf,将上述相应的7000改成7010的参数即可完成7010.conf的配置。为了方便启动redis-server。写一个简单shell脚本:

    #!/bin/bash
    
    /opt/redis-3.2.8/src/redis-server 7000.conf
    echo "status from 7000: $?"
    sleep 5
    /opt/redis-3.2.8/src/redis-server 7010.conf
    echo "status from 7010: $?"

    运行一下后,成功。得到文件列表:

    [root@localhost tkcluster]# ll
    总计 116
    -rw-r--r-- 1 root root 46695 11-21 15:11 7000.conf
    -rw-r--r-- 1 root root 46684 11-21 15:11 7010.conf
    -rw-r--r-- 1 root root    54 11-22 19:10 appendonly7000.aof
    -rw-r--r-- 1 root root     0 11-22 18:43 appendonly7010.aof
    -rw-r--r-- 1 root root    90 11-22 19:10 dump.rdb
    -rw-r--r-- 1 root root   739 11-22 18:43 nodes-7000.conf
    -rw-r--r-- 1 root root   739 11-22 18:43 nodes-7010.conf
    -rwxr-xr-x 1 root root   166 11-21 14:59 stcluster.sh

    检查下,集群创建的指令是否能工作:

    [root@bogon src]# ./redis-trib.rb --help
    /usr/bin/env: ruby: 没有那个文件或目录

    系统里面没有ruby这个环境,需要安装一下。

    这个过程有点让人头疼,开始,在10.90.7.10的机器上进行安装,通过yum,下面是我遇到的问题

    [root@bogon src]# yum install -y ruby

    源找到了,很快安装成功。继续尝试:

    [root@bogon src]# ./redis-trib.rb --help
    /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError)
            from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
            from ./redis-trib.rb:25:in `<main>'

    这个错误,呵呵,熟悉ruby的话,很容易看出来,是ruby的环境需要访问redis,但是系统里面没有ruby的redis客户端程序,需要安装一下ruby的redis客户端插件。

    [root@bogon src]# gem install redis
    Fetching: redis-4.0.1.gem (100%)
    ERROR:  Error installing redis:
            redis requires Ruby version >= 2.2.2.

    这个错误,是因为ruby版本太低,需要升级,采用下面的方式可以完成:

    [root@bogon src]# curl -L get.rvm.io | bash -s stable 
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   194  100   194    0     0    194      0  0:00:01 --:--:--  0:00:01   249
    100 24090  100 24090    0     0  24090      0  0:00:01  0:00:01 --:--:-- 25304
    Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
    Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
    curl: (22) The requested URL returned error: 503
    
    Could not download 'https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc'.
      curl returned status '22'.
    
    Creating group 'rvm'
    
    Installing RVM to /usr/local/rvm/
    Installation of RVM in /usr/local/rvm/ is almost complete:
    
      * First you need to add all users that will be using rvm to 'rvm' group,
        and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.
    
      * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
        in all your open shell windows, in rare cases you need to reopen all shell windows.

    执行完成后,按照上面的提示,首先推出ssh,然后再登陆ssh。然后执行source /etc/profile.d/rvm.sh指令。接下来执行一下rvm list known指令,看看当前查看rvm库中已知的ruby版本

    [root@bogon redis-3.2.8]# rvm list known
    # MRI Rubies
    [ruby-]1.8.6[-p420]
    [ruby-]1.8.7[-head] # security released on head
    [ruby-]1.9.1[-p431]
    [ruby-]1.9.2[-p330]
    [ruby-]1.9.3[-p551]
    [ruby-]2.0.0[-p648]
    [ruby-]2.1[.10]
    [ruby-]2.2[.7]
    [ruby-]2.3[.4]
    [ruby-]2.4[.1]
    ruby-head
    
    # for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
    
    # JRuby
    jruby-1.6[.8]
    jruby-1.7[.27]
    jruby[-9.1.13.0]
    jruby-head
    
    # Rubinius
    rbx-1[.4.3]
    rbx-2.3[.0]
    rbx-2.4[.1]
    rbx-2[.5.8]
    rbx-3[.84]
    rbx-head
    
    # Opal
    opal
    
    # Minimalistic ruby implementation - ISO 30170:2012
    mruby-1.0.0
    mruby-1.1.0
    mruby-1.2.0
    mruby-1[.3.0]
    mruby[-head]
    
    # Ruby Enterprise Edition
    ree-1.8.6
    ree[-1.8.7][-2012.02]
    
    # Topaz
    topaz
    
    # MagLev
    maglev[-head]
    maglev-1.0.0
    
    # Mac OS X Snow Leopard Or Newer
    macruby-0.10
    macruby-0.11
    macruby[-0.12]
    macruby-nightly
    macruby-head
    
    # IronRuby
    ironruby[-1.1.3]
    ironruby-head
    [root@bogon redis-3.2.8]# 
    View Code

    查看后,看到前面有ruby的版本比较多,高于2.0.0的有4个,选一个即可。这里就选择2.3.4吧。

    [root@bogon redis-3.2.8]# rvm install 2.3.4
    Searching for binary rubies, this might take some time.
    Found remote file https://rvm_io.global.ssl.fastly.net/binaries/centos/7/x86_64/ruby-2.3.4.tar.bz2
    Checking requirements for centos.
    Installing requirements for centos.
    Installing required packages: bison, bzip2, libyaml-devel......
    Requirements installation successful.
    ruby-2.3.4 - #configure
    ruby-2.3.4 - #download
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 25.2M  100 25.2M    0     0   149k      0  0:02:53  0:02:53 --:--:--  165k
    No checksum for downloaded archive, recording checksum in user configuration.
    ruby-2.3.4 - #validate archive
    ruby-2.3.4 - #extract
    ruby-2.3.4 - #validate binary
    ruby-2.3.4 - #setup
    ruby-2.3.4 - #gemset created /usr/local/rvm/gems/ruby-2.3.4@global
    ruby-2.3.4 - #importing gemset /usr/local/rvm/gemsets/global.gems..............................
    ruby-2.3.4 - #generating global wrappers........
    Error running 'run_gem_wrappers_regenerate',
    please read /usr/local/rvm/log/1511253510_ruby-2.3.4/gemset.wrappers.global.log
    ruby-2.3.4 - #gemset created /usr/local/rvm/gems/ruby-2.3.4
    ruby-2.3.4 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
    ruby-2.3.4 - #generating default wrappers.........
    Error running 'run_gem_wrappers_regenerate',
    please read /usr/local/rvm/log/1511253510_ruby-2.3.4/gemset.wrappers.default.log

    在这个地方,我的10.90.7.10的机器总是报错。。。

    执行启用新的ruby版本:

    [root@bogon redis-3.2.8]# rvm use 2.3.4
    Using /usr/local/rvm/gems/ruby-2.3.4
    Error loading RubyGems plugin "/usr/local/rvm/gems/ruby-2.3.4@global/gems/executable-hooks-1.3.2/lib/rubygems_plugin.rb": /lib64/libcrypto.so.10: version `OPENSSL_1.0.2' not found (required by /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/x86_64-linux/openssl.so) - /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/x86_64-linux/openssl.so (LoadError)
    Error loading RubyGems plugin "/usr/local/rvm/gems/ruby-2.3.4@global/gems/gem-wrappers-1.3.2/lib/rubygems_plugin.rb": /lib64/libcrypto.so.10: version `OPENSSL_1.0.2' not found (required by /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/x86_64-linux/openssl.so) - /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/x86_64-linux/openssl.so (LoadError)

    这个错误是找openssl 1.0.2的依赖,需要安装。我以源码来安装这个吧。先从执行:

    [root@bogon openssl-1.0.2l]# wget  wget https://www.openssl.org/source/openssl-1.0.2.tar.gz

    下载完毕后,解压安装:

    [root@bogon openssl-1.0.2]#  ./config -fPIC --prefix=/usr/local/openssl/ enable-shared
    Operating system: x86_64-whatever-linux2
    Configuring for linux-x86_64
    Configuring for linux-x86_64
        no-ec_nistp_64_gcc_128 [default]  OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
        no-gmp          [default]  OPENSSL_NO_GMP (skip dir)
        no-jpake        [experimental] OPENSSL_NO_JPAKE (skip dir)
        no-krb5         [krb5-flavor not specified] OPENSSL_NO_KRB5
        no-libunbound   [experimental] OPENSSL_NO_LIBUNBOUND (skip dir)
        no-md2          [default]  OPENSSL_NO_MD2 (skip dir)
        no-rc5          [default]  OPENSSL_NO_RC5 (skip dir)
        no-rfc3779      [default]  OPENSSL_NO_RFC3779 (skip dir)
        no-sctp         [default]  OPENSSL_NO_SCTP (skip dir)
        no-ssl-trace    [default]  OPENSSL_NO_SSL_TRACE (skip dir)
        no-store        [experimental] OPENSSL_NO_STORE (skip dir)
        no-unit-test    [default]  OPENSSL_NO_UNIT_TEST (skip dir)
        no-zlib         [default] 
        no-zlib-dynamic [default] 
    IsMK1MF=0
    CC            =gcc
    CFLAG         =-fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -fPIC -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
    EX_LIBS       =-ldl
    CPUID_OBJ     =x86_64cpuid.o
    BN_ASM        =x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o
    EC_ASM        =ecp_nistz256.o ecp_nistz256-x86_64.o
    DES_ENC       =des_enc.o fcrypt_b.o
    AES_ENC       =aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o
    BF_ENC        =bf_enc.o
    CAST_ENC      =c_enc.o
    RC4_ENC       =rc4-x86_64.o rc4-md5-x86_64.o
    RC5_ENC       =rc5_enc.o
    MD5_OBJ_ASM   =md5-x86_64.o
    SHA1_OBJ_ASM  =sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o
    RMD160_OBJ_ASM=
    CMLL_ENC      =cmll-x86_64.o cmll_misc.o
    MODES_OBJ     =ghash-x86_64.o aesni-gcm-x86_64.o
    ENGINES_OBJ   =
    PROCESSOR     =
    RANLIB        =/usr/bin/ranlib
    ARFLAGS       =
    PERL          =/usr/bin/perl
    SIXTY_FOUR_BIT_LONG mode
    DES_UNROLL used
    DES_INT used
    RC4_CHUNK is unsigned long
    e_os2.h => include/openssl/e_os2.h
    making links in crypto...
    make[1]: 进入目录“/opt/redis/openssl-1.0.2/crypto”
    crypto.h => ../include/openssl/crypto.h
    opensslv.h => ../include/openssl/opensslv.h
    opensslconf.h => ../include/openssl/opensslconf.h
    ebcdic.h => ../include/openssl/ebcdic.h
    symhacks.h => ../include/openssl/symhacks.h
    ossl_typ.h => ../include/openssl/ossl_typ.h
    constant_time_test.c => ../test/constant_time_test.c
    making links in crypto/objects...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/objects”
    objects.h => ../../include/openssl/objects.h
    obj_mac.h => ../../include/openssl/obj_mac.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/objects”
    making links in crypto/md4...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/md4”
    md4.h => ../../include/openssl/md4.h
    md4test.c => ../../test/md4test.c
    md4.c => ../../apps/md4.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/md4”
    making links in crypto/md5...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/md5”
    md5.h => ../../include/openssl/md5.h
    md5test.c => ../../test/md5test.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/md5”
    making links in crypto/sha...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/sha”
    sha.h => ../../include/openssl/sha.h
    shatest.c => ../../test/shatest.c
    sha1test.c => ../../test/sha1test.c
    sha256t.c => ../../test/sha256t.c
    sha512t.c => ../../test/sha512t.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/sha”
    making links in crypto/mdc2...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/mdc2”
    mdc2.h => ../../include/openssl/mdc2.h
    mdc2test.c => ../../test/mdc2test.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/mdc2”
    making links in crypto/hmac...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/hmac”
    hmac.h => ../../include/openssl/hmac.h
    hmactest.c => ../../test/hmactest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/hmac”
    making links in crypto/ripemd...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/ripemd”
    ripemd.h => ../../include/openssl/ripemd.h
    rmdtest.c => ../../test/rmdtest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/ripemd”
    making links in crypto/whrlpool...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/whrlpool”
    whrlpool.h => ../../include/openssl/whrlpool.h
    wp_test.c => ../../test/wp_test.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/whrlpool”
    making links in crypto/des...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/des”
    des.h => ../../include/openssl/des.h
    des_old.h => ../../include/openssl/des_old.h
    destest.c => ../../test/destest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/des”
    making links in crypto/aes...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/aes”
    aes.h => ../../include/openssl/aes.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/aes”
    making links in crypto/rc2...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/rc2”
    rc2.h => ../../include/openssl/rc2.h
    rc2test.c => ../../test/rc2test.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/rc2”
    making links in crypto/rc4...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/rc4”
    rc4.h => ../../include/openssl/rc4.h
    rc4test.c => ../../test/rc4test.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/rc4”
    making links in crypto/idea...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/idea”
    idea.h => ../../include/openssl/idea.h
    ideatest.c => ../../test/ideatest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/idea”
    making links in crypto/bf...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/bf”
    blowfish.h => ../../include/openssl/blowfish.h
    bftest.c => ../../test/bftest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/bf”
    making links in crypto/cast...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/cast”
    cast.h => ../../include/openssl/cast.h
    casttest.c => ../../test/casttest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/cast”
    making links in crypto/camellia...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/camellia”
    camellia.h => ../../include/openssl/camellia.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/camellia”
    making links in crypto/seed...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/seed”
    seed.h => ../../include/openssl/seed.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/seed”
    making links in crypto/modes...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/modes”
    modes.h => ../../include/openssl/modes.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/modes”
    making links in crypto/bn...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/bn”
    bn.h => ../../include/openssl/bn.h
    bntest.c => ../../test/bntest.c
    exptest.c => ../../test/exptest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/bn”
    making links in crypto/ec...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/ec”
    ec.h => ../../include/openssl/ec.h
    ectest.c => ../../test/ectest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/ec”
    making links in crypto/rsa...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/rsa”
    rsa.h => ../../include/openssl/rsa.h
    rsa_test.c => ../../test/rsa_test.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/rsa”
    making links in crypto/dsa...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/dsa”
    dsa.h => ../../include/openssl/dsa.h
    dsatest.c => ../../test/dsatest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/dsa”
    making links in crypto/ecdsa...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/ecdsa”
    ecdsa.h => ../../include/openssl/ecdsa.h
    ecdsatest.c => ../../test/ecdsatest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/ecdsa”
    making links in crypto/dh...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/dh”
    dh.h => ../../include/openssl/dh.h
    dhtest.c => ../../test/dhtest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/dh”
    making links in crypto/ecdh...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/ecdh”
    ecdh.h => ../../include/openssl/ecdh.h
    ecdhtest.c => ../../test/ecdhtest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/ecdh”
    making links in crypto/dso...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/dso”
    dso.h => ../../include/openssl/dso.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/dso”
    making links in crypto/engine...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/engine”
    engine.h => ../../include/openssl/engine.h
    enginetest.c => ../../test/enginetest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/engine”
    making links in crypto/buffer...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/buffer”
    buffer.h => ../../include/openssl/buffer.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/buffer”
    making links in crypto/bio...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/bio”
    bio.h => ../../include/openssl/bio.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/bio”
    making links in crypto/stack...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/stack”
    stack.h => ../../include/openssl/stack.h
    safestack.h => ../../include/openssl/safestack.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/stack”
    making links in crypto/lhash...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/lhash”
    lhash.h => ../../include/openssl/lhash.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/lhash”
    making links in crypto/rand...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/rand”
    rand.h => ../../include/openssl/rand.h
    randtest.c => ../../test/randtest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/rand”
    making links in crypto/err...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/err”
    err.h => ../../include/openssl/err.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/err”
    making links in crypto/evp...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/evp”
    evp.h => ../../include/openssl/evp.h
    evp_test.c => ../../test/evp_test.c
    evptests.txt -> ../../test/evptests.txt
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/evp”
    making links in crypto/asn1...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/asn1”
    asn1.h => ../../include/openssl/asn1.h
    asn1_mac.h => ../../include/openssl/asn1_mac.h
    asn1t.h => ../../include/openssl/asn1t.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/asn1”
    making links in crypto/pem...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/pem”
    pem.h => ../../include/openssl/pem.h
    pem2.h => ../../include/openssl/pem2.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/pem”
    making links in crypto/x509...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/x509”
    x509.h => ../../include/openssl/x509.h
    x509_vfy.h => ../../include/openssl/x509_vfy.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/x509”
    making links in crypto/x509v3...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/x509v3”
    x509v3.h => ../../include/openssl/x509v3.h
    v3nametest.c => ../../test/v3nametest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/x509v3”
    making links in crypto/conf...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/conf”
    conf.h => ../../include/openssl/conf.h
    conf_api.h => ../../include/openssl/conf_api.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/conf”
    making links in crypto/txt_db...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/txt_db”
    txt_db.h => ../../include/openssl/txt_db.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/txt_db”
    making links in crypto/pkcs7...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/pkcs7”
    pkcs7.h => ../../include/openssl/pkcs7.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/pkcs7”
    making links in crypto/pkcs12...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/pkcs12”
    pkcs12.h => ../../include/openssl/pkcs12.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/pkcs12”
    making links in crypto/comp...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/comp”
    comp.h => ../../include/openssl/comp.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/comp”
    making links in crypto/ocsp...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/ocsp”
    ocsp.h => ../../include/openssl/ocsp.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/ocsp”
    making links in crypto/ui...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/ui”
    ui.h => ../../include/openssl/ui.h
    ui_compat.h => ../../include/openssl/ui_compat.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/ui”
    making links in crypto/krb5...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/krb5”
    krb5_asn.h => ../../include/openssl/krb5_asn.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/krb5”
    making links in crypto/cms...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/cms”
    cms.h => ../../include/openssl/cms.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/cms”
    making links in crypto/pqueue...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/pqueue”
    pqueue.h => ../../include/openssl/pqueue.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/pqueue”
    making links in crypto/ts...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/ts”
    ts.h => ../../include/openssl/ts.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/ts”
    making links in crypto/srp...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/srp”
    srp.h => ../../include/openssl/srp.h
    srptest.c => ../../test/srptest.c
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/srp”
    making links in crypto/cmac...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/crypto/cmac”
    cmac.h => ../../include/openssl/cmac.h
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/crypto/cmac”
    make[1]: 离开目录“/opt/redis/openssl-1.0.2/crypto”
    making links in ssl...
    make[1]: 进入目录“/opt/redis/openssl-1.0.2/ssl”
    ssl.h => ../include/openssl/ssl.h
    ssl2.h => ../include/openssl/ssl2.h
    ssl3.h => ../include/openssl/ssl3.h
    ssl23.h => ../include/openssl/ssl23.h
    tls1.h => ../include/openssl/tls1.h
    dtls1.h => ../include/openssl/dtls1.h
    kssl.h => ../include/openssl/kssl.h
    srtp.h => ../include/openssl/srtp.h
    ssltest.c => ../test/ssltest.c
    heartbeat_test.c => ../test/heartbeat_test.c
    make[1]: 离开目录“/opt/redis/openssl-1.0.2/ssl”
    making links in engines...
    make[1]: 进入目录“/opt/redis/openssl-1.0.2/engines”
    making links in engines/ccgost...
    make[2]: 进入目录“/opt/redis/openssl-1.0.2/engines/ccgost”
    make[2]: 对“links”无需做任何事。
    make[2]: 离开目录“/opt/redis/openssl-1.0.2/engines/ccgost”
    make[1]: 离开目录“/opt/redis/openssl-1.0.2/engines”
    making links in apps...
    make[1]: 进入目录“/opt/redis/openssl-1.0.2/apps”
    make[1]: 对“links”无需做任何事。
    make[1]: 离开目录“/opt/redis/openssl-1.0.2/apps”
    making links in test...
    make[1]: 进入目录“/opt/redis/openssl-1.0.2/test”
    make[1]: 对“links”无需做任何事。
    make[1]: 离开目录“/opt/redis/openssl-1.0.2/test”
    making links in tools...
    make[1]: 进入目录“/opt/redis/openssl-1.0.2/tools”
    make[1]: 对“links”无需做任何事。
    make[1]: 离开目录“/opt/redis/openssl-1.0.2/tools”
    generating dummy tests (if needed)...
    make[1]: 进入目录“/opt/redis/openssl-1.0.2/test”
    make[1]: 对“generate”无需做任何事。
    make[1]: 离开目录“/opt/redis/openssl-1.0.2/test”
    
    Configured for linux-x86_64.
    [root@bogon openssl-1.0.2]
    View Code

    然后进行make操作,生成可执行文件。 完成后,看看当前的版本。openssl安装后,执行redis-trib还是报错。。。

    到此为止,因为这个过程我反复尝试各种修正openssl的操作,都报错,应该是我的这个机器环境什么地方出问题了,不折腾这个了,既然redis配置的是集群的环境,那么,我在另外的一台机器上处理,应该也没有什么问题。

    接下来的,配置操作是在10.90.7.2的服务器上进行的,一切换一种方式进行操作,这次主要是基于源码的安装。

    源码安装ruby 2.4.2。从 http://www.ruby-lang.org/en/downloads/下载需要的版本。 解压后,进入ruby目录,分别进行./configure,./make, ./make install

    查看版本信息,得到下面的内容,说明安装成功。

    [root@localhost ~]# ruby -v
    ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

    继续执行redis-trib.rb指令。

    [root@localhost src]# ./redis-trib.rb --help
    /usr/local/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError)
            from /usr/local/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
            from ./redis-trib.rb:25:in `<main>'

    这个错误和上面的基于yum安装的一个错误,缺少ruby版本的redis。依然下载源码安装。https://rubygems.org/downloads/redis-4.0.1.gem下载完毕后,用gem进行安装。

    [root@localhost opt]# gem install redis-4.0.1.gem
    Successfully installed redis-4.0.1
    Parsing documentation for redis-4.0.1
    Installing ri documentation for redis-4.0.1
    Done installing documentation for redis after 0 seconds
    1 gem installed
    [root@localhost opt]# 

    再次执行redis-trib指令,检查redis-trib是否可以操作集群。

    [root@localhost src]# ./redis-trib.rb
    Usage: redis-trib <command> <options> <arguments ...>
    
      create          host1:port1 ... hostN:portN
                      --replicas <arg>
      check           host:port
      info            host:port
      fix             host:port
                      --timeout <arg>
      reshard         host:port
                      --from <arg>
                      --to <arg>
                      --slots <arg>
                      --yes
                      --timeout <arg>
                      --pipeline <arg>
      rebalance       host:port
                      --weight <arg>
                      --auto-weights
                      --use-empty-masters
                      --timeout <arg>
                      --simulate
                      --pipeline <arg>
                      --threshold <arg>
      add-node        new_host:new_port existing_host:existing_port
                      --slave
                      --master-id <arg>
      del-node        host:port node_id
      set-timeout     host:port milliseconds
      call            host:port command arg arg .. arg
      import          host:port
                      --from <arg>
                      --copy
                      --replace
      help            (show this help)
    
    For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.
    [root@localhost src]# 

    这次,说明redis的起集群的操作成功,下一步准备集群创建。

    查看目前启动的几台redis机器信息(info)

    [root@localhost src]# ./redis-trib.rb info 10.90.7.2:7001
    [ERR] Sorry, can't connect to node 10.90.7.2:7001
    [root@localhost src]# ./redis-trib.rb info 10.90.7.2:7000
    10.90.7.2:7000 (54941737...) -> 0 keys | 0 slots | 0 slaves.
    [OK] 0 keys in 1 masters.
    0.00 keys per slot on average.
    [root@localhost src]# 
    [root@localhost src]# ./redis-trib.rb info 10.90.7.2:7010
    10.90.7.2:7010 (79ebc53a...) -> 0 keys | 0 slots | 0 slaves.
    [OK] 0 keys in 1 masters.
    0.00 keys per slot on average.
    [root@localhost src]# 
    [root@localhost src]# ./redis-trib.rb info 10.90.7.10:7001
    10.90.7.10:7001 (7fd72f31...) -> 0 keys | 0 slots | 0 slaves.
    [OK] 0 keys in 1 masters.
    0.00 keys per slot on average.
    [root@localhost src]# ./redis-trib.rb info 10.90.7.10:7011
    10.90.7.10:7011 (d5a0fa35...) -> 0 keys | 0 slots | 0 slaves.
    [OK] 0 keys in 1 masters.
    0.00 keys per slot on average.
    [root@localhost src]# ./redis-trib.rb info 10.90.2.102:7002
    10.90.2.102:7002 (8d539663...) -> 0 keys | 0 slots | 0 slaves.
    [OK] 0 keys in 1 masters.
    0.00 keys per slot on average.
    [root@localhost src]# ./redis-trib.rb info 10.90.2.102:7012
    10.90.2.102:7012 (175061fa...) -> 0 keys | 0 slots | 0 slaves.
    [OK] 0 keys in 1 masters.
    0.00 keys per slot on average.
    [root@localhost src]# 

    创建redis集群,通过redis-trib命令实现:

    [root@localhost src]# ./redis-trib.rb create --replicas 1 10.90.7.2:7000 10.90.7.2:7010 10.90.7.10:7001 10.90.7.10:7011 10.90.2.102:7002 10.90.2.102:7012
    >>> Creating cluster
    >>> Performing hash slots allocation on 6 nodes...
    Using 3 masters:
    10.90.7.2:7000
    10.90.7.10:7001
    10.90.2.102:7002
    Adding replica 10.90.7.10:7011 to 10.90.7.2:7000
    Adding replica 10.90.7.2:7010 to 10.90.7.10:7001
    Adding replica 10.90.2.102:7012 to 10.90.2.102:7002
    M: 549417379f072c2f9551c1e662fbf0ef3ecc73eb 10.90.7.2:7000
       slots:0-5460 (5461 slots) master
    S: 79ebc53a5193dac898ec01fe2c5b0023990a379b 10.90.7.2:7010
       replicates 7fd72f31bf4faaae4f30cec6ac8ae1ab9cdaa597
    M: 7fd72f31bf4faaae4f30cec6ac8ae1ab9cdaa597 10.90.7.10:7001
       slots:5461-10922 (5462 slots) master
    S: d5a0fa35859c40e8588bf8648e036ab152bcece7 10.90.7.10:7011
       replicates 549417379f072c2f9551c1e662fbf0ef3ecc73eb
    M: 8d53966305162f6f0e53714f22e554a38f74d67b 10.90.2.102:7002
       slots:10923-16383 (5461 slots) master
    S: 175061fa6addecc8eaaf9b999372a9d5a8964d44 10.90.2.102:7012
       replicates 8d53966305162f6f0e53714f22e554a38f74d67b
    Can I set the above configuration? (type 'yes' to accept): yes
    >>> Nodes configuration updated
    >>> Assign a different config epoch to each node
    >>> Sending CLUSTER MEET messages to join the cluster
    Waiting for the cluster to join.....
    >>> Performing Cluster Check (using node 10.90.7.2:7000)
    M: 549417379f072c2f9551c1e662fbf0ef3ecc73eb 10.90.7.2:7000
       slots:0-5460 (5461 slots) master
       1 additional replica(s)
    S: 79ebc53a5193dac898ec01fe2c5b0023990a379b 10.90.7.2:7010
       slots: (0 slots) slave
       replicates 7fd72f31bf4faaae4f30cec6ac8ae1ab9cdaa597
    S: d5a0fa35859c40e8588bf8648e036ab152bcece7 10.90.7.10:7011
       slots: (0 slots) slave
       replicates 549417379f072c2f9551c1e662fbf0ef3ecc73eb
    M: 7fd72f31bf4faaae4f30cec6ac8ae1ab9cdaa597 10.90.7.10:7001
       slots:5461-10922 (5462 slots) master
       1 additional replica(s)
    M: 8d53966305162f6f0e53714f22e554a38f74d67b 10.90.2.102:7002
       slots:10923-16383 (5461 slots) master
       1 additional replica(s)
    S: 175061fa6addecc8eaaf9b999372a9d5a8964d44 10.90.2.102:7012
       slots: (0 slots) slave
       replicates 8d53966305162f6f0e53714f22e554a38f74d67b
    [OK] All nodes agree about slots configuration.
    >>> Check for open slots...
    >>> Check slots coverage...
    [OK] All 16384 slots covered.

    指令查看redis集群信息:

    [root@localhost src]# ./redis-cli -c -h 10.90.7.2 -p 7000
    10.90.7.2:7000> info
    # Server
    redis_version:3.2.8
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:6319bd4d85613682
    redis_mode:cluster
    os:Linux 2.6.18-274.el5 x86_64
    arch_bits:64
    multiplexing_api:epoll
    gcc_version:4.1.2
    process_id:29047
    run_id:428293cc0d9842e0ba2f3917322a0deb136196ee
    tcp_port:7000
    uptime_in_seconds:100413
    uptime_in_days:1
    hz:10
    lru_clock:1399317
    executable:/opt/redis-3.2.8/src/redis-server
    config_file:/opt/redis-3.2.8/tkcluster/7000.conf
    
    # Clients
    connected_clients:1
    client_longest_output_list:0
    client_biggest_input_buf:0
    blocked_clients:0
    
    # Memory
    used_memory:2418464
    used_memory_human:2.31M
    used_memory_rss:3018752
    used_memory_rss_human:2.88M
    used_memory_peak:2418464
    used_memory_peak_human:2.31M
    total_system_memory:8263512064
    total_system_memory_human:7.70G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    mem_fragmentation_ratio:1.25
    mem_allocator:jemalloc-4.0.3
    
    # Persistence
    loading:0
    rdb_changes_since_last_save:0
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1511347436
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    aof_enabled:1
    aof_rewrite_in_progress:0
    aof_rewrite_scheduled:0
    aof_last_rewrite_time_sec:-1
    aof_current_rewrite_time_sec:-1
    aof_last_bgrewrite_status:ok
    aof_last_write_status:ok
    aof_current_size:0
    aof_base_size:0
    aof_pending_rewrite:0
    aof_buffer_length:0
    aof_rewrite_buffer_length:0
    aof_pending_bio_fsync:0
    aof_delayed_fsync:0
    
    # Stats
    total_connections_received:5
    total_commands_processed:1349
    instantaneous_ops_per_sec:1
    total_net_input_bytes:102199
    total_net_output_bytes:6045767
    instantaneous_input_kbps:0.04
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:1
    sync_partial_ok:0
    sync_partial_err:0
    expired_keys:0
    evicted_keys:0
    keyspace_hits:0
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:4132
    migrate_cached_sockets:0
    
    # Replication
    role:master
    connected_slaves:1
    slave0:ip=10.90.7.10,port=7011,state=online,offset=1849,lag=1
    master_repl_offset:1849
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:2
    repl_backlog_histlen:1848
    
    # CPU
    used_cpu_sys:0.09
    used_cpu_user:0.11
    used_cpu_sys_children:0.01
    used_cpu_user_children:0.00
    
    # Cluster
    cluster_enabled:1
    
    # Keyspace
    10.90.7.2:7000>

    在10.90.7.2上设置一个数据:

    10.90.7.2:7000> set hello 1
    OK
    10.90.7.2:7000> get hello 
    "1"

    查看一下集群的信息点:

    10.90.7.2:7000> cluster info
    cluster_state:ok
    cluster_slots_assigned:16384
    cluster_slots_ok:16384
    cluster_slots_pfail:0
    cluster_slots_fail:0
    cluster_known_nodes:6
    cluster_size:3
    cluster_current_epoch:6
    cluster_my_epoch:1
    cluster_stats_messages_sent:15335
    cluster_stats_messages_received:15335

    从另外一个主机上,测试看看:

    [root@bogon src]# ./redis-cli -c -h 10.90.7.10 -p 7001
    10.90.7.10:7001> info
    # Server
    redis_version:3.2.8
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:b50c19b6d7e8c0c8
    redis_mode:cluster
    os:Linux 3.10.0-229.el7.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    gcc_version:4.8.3
    process_id:40885
    run_id:5b03ae96c0af7156d9ee0fae9ab96f9c56c7f6b7
    tcp_port:7001
    uptime_in_seconds:98920
    uptime_in_days:1
    hz:10
    lru_clock:1399401
    executable:/opt/redis/redis-3.2.8/src/redis-server
    config_file:/opt/redis/redis-3.2.8/tkcluster/7001.conf
    
    # Clients
    connected_clients:1
    client_longest_output_list:0
    client_biggest_input_buf:0
    blocked_clients:0
    
    # Memory
    used_memory:2418496
    used_memory_human:2.31M
    used_memory_rss:10039296
    used_memory_rss_human:9.57M
    used_memory_peak:2418496
    used_memory_peak_human:2.31M
    total_system_memory:33450364928
    total_system_memory_human:31.15G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    mem_fragmentation_ratio:4.15
    mem_allocator:jemalloc-4.0.3
    
    # Persistence
    loading:0
    rdb_changes_since_last_save:0
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1511347221
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    aof_enabled:1
    aof_rewrite_in_progress:0
    aof_rewrite_scheduled:0
    aof_last_rewrite_time_sec:-1
    aof_current_rewrite_time_sec:-1
    aof_last_bgrewrite_status:ok
    aof_last_write_status:ok
    aof_current_size:0
    aof_base_size:0
    aof_pending_rewrite:0
    aof_buffer_length:0
    aof_rewrite_buffer_length:0
    aof_pending_bio_fsync:0
    aof_delayed_fsync:0
    
    # Stats
    total_connections_received:5
    total_commands_processed:1647
    instantaneous_ops_per_sec:0
    total_net_input_bytes:115303
    total_net_output_bytes:6128379
    instantaneous_input_kbps:0.02
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:1
    sync_partial_ok:0
    sync_partial_err:0
    expired_keys:0
    evicted_keys:0
    keyspace_hits:0
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:789
    migrate_cached_sockets:0
    
    # Replication
    role:master
    connected_slaves:1
    slave0:ip=10.90.7.2,port=7010,state=online,offset=2255,lag=1
    master_repl_offset:2255
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:2
    repl_backlog_histlen:2254
    
    # CPU
    used_cpu_sys:35.23
    used_cpu_user:19.00
    used_cpu_sys_children:0.00
    used_cpu_user_children:0.00
    
    # Cluster
    cluster_enabled:1
    
    # Keyspace
    10.90.7.10:7001> info
    # Server
    redis_version:3.2.8
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:b50c19b6d7e8c0c8
    redis_mode:cluster
    os:Linux 3.10.0-229.el7.x86_64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    gcc_version:4.8.3
    process_id:40885
    run_id:5b03ae96c0af7156d9ee0fae9ab96f9c56c7f6b7
    tcp_port:7001
    uptime_in_seconds:98926
    uptime_in_days:1
    hz:10
    lru_clock:1399407
    executable:/opt/redis/redis-3.2.8/src/redis-server
    config_file:/opt/redis/redis-3.2.8/tkcluster/7001.conf
    
    # Clients
    connected_clients:1
    client_longest_output_list:0
    client_biggest_input_buf:0
    blocked_clients:0
    
    # Memory
    used_memory:2418496
    used_memory_human:2.31M
    used_memory_rss:10039296
    used_memory_rss_human:9.57M
    used_memory_peak:2418496
    used_memory_peak_human:2.31M
    total_system_memory:33450364928
    total_system_memory_human:31.15G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    mem_fragmentation_ratio:4.15
    mem_allocator:jemalloc-4.0.3
    
    # Persistence
    loading:0
    rdb_changes_since_last_save:0
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1511347221
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    aof_enabled:1
    aof_rewrite_in_progress:0
    aof_rewrite_scheduled:0
    aof_last_rewrite_time_sec:-1
    aof_current_rewrite_time_sec:-1
    aof_last_bgrewrite_status:ok
    aof_last_write_status:ok
    aof_current_size:0
    aof_base_size:0
    aof_pending_rewrite:0
    aof_buffer_length:0
    aof_rewrite_buffer_length:0
    aof_pending_bio_fsync:0
    aof_delayed_fsync:0
    
    # Stats
    total_connections_received:5
    total_commands_processed:1655
    instantaneous_ops_per_sec:1
    total_net_input_bytes:115576
    total_net_output_bytes:6130809
    instantaneous_input_kbps:0.04
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:1
    sync_partial_ok:0
    sync_partial_err:0
    expired_keys:0
    evicted_keys:0
    keyspace_hits:0
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:789
    migrate_cached_sockets:0
    
    # Replication
    role:master
    connected_slaves:1
    slave0:ip=10.90.7.2,port=7010,state=online,offset=2269,lag=0
    master_repl_offset:2269
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:2
    repl_backlog_histlen:2268
    
    # CPU
    used_cpu_sys:35.23
    used_cpu_user:19.00
    used_cpu_sys_children:0.00
    used_cpu_user_children:0.00
    
    # Cluster
    cluster_enabled:1
    
    # Keyspace
    10.90.7.10:7001> get hello
    -> Redirected to slot [866] located at 10.90.7.2:7000
    "1"
    10.90.7.2:7000>

    选择database的操作:

    10.90.7.2:7000> select 0
    OK
    10.90.7.2:7000> select 1
    (error) ERR SELECT is not allowed in cluster mode
    10.90.7.2:7000>

    特别说明,redis集群下,不支持database的非0的选择,其实是不支持select指令了,但是对于默认的database 0又默认支持。有点设计的不美妙

    另外,备注:集群环境下,不支持slaveof的配置,即配置文件里面,不能启动slaveof的配置。否则如我开始没有注意到这个,将conf文件中的slaveof指定了。就出现下面的错误。

    [root@localhost tkcluster]# ./stcluster.sh 
    status from 7010: 0
    
    *** FATAL CONFIG FILE ERROR ***
    Reading the configuration file, at line 265
    >>> 'slaveof 10.90.7.2 7010'
    slaveof directive not allowed in cluster mode
    status from 7011: 1
    [root@localhost tkcluster]#

    OK,到此,redis的集群环境搭建到此结束,成功完成!

  • 相关阅读:
    SupoSE 概述 Redmine
    tmux guake
    How to Install and Use Krugle Basic
    use webdevelop tools to delete domain specific cookies for ecommerical cps union effect
    执行hudson daemon的脚本
    python技巧26[python的egg包的安装和制作]
    HOWTO Modular Xorg
    ARC专题:再续 Xcode 4.2 中的Automatic Reference Counting (ARC)
    ARC专题:在Xcode 4.2中加入不支持ARC的源码
    Windows下的.NET+ Memcached安装
  • 原文地址:https://www.cnblogs.com/shihuc/p/7882004.html
Copyright © 2011-2022 走看看