• Redis6.2.1版本集群新加副本


    该方案经过测试,无法实现真正的高可用,当172.31.4.18宕机后,4.19上的实例需要人工干预切换为主,才可继续对外服务

    测试数据

    通过redis-benchmark生成测试数据

    ./bin/redis-benchmark -h 172.31.4.18 -p 6381 -a Redis_6.2.1_Sc --cluster -t set -d 128 -n 10000000 -r 100000000 -c 200
    

    新加节点

    172.31.4.18:6381> AUTH Redis_6.2.1_Sc
    OK
     
    172.31.4.18:6381> cluster meet 172.31.4.19 6382
    172.31.4.18:6381> cluster meet 172.31.4.19 6384
    172.31.4.18:6381> cluster meet 172.31.4.19 6386
    

    如发生问题执行如下操作回退,后面新加副本也可以使用相同命令

    172.31.4.18:6381> cluster nodes
    172.31.4.18:6381> cluster forget 9afa9a0f3392cc3b588d59747184ac94ef5806ea
    

    分片1新加副本

    500MB数据,耗时30s以内

    172.31.4.19:6382> AUTH Redis_6.2.1_Sc
    OK
     
    172.31.4.19:6382> cluster nodes
    1d287ec8daa829cb19e50a16c45ba315a77bcbd8 172.31.4.19:6384@16384 master - 0 1720765311000 4 connected
    9afa9a0f3392cc3b588d59747184ac94ef5806ea 172.31.4.19:6382@16382 myself,master - 0 1720765309000 3 connected
    962a95df82c9defbc747b6996b0e71a9db1575a9 172.31.4.19:6386@16386 master - 0 1720765311000 5 connected
    cdd87865700af1aecaf409fb54e5f6778fbb6dcb 172.31.4.18:6383@16383 master - 0 1720765311638 2 connected 5461-10922
    e2a1cd30a9bd3bb01fc431053620ef3701b7f567 172.31.4.18:6381@16381 master - 0 1720765309000 0 connected 0-5460
    9b56162051088e762426f4300f3a2e0406c033ed 172.31.4.18:6385@16385 master - 0 1720765312640 1 connected 10923-16383
     
    172.31.4.19:6382> cluster replicate e2a1cd30a9bd3bb01fc431053620ef3701b7f567
    OK
    

    副本日志信息

    11281:S 12 Jul 2024 14:30:33.125 * Before turning into a replica, using my own master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer.
    11281:S 12 Jul 2024 14:30:33.125 * Connecting to MASTER 172.31.4.18:6381
    11281:S 12 Jul 2024 14:30:33.125 * MASTER <-> REPLICA sync started
    11281:S 12 Jul 2024 14:30:33.126 * Non blocking connect for SYNC fired the event.
    11281:S 12 Jul 2024 14:30:33.126 * Master replied to PING, replication can continue...
    11281:S 12 Jul 2024 14:30:33.126 * Trying a partial resynchronization (request 4b293873f2b48207b7dd5728a138615b565a46c1:225).
    11281:S 12 Jul 2024 14:30:33.153 * Full resync from master: 93f860f4cc1a49eb2f6edd38b1f958896866a54f:0
    11281:S 12 Jul 2024 14:30:33.153 * Discarding previously cached master state.
    11281:S 12 Jul 2024 14:30:41.930 * MASTER <-> REPLICA sync: receiving 518563169 bytes from master to disk
    11281:S 12 Jul 2024 14:30:46.601 * MASTER <-> REPLICA sync: Flushing old data
    11281:S 12 Jul 2024 14:30:46.601 * MASTER <-> REPLICA sync: Loading DB in memory
    11281:S 12 Jul 2024 14:30:46.607 * Loading RDB produced by version 6.2.1
    11281:S 12 Jul 2024 14:30:46.607 * RDB age 14 seconds
    11281:S 12 Jul 2024 14:30:46.608 * RDB memory usage when created 951.10 Mb
    11281:S 12 Jul 2024 14:30:57.392 * MASTER <-> REPLICA sync: Finished with success
     
     
    [cpcn@redis02 redis6382]$ du -sh dump6382.rdb
    495M    dump6382.rdb
    

    分片2新加副本

    172.31.4.19:6384> AUTH Redis_6.2.1_Sc
    OK
     
    172.31.4.19:6384> cluster nodes
    9b56162051088e762426f4300f3a2e0406c033ed 172.31.4.18:6385@16385 master - 0 1720765958000 1 connected 10923-16383
    cdd87865700af1aecaf409fb54e5f6778fbb6dcb 172.31.4.18:6383@16383 master - 0 1720765959692 2 connected 5461-10922
    9afa9a0f3392cc3b588d59747184ac94ef5806ea 172.31.4.19:6382@16382 slave e2a1cd30a9bd3bb01fc431053620ef3701b7f567 0 1720765958691 0 connected
    1d287ec8daa829cb19e50a16c45ba315a77bcbd8 172.31.4.19:6384@16384 myself,master - 0 1720765959000 4 connected
    e2a1cd30a9bd3bb01fc431053620ef3701b7f567 172.31.4.18:6381@16381 master - 0 1720765958000 0 connected 0-5460
    962a95df82c9defbc747b6996b0e71a9db1575a9 172.31.4.19:6386@16386 master - 0 1720765960694 5 connected
     
    172.31.4.19:6384> cluster replicate cdd87865700af1aecaf409fb54e5f6778fbb6dcb
    OK
    

    分片3新加副本

    172.31.4.19:6386> AUTH Redis_6.2.1_Sc
    OK
     
    172.31.4.19:6386> cluster nodes
    e2a1cd30a9bd3bb01fc431053620ef3701b7f567 172.31.4.18:6381@16381 master - 0 1720766205000 0 connected 0-5460
    cdd87865700af1aecaf409fb54e5f6778fbb6dcb 172.31.4.18:6383@16383 master - 0 1720766206359 2 connected 5461-10922
    962a95df82c9defbc747b6996b0e71a9db1575a9 172.31.4.19:6386@16386 myself,master - 0 1720766205000 5 connected
    9b56162051088e762426f4300f3a2e0406c033ed 172.31.4.18:6385@16385 master - 0 1720766207360 1 connected 10923-16383
    1d287ec8daa829cb19e50a16c45ba315a77bcbd8 172.31.4.19:6384@16384 slave cdd87865700af1aecaf409fb54e5f6778fbb6dcb 0 1720766205357 2 connected
    9afa9a0f3392cc3b588d59747184ac94ef5806ea 172.31.4.19:6382@16382 slave e2a1cd30a9bd3bb01fc431053620ef3701b7f567 0 1720766206000 0 connected
     
    172.31.4.19:6386> cluster replicate 9b56162051088e762426f4300f3a2e0406c033ed
    OK
    

    副本添加完成

    172.31.4.19:6386> cluster nodes
    e2a1cd30a9bd3bb01fc431053620ef3701b7f567 172.31.4.18:6381@16381 master - 0 1720766507629 0 connected 0-5460
    cdd87865700af1aecaf409fb54e5f6778fbb6dcb 172.31.4.18:6383@16383 master - 0 1720766507000 2 connected 5461-10922
    962a95df82c9defbc747b6996b0e71a9db1575a9 172.31.4.19:6386@16386 myself,slave 9b56162051088e762426f4300f3a2e0406c033ed 0 1720766506000 1 connected
    9b56162051088e762426f4300f3a2e0406c033ed 172.31.4.18:6385@16385 master - 0 1720766509633 1 connected 10923-16383
    1d287ec8daa829cb19e50a16c45ba315a77bcbd8 172.31.4.19:6384@16384 slave cdd87865700af1aecaf409fb54e5f6778fbb6dcb 0 1720766508630 2 connected
    9afa9a0f3392cc3b588d59747184ac94ef5806ea 172.31.4.19:6382@16382 slave e2a1cd30a9bd3bb01fc431053620ef3701b7f567 0 1720766507000 0 connected
    
  • 相关阅读:
    K8s Ingress Controller部署指南:轻松实现服务外部访问
    精准定位——MySQL日志学习的一天【错误、二进制、查询、慢查询】
    严格反馈非线性系统基于事件触发的自抗扰预设有限时间跟踪控制
    一文了解什么是数字孪生
    Vue3无缝滚动----vue3-seamless-scroll
    C++与C语言中的字符串
    vueRouter 重定向 高亮 传参 嵌套 简单示例
    【解决】Unity3D中无法在MQTT事件中执行Animator
    SOA和微服务举例介绍
    深度学习:UserWarning: The parameter ‘pretrained‘ is deprecated since 0.13..解决办法
  • 原文地址:https://blog.csdn.net/u014650965/article/details/140381931