• redis集群安装


    一、架构细节

    ①所有的redis节点彼此互联(PING-PONG机制),内部使用二进制协议优化传输速度和带宽.
    ②节点的fail是通过集群中超过半数的节点检测失效时才生效.
    ③客户端与redis节点直连,不需要中间proxy层.客户端不需要连接集群所有节点,连接集群中任何一个可用节点即可
    ④redis-cluster把所有的物理节点映射到[0-16383]slot上,cluster 负责维护node<->slot<->value
    Redis 集群中内置了 16384 个哈希槽,当需要在 Redis 集群中放置一个 key-value 时,redis 先对 key 使用 crc16 算法算出一个结果,然后把结果对 16384 求余数,这样每个 key 都会对应一个编号在 0-16383 之间的哈希槽,redis 会根据节点数量大致均等的将哈希槽映射到不同的节点
    

    二、集群搭建

    a、创建6个redis实例指定端口从 7001 到 7006
    b、修改redis.conf 打开cluster-enable yes 前的注释。
    c、需要一个ruby脚本(redis-trib.rb), redis-trib.rb在redis源码文件夹下的src目录下。
    d、把redis-trib.rb 文件复制到redis-cluster目录下。
    e、执行ruby脚本之前,需要安装ruby环境。

    ①:yum install ruby
    ②:yum install rubygems
    ③:安装redis-trib.rb 运行依赖的ruby的包:gem install redis-3.3.0.gem

    f、编写启动redis-cluster的脚本

    ①:vim start-all.sh
    ②:start-all.sh 内容如下:
    cd redis01
    ./redis-server redis.conf
    cd ..
    cd redis02
    ./redis-server redis.conf
    cd ..
    cd redis03
    ./redis-server redis.conf
    cd ..
    cd redis04
    ./redis-server redis.conf
    cd ..
    cd redis05
    ./redis-server redis.conf
    cd ..
    cd redis06
    ./redis-server redis.conf
    cd ..

    g、使用redis-trib.rb创建集群

    ./redis-trib.rb create --replicas 1 192.168.16.251:7001 192.168.16.251:7002 192.168.16.251:7003 192.168.16.251:7004 192.168.16.251:7005  192.168.16.251:7006
    

    h、使用客户端连接集群

    redis01/redis-cli -p 7001 -c

    i、备注

    redis-3.3.0.gem下载:https://rubygems.org/gems/redis
    redis官网:
    ①:https://redis.io/ 
    ②:http://www.redis.cn/

    致辞结束……

    关注我的公众号,精彩内容不能错过

  • 相关阅读:
    大前端工具集
    Python黑魔法,一行实现并行化
    MRPT
    ./configure 交叉编译库时所最常用到的配置
    Ubuntu16.04 ARM 编译 编译器版本和unordered_map map问题
    ubuntu 16.04 ARM glog移植
    Ubuntu16.04 ARM平台移植libcurl curl-7.63.0
    ubuntu16.04 ARM平台移植xmlrpc-c1.39.12
    ubunt 14.04 Could not find CMAKE_ROOT !!! CMake has most likely not been installed correctly. Modul
    ubuntu PCL的使用
  • 原文地址:https://www.cnblogs.com/huanchupkblog/p/6669415.html
Copyright © 2020-2023  润新知