In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Demand
You need to transfer part of the keys from one redis instance to another redis instance
two。 Migration scenario 2.1 Source instance and destination instance version same 2.1.1 use the dump command #! / bin/bash#redis source ipsrc_ip=127.0.0.1#redis source portsrc_port=6392#redis destination ipdest_ip=127.0.0.1#redis destination portdest_port=6393# key prefix key_prefix=testi=1redis-cli-h $src_ip-p $src_port keys "$key_prefix} *" | while read keydo redis-cli-h $dest_ip- P $dest_port del $key redis-cli-h $src_ip-p $src_port-- raw dump $key | perl-pe 'chomp if eof' | redis-cli-h $dest_ip-p $dest_port-x restore $key 0 echo "$i migrate key $key" ((iTunes +)) done2.1.2 uses the migrate command
Migrate usage:
MIGRATE host port key destination-db timeout [COPY] [REPLACE]
Starting version: 2.6.0
Time complexity: This command actually executes a DUMP+DEL in the source instance, and a RESTORE in the target instance. See the pages of these commands for time complexity. Also an O (N) data transfer between the two instances is performed.
Migration script
#! / bin/bash#redis source ipsrc_ip=127.0.0.1#redis source portsrc_port=6392#redis destination ipdest_ip=127.0.0.1#redis destination portdest_port=6393# prefix to be migrated key_prefix=testi=1redis-cli-h $src_ip-p $src_port keys "${key_prefix} *" | while read keydo redis-cli-h $src_ip-p $src_port migrate $dest_ip $dest_port $key 0 1000 replace echo "$i migrate key $key" ) done2.2 source instance and target instance version is different 2.2.1 is not feasible
If the version of the source instance is different from that of the destination instance, there will be the following error when using migrate for migration:
1935 migrate key esf_common_auth_code_18587656289 (error) ERR Target instance replied with error: ERR DUMP payload version or checksum are wrong
If the version of the source instance is different from that of the target instance, there will be the following error when using dump for migration
(error) ERR DUMP payload version or checksum are wrong if the source instance and destination instance version are not the same Directly copy the rdbw file to build the slave library as follows: error 5453 Nov 23 Nov 18 MASTER SLAVE sync: Flushing old data5453:S 23 Nov 18 13 14. 153 * MASTER SLAVE sync: Loading DB in memory5453:S 23 Nov 18 Nov 13 14. 153 # Can't handle RDB format version 85453 MASTER SLAVE sync 13 Nov 13 14. 153 # Failed trying to load the MASTER synchronization DB from disk2.2.2
Enable the source instance aof persistence feature
Config set appendonly yes
Manual aof persistence
Bgrewriteaof creates a new redis instance, which is the same as the target instance version and starts
Import the aof file of the redis of the source instance into the new instance
Redis-cli-h 127.0.0.1-p 6395-a password-- pipe < appendonly.aof migrates the key of the new instance to the target instance through dump or migrate
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.