安装
yum install epel-release
yum install redis
##开启远程
vim /etc/redis.conf
bind ip #本机ip
##systemctl start redis
##redis-cli -h 192.168.190.139
实验成功的aof方式
#实例1,源实例开启aof功能,将在dir目录下生成appendonly.aof文件
config set appendonly yes
BGSAVE
save
#获取appendonly.aof 文件后转移至实例2 导入
redis-cli -h 192.168.2.141 --pipe < appendonly.aof
#检查数据
源实例db0迁移至目标实例db1
未测试
#!/bin/bash
redis-cli -h x.1 -p 6379 -a password -n 0 keys "*" | while read key
do
redis-cli -h x.1 -p 6379 -a password -n 0 --raw dump $key | perl -pe 'chomp if eof' | redis-cli -h x.2 -p 6379 -a password -n 1 -x restore $key 0
echo "migrate key $key"
done
redis-dump工具
未测试
yum install ruby rubygems ruby-devel -y
gem sources -a http://ruby.taobao.org
gem sources --add http://gems.ruby-china.org/ --remove http://rubygems.org/
gem install redis-dump -V
#导出数据
redis-dump -u :password@172.20.0.1:6379 > 172.20.0.1.json
#导入数据
cat 172.20.0.1.json | redis-load -u :password@172.20.0.2:6379