当前位置:网站首页>Redis data migration (II)

Redis data migration (II)

2022-07-03 20:48:00 Interesting soul_ A secular heart

Mode one : Use redis-cli Migrating data

Migrating code ( take )192.168.31.216 Server redis Of 0 All data in the database is migrated to the server that executes the command redis Of 0 database :
New file
vim redis-mv.sh And add the following

redis-cli -h 192.168.31.216 -p 6379  -n 0 keys "*" | while read key
do
    redis-cli -h 192.168.31.216 -p 6379  -n 0 --raw dump $key | perl -pe 'chomp if eof' | redis-cli -h 127.0.0.1 -p 6379  -n 0 -x restore $key 0
    echo "migrate key $key"
done

Give the file corresponding permissions , And execute the file

chmod 777 redis-mv.sh
./redis-mv.sh

Execute output diagram
 Insert picture description here
Database value before migration
 Insert picture description here
After the move
 Insert picture description here

原网站

版权声明
本文为[Interesting soul_ A secular heart]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202142358516631.html