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

Real-time migration of Redis heterogeneous cluster data

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Background

Due to historical reasons, the company's cache scheme uses Codis, and most of them share a cluster. We plan to abandon Codis and use the native cluster architecture of Redis. Why abandon Codis? there are two main reasons: 1. Codis has not been updated and maintained for a long time, the official version of Redis has been iterated to 5.x.x, and some new features of codis-server or 3.x.x are not supported. 2. Based on the principle of sharing risk equally and not putting eggs in one basket, our current usage violates this principle. If something goes wrong in a cluster, then all services of the whole department will be affected. In the process of previous research and business department research, it is found that people use Codis not only for caching, but also for storage in some business scenarios, such as counters. Therefore, we need a real-time data migration solution so that businesses can migrate from Codis to Redis without awareness.

Demand for scheme selection

1. Support data migration from Codis to Redis Cluster

2. Support data migration from Codis to Sentinel cluster

3. Only part of key can be migrated.

4. Support to check the progress of migration

Investigation and research

1 、 redis-migrate-tool

Redis-migrate-tool is an open source tool for real-time data migration between Redis heterogeneous clusters by VIPSHOP, but it has not been updated for two years. I personally think it is a relatively perfect tool, especially data verification. For more information, please see GitHub:

Https://github.com/vipshop/redis-migrate-tool

2 、 RedisShake

RedisShake is a secondary development tool of Aliyun based on pea pod open source redis-port to support real-time synchronization of Redis heterogeneous clusters. Compared with redis-migrate-tool, I think its advantage is that it supports prefix key synchronization and multi-DB synchronization, while redis-migrate-tool can only be fully synchronized, and if the source is divided into libraries, synchronization to the target Redis is synchronized to db0 one library. This is not feasible for businesses that have done sub-database scenarios. For more information on the features of RedisShake, please see GitHub:

Https://github.com/alibaba/RedisShake

3 、 redis-port

Redis-port is a Redis data migration tool that Pea Pod used to make it easy to migrate from redis to Codis open source. Now it has not been updated for a long time. For its features, please see GitHub:

Https://github.com/CodisLabs/redis-port

Practice environment codis--- "Sentinel fragment master password codis version Sentinel address master address master password Sentinel redis version 192.168.46.150:10379xxx3.2.4192.168.9.87:6385192.168.9.87:63841234565.0.2192.168.47.150:10379xxx3.2.4192.168.9.88:6385192.168.9.87:63841234565.0.2xxx3.2.4192.168.9.89:6385192.168.9.87:63841234565." 0.2 Redis Cluster shard master password codis version master nodemaster password redis cluster version 192.168.46.150:10379xxx3.2.4192.168.9.87:63831234565.0.2192.168.47.150:10379xxx3.2.4192.168.9.89:63821234565.0.2xxx3.2.4192.168.9.88:63811234565.0.2 use redis-migrate-tool for data migration migration tool installation

Just compile and install according to the official documentation.

Write a configuration file

Migrate Sentinel's profile

Vim / chj/app/redis-migrate-tool/rmt_ sentinel.confession [source] type: singleservers:- 192.168.46.150 singleservers:- 10379-192.168.47.150:10379redis_auth: xxx [target] type: singleservers:- 192.168.9.87:6384redis_auth: 123456 [common] listen: 0.0.0.08888

Migrate the configuration file for redis cluster

Vim / chj/app/redis-migrate-tool/rmt_ cluster.confession [source] type: singleservers:-192.168.46.150 type 10379-192.168.47.150:10379redis_auth: xxx [target] type: redis clusterservers:- 192.168.9.87 chj/app/redis-migrate- 6383-192.168.9.89 192.168.47.150:10379redis_auth 6382-192.168.9.88:6381redis_auth: 123456 [common] listen: 0.0.0.0888 start the synchronization program cd / chj/app/redis-migrate- Tool#condis migrates data to sentinel cluster. / src/redis-migrate-tool-c rmt_sentinel.conf-o rmt.log-d # condis migrates data to redis cluster./src/redis-migrate-tool-c rmt_cluster.conf-o rmt_cluster.log-d data check cd / chj/app/redis-migrate-tool [root@devops-template-test redis-migrate-tool] #. / src/redis-migrate-tool-c rmt_sentinel.conf-C "redis _ check 60000 "Check job is running... [2019-06-25 11 rmt_check.c:848 ERROR 09.414] key checked failed: check key's value error Value is inconsistent. Key (len:17, type:hash): BigData-IpParse:4Checked keys: 60000Inconsistent value keys: 1Inconsistent expire keys: 0Other check error keys: 0Checked OK keys: 59999Check job finished, used 16.622sPS1, "- C" redis_check 60000 "specifies the number of samples to perform data verification. 60000 refers to the number of samples of the verification data. The default is 10002. If there is an exception, you need to confirm the execution of the exception key. Synchronization status confirmation.

Total_msgs_outqueue can determine whether there is an oplog waiting in the queue for processing. If total_msgs_outqueue > 0, please wait until total_msgs_outqueue=0 can switch.

