Redis Data Backup and recovery

Source: Internet
Author: User
Tags redis redis server

Redis provides two persistence options, the RDB and the AOF, respectively.

By default 60 seconds are flushed to disk once [save 60 10000 when there are 1w keys data is changed when the],redis data set is saved in a binary file called Dump.rdb, this policy is called a snapshot.

You can also manually invoke the Save or Bgsave command:

1
/usr/local/bin/redis-cli-h 127.0.0.1-p 6379-a pwd bgsave

Snapshots are easy to recover and files are small, but the snapshot data may be incomplete if you experience downtime. You may need to enable another persistence mode aof, open [appendonly Yes] in the configuration file.

AOF rules for refreshing logs to disk:
Appendfsync always #always indicates that each write operation is synchronized, very slow and very secure.
Appendfsync everysec #everysec表示对写操作进行累积, synchronized once per second
The official recommendation of the everysec, security, is that the speed is not fast enough, if the machine is in trouble, it may lose 1 seconds of data.

You can also manually perform bgrewriteaof for aof backups:

1
/usr/local/bin/redis-cli-h 127.0.0.1-p 6379-a pwd bgrewriteaof

We are now doing is a master (master) more from (Slave), the main library does not open aof persistence, just back up every day rdb[the official advice is to back up the Rdb file every hour, see your strategy], and on the library to open aof backup, The corresponding backup file is pushed to the backup server using a script.
When the Redis server is hung up, the restart will restore data to memory according to the following priority: If you configure AOF only, load aof file recovery data when restarting, if RBD and AOF are configured at the same time, boot is only load aof file recovery data; If only RBD is configured, startup is to speak load dump file recovery data.

The recovery should be noted that if the main library hangs can not directly restart the main library, otherwise it will directly overwrite the AoF file from the library, make sure that the files to be recovered correctly to start, otherwise it will flush out the original file.

Master-Slave Configuration example

# vim/etc/redis.conf
Daemonize Yes
Port 6379
/var/redis.pid
From server settings
# vim/etc/redis.conf
Daemonize Yes
Port 6300
Slaveof 192.168.1.100 6379
/var/redis.pid

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.