zoukankan      html  css  js  c++  java
  • redis中使用redis-dump导出、导入、还原数据实例

    转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/109.html?1455861283

    redis的备份和还原,借助了第三方的工具,redis-dump

    1、安装redis-dump

    代码如下:


    [root@localhost tank]# yum install ruby rubygems ruby-devel   //安装rubygems 以及相关包  
    [root@localhost tank]# gem sources -a http://ruby.taobao.org/   //源,加入淘宝,外面的源不能访问  
    http://ruby.taobao.org/ added to sources  
    [root@localhost tank]# gem install redis-dump -V   //安装redis-dump  

    2、redis-dump导出数据

    代码如下:

    [root@localhost tank]# telnet 127.0.0.1 6379 //telnet到redis  
    Trying 127.0.0.1...  
    Connected to 127.0.0.1.  
    Escape character is '^]'.  
    set test 11 //设置一个值  
    +OK  
    get test //取值  
    $2  
    11  
      
    [root@localhost tank]# redis-dump -u 127.0.0.1:6379 >test.json //导出数据  

    3、redis-load还原数据

    代码如下:


    [root@localhost tank]# telnet 127.0.0.1 6379 //telnet到redis  
    Trying 127.0.0.1...  
    Connected to 127.0.0.1.  
    Escape character is '^]'.  
    flushall //请空所有数据  
    +OK  
    keys * //查看已清空  
    *0  
      
    [root@localhost tank]# < test.json redis-load //导入数据  
      
    [root@localhost tank]# telnet 127.0.0.1 6379  
    Trying 127.0.0.1...  
    Connected to 127.0.0.1.  
    Escape character is '^]'.  
    keys * //已导入成功  
    *1  
    $4  
    test  

  • 相关阅读:
    docker实例之mysql的使用
    使用Dockerfile创建ssh服务的镜像02
    添加ssh服务构建新镜像-docker commit 方式01
    Keepalived
    ubuntu网卡配置
    升级openssl
    源码安装nginx env
    dockerfile
    shell字符截取
    MYSQL导入/迁移后事件不执行
  • 原文地址:https://www.cnblogs.com/itxuexiwang/p/5200789.html
Copyright © 2011-2022 走看看