Some time ago, we found that the redis memory usage on one of our business servers exceeds 50% of the total server memory. When bgsave is triggered, an error is reported, prompting WARNINGovercommit_memoryissetto0 !..., Then all redis write operations will fail. In this case, there is a solution in the redis official FAQ. in linux, perform the following operations, ec
Some time ago, we found that the redis memory usage on one of our business servers exceeds 50% of the total server memory. When bgsave is triggered, an error is reported, prompting WARNING overcommit_memory is set to 0! ..., And then all redis write operations will fail. In this case, there is a solution in the redis official FAQ. in linux, perform the following operations, ec
Some time ago, we found that the memory usage of redis on one of our business servers exceeds 50% of the total server memory. When bgsave is triggered, an error is reported, promptingWARNING overcommit_memory is set to 0! ...
And all redis write operations will fail. In this case, there is a solution in the redis official FAQ. in linux, perform the following operations,
echo 1 > /proc/sys/vm/overcommit_memory
Specific can see the official FAQ, http://redis.io/topics/faq
After resolving the bgsave problem, we decided to migrate a part of the data to another redis instance and record the migration process below. One of the two solutions is to copy the rdb file or configure a synchronization from redis, but all the data has been migrated and other processing is required. Another solution is to write a migration script to migrate only part of the data to be migrated.
Paste it here
#! /Bin/bash # redis source ipsrc_ip = 192.168.0.10 # redis source portsrc_port = 6379 # redis destination ipdest_ip = 192.168.0.11 # redis destination portdest_port = 6379 # key prefix key_prefix = com. example. 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" (I ++ )) done
References:
1. http://redis.io/commands/DUMP
2. http://stackoverflow.com/questions/16127682/how-to-use-redis-dump-and-restore-offline
Original article address: migrate some redis data to other redis instances. Thanks to the original author for sharing.