redisデータベースの複製

rdbファイルの複製ではなく、db10 → db18とかに複製する方法。

[code]source_host=localhost
source_port=xxxx
source_db=10
target_host=localhost
target_port=xxxx
target_db=18
redis-cli -p $source_port -n $source_db keys \* | while read key; do echo "Copying $key"; \
redis-cli –raw -h $source_host -p $source_port -n $source_db DUMP "$key" | \
head -c -1|redis-cli -x -h $target_host -p $target_port -n $target_db RESTORE "$key" 0; done
[/code]

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です