Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[Redis] Fast replication from redis-cluster to redis-cluster

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The existing requirement is the rapid migration from redis-cluster to redis-cluster, and after the migration, both sets of redis-cluster should be used independently and without dependencies.

Method 1: use the online migration tool in the previous redis migration

Redis-migration (disadvantage: does not support redis4.0) redis-migration-tools (disadvantage: does not support redis4.0) redis-sync-manage:redis-port encapsulated version ((disadvantage: does not support password mode) and other tools

Just online is redis4.0, and some can't use the above tools for various reasons.

Method 2:

Reference: [Redis] the disadvantage of redis migrating data to redis-cluster: the steps are relatively troublesome. When the file redis rdb file is too large, the migration time is too long.

Method 3: a method that needs to be described in detail in this article (assuming that the cluster is three nodes)

1. The new cluster (75 and 74) is added to the original cluster as slave, waiting for synchronized data 2. 5. Wait for the data to be synchronized and remove it from cluster 3. Shut down the synchronized three nodes 4. The original nodes.conf for editing the nodes.conf file should be like this: 4ce6e03ba48336569efcc7bbaab6edb538cb1a90 172.23.3.744ce6e03ba48336569efcc7bbaab6edb538cb1a90 6379V 16379 slave a7f923aaee624acf672f8704ffb4b27b48a56352 01536238939051 19 connectedaa8cf0b64f91c77846862909f9cec0c20ea54c1e 172.23.3.72V 6379V 16379 slave f2d9ac982c1d621850638a474ed4b8ffc5063d28 01536238941056 18 connected2d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 172.31.36.20V 6379V 16379 master-01536238940000 17 connected 0-5021753-5930 12175-12671f2d9ac982c1d621850638a474ed4b8ffc5063d28 172.31.47.95V 637979 master-01536238939000 18 connected 503-17525931-6380 10925-11274 12672-163834dd59a9480a669f308a6819a3538e3340ed855cf 172.23.75mm 16379 myself Slave 2d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 0 1536238940000 0 connectedc4c7df1e21399984d909761441be80b178ef62a5 172.31.47.956380 "16380 slave a7f923aaee624acf672f8704ffb4b27b48a56352 01536238941000 19 connected9a6307f16ea34354e701c4dbe04ecb5c77021938 172.31.37.243380" 16380 slave f2d9ac982c1d621850638a474ed4b8ffc5063d28 01536238942381 18 connecteda7f923aaee624acf672f8704ffb4b27b48a56352 172.31.37.37.241414379 master-01536238942061 19 connected 6381-109248942061 19 connected 6381-10924 11275-121745dcc47b5477628895ce98e4c06f8e228a9c4fe5f 172.36.20 connectedvars currentEpoch 6380 16380 slave 2d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 01536238941373 17 connectedvars currentEpoch 19 lastVoteEpoch 0 modified nodes.conf to 4ce6e03ba48336569efcc7bbaab6edb538cb1a90 172.23.3.74419 connected 637979 master-01536238942061 19 connected 6381-10924 11275-12174aa8cf0b64f91c77846862909f9cec0c20ea54c1e 172.23.3. Master-01536238939000 18 connected 503-1752 5931-6380 10925-11274 12672-163834dd59a9480a669f308a6819a3538e3340ed855cf 172.23.3.75 163834dd59a9480a669f308a6819a3538e3340ed855cf 6379U 16379 myself Master-01536238940000 17 connected 0-502 1753-5930 12175-12671vars currentEpoch 19 lastVoteEpoch 0 take 74 as an example Modify the idea: find 74 master 37.24, replace 74 slot information 37.24 slot information master-01536238942061 19 connected 6381-10924 11275-12174 each machine master is preceded by myself information 5. Restart the redis cluster of 75, 74, and 72 and verify that 2-5 steps can be written into a script automatically, and a set of clusters can be copied in minutes!

Add: it is also possible to move the computer room, so that only a set of clusters can be used, this requirement is more simple!

Directly shut down the redis service of the original computer room, upgrade the redis of the new computer room to master, and modify the domain name resolution. The switching process is as follows

After 6379 downmachine, 6380 will be upgraded to master 6379 after restart, the cluster info will be changed into slave and added to 6380. The change process of cluster info is as follows: normally [root@ip-172-31-36-20] # / usr/local/redis/bin/redis-cli-a XSX7sOfvFeLEyXod-h 127.0.0.1-p 6379-c cluster nodesf2d9ac982c1d621850638a474ed4b8ffc5063d28 172.31.47.95 XSX7sOfvFeLEyXod 16379 master-01536302125000 18 connected 804-17525931-6380 10925-11274 12672-1638395c8168dab83f7156c1b0ba34686917972259517 172.31.36.20 usr/local/redis/bin/redis-cli 6380 slave 2d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 01536302126000 20 Connecteda7f923aaee624acf672f8704ffb4b27b48a56352 172.31.37.24 connected 6379 16379 master-01536302126573 21 connected 787-803 6381-10924 11275-12174596012a79c3699692651fe47bc1a5a982762676a 172.31.47.95 12174596012a79c3699692651fe47bc1a5a982762676a 172.31.47.95 connected 6380 slave f2d9ac982c1d621850638a474ed4b8ffc5063d28 01536302124569 21 connecteddd4d8dbe8aee4ef0e31b8908297ca64092302bfd 172.31.37.37.24 Color 6380 slave a7f923aaee624acf672f8704ffb4b27b48a56352 01536302125000 21 connected2d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 172.31.36.20 6379mm 16379 myself Master-1536291530036 1536291530036 20 connected 0-786 1753-5930 12175-12671down after dropping master 6379 [root@ip-172-31-36-20] # / usr/local/redis/bin/redis-cli-a XSX7sOfvFeLEyXod-h 172.31.37.24-p 6379-c cluster nodes | grep-I 36a7f923aaee624acf672f8704ffb4b27b48a56352 172.31.37.24 myself Master-1536291532036 1536291532036 21 connected 787-803 6381-10924 11275-1217495c8168dab83f7156c1b0ba34686917972259517 172.31.36.20 slave 2d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 01536302197019 20 connectedf2d9ac982c1d621850638a474ed4b8ffc5063d28 172.31.47.47.951536302196019 18 connected 804-17525931-6380 10925-11274 12672-16383596012a79c3699692651fe47bc1a5a982762676a 172.31.47.958016380 slave f2d9ac982c1d621850638a474ed4b8ffc5063d28 01536302198019 18 connecteddd4d8dbe8aee4ef0e31b8908297ca64092302bfd 172.31.37.2424 slave a7f923aaee624acf672f8704ffb4b27b48a56352 015363019000 21 connected2d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 172.36.36.206379116379 master,fail-1536302172919 15363022919 15363029019 20 disconnected 0 786 1753-12671 seconds after the successful election 6380 promote [root@ip-172-31-36-20] # / usr/local/redis/bin/redis-cli-a XSX7sOfvFeLEyXod-h 172.31.37.24-p 6379-c cluster nodes | grep-I 36.2095c8168dab83f7156c1b0ba34686917972259517 172.31.36.20 grep 6380 master-01536302200019 22 connected 0-786 1753-5930 12175-126712d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 172.31.36.20637916379 master Fail-1536302172919 1536302169019 20 disconnected restart 6379 seconds after rejoining the cluster [root@ip-172-31-36-20] # / usr/local/redis/bin/redis-cli-a XSX7sOfvFeLEyXod-h 172.31.37.24-p 6379-c cluster nodes | grep-I 36.2095c8168dab83f7156c1b0ba34686917972259517 172.31.36.20 6380mm 16380 master-01536302275023 22 connected 0-786 1753-5930 12175-126712d21ca5d5504b6e8bf283d4a3d0f390ab0258b90 172.36.20 usr/local/redis/bin/redis-cli 6379mm 16379 slave 95c8168dab83f7156c1b0ba34686917972259517 01536302273023 connected 22

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report