zoukankan      html  css  js  c++  java
  • master-slave replication

    redis save 备份 恢复

    root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt

    redis-cli save

    cp /var/lib/redis/dump.rdb /var/lib/redis/BEFOREdump.rdb

    redis-cli flushall

    ./redis-server stop

    cp /var/lib/redis/BEFOREdump.rdb /var/lib/redis/dump.rdb

    root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt
    -rw-r--r-- 1 redis redis 18 May  5 07:36 /var/lib/redis/dump.rdb
    -rw-r--r-- 1 root  root  18 May  5 06:59 /etc/redis/dump.rdb
    -rw-r--r-- 1 root  root  18 May  5 06:55 /etc/init.d/dump.rdb
    -rw-rw-r-- 1 wuser wuser 18 May  4 23:58 /home/wuser/dump.rdb
    -rw-r--r-- 1 root  root  18 May  4 23:54 /dump.rdb
    root@ubuntu:/etc/init.d# redis-cli
    127.0.0.1:6379> keys
    (error) ERR wrong number of arguments for 'keys' command
    127.0.0.1:6379> keys *
    (empty list or set)
    127.0.0.1:6379> set  w2  3211
    OK
    127.0.0.1:6379> set  w2d  3211
    OK
    127.0.0.1:6379> save
    OK
    127.0.0.1:6379> exit
    root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt
    -rw-r--r-- 1 redis redis 35 May  5 07:37 /var/lib/redis/dump.rdb
    -rw-r--r-- 1 root  root  18 May  5 06:59 /etc/redis/dump.rdb
    -rw-r--r-- 1 root  root  18 May  5 06:55 /etc/init.d/dump.rdb
    -rw-rw-r-- 1 wuser wuser 18 May  4 23:58 /home/wuser/dump.rdb
    -rw-r--r-- 1 root  root  18 May  4 23:54 /dump.rdb
    root@ubuntu:/etc/init.d# cp /var/lib/redis/dump.rdb /var/lib/redis/BEFOREdump.rdb
    root@ubuntu:/etc/init.d# redis-cli
    127.0.0.1:6379> KEYS *
    1) "w2d"
    2) "w2"
    127.0.0.1:6379> flushall
    OK
    127.0.0.1:6379> exit
    root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt
    -rw-r--r-- 1 redis redis 18 May  5 07:38 /var/lib/redis/dump.rdb
    -rw-r--r-- 1 root  root  18 May  5 06:59 /etc/redis/dump.rdb
    -rw-r--r-- 1 root  root  18 May  5 06:55 /etc/init.d/dump.rdb
    -rw-rw-r-- 1 wuser wuser 18 May  4 23:58 /home/wuser/dump.rdb
    -rw-r--r-- 1 root  root  18 May  4 23:54 /dump.rdb
    root@ubuntu:/etc/init.d# redis-cli
    127.0.0.1:6379> keys *
    (empty list or set)
    127.0.0.1:6379> exit
    root@ubuntu:/etc/init.d# ./redis-server stop
    [ ok ] Stopping redis-server (via systemctl): redis-server.service.
    root@ubuntu:/etc/init.d# cp /var/lib/redis/BEFOREdump.rdb /var/lib/redis/dump.rdb 
    root@ubuntu:/etc/init.d# ./redis-server start
    [ ok ] Starting redis-server (via systemctl): redis-server.service.
    root@ubuntu:/etc/init.d# redis-cli
    127.0.0.1:6379> keys *
    1) "w2"
    2) "w2d"
    127.0.0.1:6379> exit
    root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt
    -rw-r--r-- 1 redis redis 35 May  5 07:40 /var/lib/redis/dump.rdb
    -rw-r--r-- 1 root  root  18 May  5 06:59 /etc/redis/dump.rdb
    -rw-r--r-- 1 root  root  18 May  5 06:55 /etc/init.d/dump.rdb
    -rw-rw-r-- 1 wuser wuser 18 May  4 23:58 /home/wuser/dump.rdb
    -rw-r--r-- 1 root  root  18 May  4 23:54 /dump.rdb
    root@ubuntu:/etc/init.d# 

    w

    https://redis.io/topics/replication

  • 相关阅读:
    android之PackageManager简单介绍
    OUI-67076 : OracleHomeInventory was not able to create a lock file" in Unix
    编程之美2013 初赛一 A
    Unity3D之挥动武器产生的剑痕特效
    怎样在万网加入Lync Online SRV记录
    mysql-定时调用存储过程
    在TextView中加入图片
    shell语法简单介绍
    quick-cocos2d-x android返回键监听并实现原生退出对话框
    秒杀多线程第四篇 一个经典的多线程同步问题
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6814845.html
Copyright © 2011-2022 走看看