zoukankan      html  css  js  c++  java
  • redis 数据导入导出,实例内db迁移

    源实例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
  • 相关阅读:
    线程间协作的两种方式:wait、notify、notifyAll和Condition
    Lock
    线程池ExecutorService的使用
    使用volatile的条件
    解决共享资源竞争
    并发时捕获异常
    Executor执行器
    BufferedReader 和BufferedWriter
    彻底理解Java的Future模式
    贝叶斯网络简介--翻译版
  • 原文地址:https://www.cnblogs.com/yum777/p/9720834.html
Copyright © 2011-2022 走看看