乐趣区

关于redis:envoy代理rediscluster

  • Redis-Cluser 架构设计

    1. Redis-Cluser 采纳无核心构造,每个节点都保留数据和整个集群状态,各个节点之间相互链接
    2. 节点间采纳 ping-pong 机制互联,外部应用二进制协定传输优化速度和带宽
    3. Redis-Cluser 会把所有物理节点映射到 0 -16383 个 slot 上
    4. Redis 集群预分好 16384 个桶,当须要在 Redis 集群中搁置一个 key-value 时,依据 CRC16(key) mod 16384 的值,决定将一个 key 放到哪个桶中
  • 部署 Redis-Cluser 3 节点 (一个正本)

    1. redis 配置
    daemonize yes
    port 7006
    cluster-enabled yes
    cluster-config-file "nodes.conf"
    cluster-node-timeout 15000
    appendonly yes
    protected-mode no
    bind 0.0.0.0
    masterauth "westos"
    requirepass westos
    1. 启动 redis 执行集群创立
redis-cli --cluster create 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006 --cluster-replicas 1
  • envoy 配置
static_resources:
  listeners:
  - name: redis_listener
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 1999
    filter_chains:
    - filters:
      - name: envoy.filters.network.redis_proxy
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.redis_proxy.v3.RedisProxy
          stat_prefix: egress_redis
          settings:
            op_timeout: 5s
          prefix_routes:
            catch_all_route:
              cluster: redis_cluster
  clusters:
  - name: redis_cluster
    connect_timeout: 1s
    type: strict_dns # static
    lb_policy: MAGLEV
    typed_extension_protocol_options:
      envoy.redis_proxy:
        "@type": type.googleapis.com/google.protobuf.Struct
        value:
          auth_password:
            inline_string: "westos"
    load_assignment:
      cluster_name: redis_cluster
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 10.0.2.15
                port_value: 7001
        - endpoint:
            address:
              socket_address:
                address: 10.0.2.15
                port_value: 7002
        - endpoint:
            address:
              socket_address:
                address: 10.0.2.15
                port_value: 7003
        - endpoint:
            address:
              socket_address:
                address: 10.0.2.15
                port_value: 7004
        - endpoint:
            address:
              socket_address:
                address: 10.0.2.15
                port_value: 7005
        - endpoint:
            address:
              socket_address:
                address: 10.0.2.15
                port_value: 7006
admin:
  access_log_path: "/dev/null"
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 8001
  • 启动 envoy
envoy -c envoy.yaml -l debug --service-cluster proxy
退出移动版