[root@devops-template-test redis-migrate-tool] # redis-cli-h 127.0.0.1-p 8889 info Serverversion:0.1.0os:Linux 3.10.0-693.5.2.el7.x86_64 x86_64multiplexing_api:epollgcc_version:4.8.5process_id:10137tcp_port:8889uptime_in_seconds:1201uptime_in_days:0config_file:/chj/app/redis-migrate-tool/rmt_cluster.conf Clientsconnected_clients:1max_clients_limit : 100total_connections_received:1 Memorymem_allocator:jemalloc-0.0.0 Groupsource_nodes_count:2target_nodes_count:4Statsall_rdb_received:1all_rdb_parsed:1all_aof_loaded:0rdb_received_count:2rdb_parsed_count:2aof_loaded_count:0total_msgs_recv:357666total_msgs_sent:357666total_net_input_bytes:78804395total_net_output_bytes:1688068278total_net_input_bytes_human:75.15Mtotal_net_output_bytes_human:1.57Gtotal _ mbufs_inqueue:0total_msgs_outqueue:0 uses RedisShake for data migration tools to install mkdir / chj/app/redis-shakecd / chj/app/redis-shakewget https://github.com/alibaba/RedisShake/releases/download/release-v1.6.9-20190624/redis-shake.tar.gztar-zxvf redis-shake.tar.gz to write configuration files

Modify the original configuration file, only the items with comments below are modified, and the rest remain the same.

Id = redis-shakelog.file =. / redis-shake.loglog.level = infopid_path = system_profile = 9310http_profile = 9320ncpu = 0parallel = 32source.type = cluster # Source Type Select clustersource.address = 192.168.46.150 redis-shake.loglog.level 10379 192.168.47.150 codis 10379 # codis fragment master address source.password_raw = xxx # codis password source.auth_type = authsource.tls_enable = falsetarget.type = sentinel # Target type is Sentinel # target.type = cluster # Target is redis clustertarget.address = sentinel-zhj2-redis-sentinel-dev-6384@192.168.9.87:6385;192.168.9.88:6385 192.168.9.89 redis 6385 # address of the target sentry cluster # target.address = 192.168.9.87 target.password_raw = 192.168.9.881 = 192.168.9.89 redis 6382 = 192.168.9.883381 # address of the target redis target.auth_type = authtarget.db =-1target.tls_enable = falserdb.input = localrdb.output = local_dumprdb.parallel = fake_time = rewrite = truefilter.db = 0 # synchronous db0filter.key = mms only Vcc # synchronizes only keyfilter.slot = filter.lua = falsebig_key_threshold = 524288000psync = falsemetric = truemetric.print_log = falseheartbeat.url = heartbeat.interval = 3heartbeat.external = test externalheartbeat.network_interface = sender.size = 5000sender.delay_channel_size = 65535keep_alive = 0scan.key_number = 50scan.special_cloud = scan.key_file = qps = 200000replace_hash_tag = falseextra = false at the beginning of mms and vcc

/ chj/app/redis-shake/start.sh / chj/app/redis-shake/redis-shake.conf sync

View synchronization status

Determine whether the synchronization is complete by comparing PullCommandTotal-BypassCommandTotal = = PushCommandTotal

Curl http://192.168.47.253:9320/metric| python-m json.tool [{"AvgDelay": "0.43 ms", "BypassCmdCount": 0, "BypassCmdCountTotal": 0, "Delay": "null ms", "Details": null, "FailCmdCount": 0, "FailCmdCountTotal": 0, "FullSyncProgress": 100, "NetworkFlowTotal": 42006 "NetworkSpeed": 0, "ProcessingCmdCount": 0, "PullCmdCount": 0, "PullCmdCountTotal": 897, "PushCmdCount": 0, "PushCmdCountTotal": 839, "SenderBufCount": 0, "SourceAddress": "192.168.46.150 25T17:45:23Z 10379", "SourceDBOffset": 0, "StartTime": "2019-06-25T17:45:23Z" "Status": "incr", "SuccessCmdCount": 0, "SuccessCmdCountTotal": 839, "TargetAddress": ["192.168.9.87 TargetAddress"], "TargetDBOffset": 0}, {"AvgDelay": "0.60 ms", "BypassCmdCount": 1, "BypassCmdCountTotal": 4067, "Delay": "null ms" "Details": null, "FailCmdCount": 0, "FailCmdCountTotal": 0, "FullSyncProgress": 100, "NetworkFlowTotal": 37629, "NetworkSpeed": 0, "ProcessingCmdCount": 0, "PullCmdCount": 1, "PullCmdCountTotal": 5106, "PushCmdCount": 0, "PushCmdCountTotal": 333, "SenderBufCount": 0 "SourceAddress": "192.168.47.150 25T17:45:23Z 10379", "SourceDBOffset": 0, "StartTime": "2019-06-25T17:45:23Z", "Status": "incr", "SuccessCmdCount": 0, "SuccessCmdCountTotal": 333, "TargetAddress": ["192.168.9.87 Status"], "TargetDBOffset": 0}]

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