1. redis-dump 和 redis-load
(该工具可用来备份还原单个库)
[root@localhost src]# yum -y install centos-release-scl-rh -y
[root@localhost src]# yum install -y rh-ruby24*
[root@localhost src]# scl enable rh-ruby24 bash
[root@localhost ~]# gem install redis-dump -V
[root@localhost src]# redis-dump --help
-u, --uri=S Redis URI (e.g. redis://hostname[:port])
-d, --database=S Redis database (e.g. -d 15)
-a, --password=S Redis password (e.g. -a 'my@pass/word')
-s, --sleep=S Sleep for S seconds after dumping (for debugging)
-c, --count=S Chunk size (default: 10000)
-f, --filter=S Filter selected keys (passed directly to redis' KEYS command)
-b, --base64 Encode key values as base64 (useful for binary values)
-O, --without_optimizations Disable run time optimizations
-V, --version Display version
-D, --debug
--nosafe
eg:
(不指定库的话备份所有的库)
redis-dump -u 192.168.96.88:7379 -d 13 > 7379_13.json
redis-load -u 192.168.96.206:7379 -d 13 < 7379_13.json