Redis迁移的两种方式
#!/bin/bash#redis 源ip
src_ip=192.168.0.1
#redis 源port
src_port=6379
#redis 源库
src_db=1
#redis 目的ip
dest_ip=192.168.0.1
#redis 目的port
dest_port=6379
#redis 目的
dest_db=3
#redis 密码
pw=123456
#要遍历的key
k=(medical_record:id medical_record_attachment:id patient_family_present:id patient_present:id patient_disease:id family_disease:id patient_allergy:id history_allergy:id)
#要迁移的key前缀
#key_prefix=com.example.test
for loop in ${k
[*]}
do
redis-cli -h $src_ip -p $src_port -a $pw -n $src_db --raw dump $loop | perl -pe 'chomp if eof' | redis-cli -h $dest_ip -p $dest_port -a $pw -n $dest_db -x restore $loop 0
echo "The value is: $loop"
done
页:
[1]