源实例db0迁移至目标实例db11 [root@172.20.0.1 ~]# cat redis_mv.sh2 #!/bin/bash3 redis-cli -h 172.20.0.1 -p 6379 -a password -n 0 keys * | while read key4 do5 redis-cli -h 172.20.0.1 -p 6379 -...
源实例db0迁移至目标实例db1
1 [root@172.20.0.1 ~]# cat redis_mv.sh 2 #!/bin/bash 3 redis-cli -h 172.20.0.1 -p 6379 -a password -n 0 keys "*" | while read key 4 do 5 redis-cli -h 172.20.0.1 -p 6379 -a password -n 0 --raw dump $key | perl -pe 'chomp if eof' | redis-cli -h 172.20.0.2 -p 6379 -a password -n 1 -x restore $key 0 6 echo "migrate key $key" 7 done
aof导入方式:
1.源实例生成aof数据
1 # 清空上文目标实例全部数据 2 [root@172.20.0.1 ~]# redis-cli -h 172.20.0.2 -a password flushall 3 OK 4 # 源实例开启aof功能,将在dir目录下生成appendonly.aof文件 5 [root@172.20.0.1 ~]# redis-cli -h 172.20.0.1 -a password config set appendonly yes 6 OK
2.目标实例导入aof数据
1 # 假设appendonly.aof就在当前路径下 2 [root@172.20.0.1 ~]# redis-cli -h 172.20.0.2 -a password --pipe < appendonly.aof 3 All data transferred. Waiting for the last reply... 4 Last reply received from server. 5 errors: 0, replies: 5 6 # 源实例关闭aof功能 7 [root@172.20.0.1 ~]# redis-cli -h 172.20.0.1 -a password config set appendonly no 8 OK
沃梦达教程
本文标题为:redis 数据导入导出,实例内db迁移
猜你喜欢
- SQL Server 2022 AlwaysOn新特性之包含可用性组详解 2023-07-29
- MySQL8.0.28安装教程详细图解(windows 64位) 2023-07-26
- 在阿里云CentOS 6.8上安装Redis 2023-09-12
- 基于Python制作一个简单的文章搜索工具 2023-07-28
- Mongodb启动报错完美解决方案:about to fork child process,waiting until server is ready for connections. 2023-07-16
- SQLSERVER调用C#的代码实现 2023-07-29
- 搭建单机Redis缓存服务的实现 2023-07-13
- Numpy中如何创建矩阵并等间隔抽取数据 2023-07-28
- Oracle 删除大量表记录操作分析总结 2023-07-23
- redis清除数据 2023-09-13