How does redis export data?

Source: Internet
Author: User
Document directory
  • How is data stored? ,
  • Where can data be stored?
  • How to export data?
  • How to restore Data?

Redis is a key-value database that supports multiple data types.

This section describes how to export data from redis.

 

How is data stored? ,

Redis stores data in the memory, but it regularly writes the data to the hard disk.

Redis stores data in two ways:

  1. Snapshot mode (snapshot)

    It supports two snapshot modes:

    1. A scheduled snapshot saves data in the memory to the disk at a certain time.
    2. A quantitative snapshot is used to save data to a disk after a certain number of data changes.

    You can also use these two methods, for example, change 1000 times, and save the data more than 60 seconds after the last storage time.

  2. Write mode (append only file)

    In this mode, redis will save the data modification commands (such as update and set) to an ASAP file that can only be appended. When redis restarts, it will re-execute the commands in this file.

 

Where can data be stored?

The data is saved to a data file. The specific file name depends on the redis configuration file, that is, redis. conf.

The configuration file is in/usr/local/redis. conf

 

Dbfilename demo. RDB

 

No. This is the demo. RDB file.

 

How to export data?

Redis writes data to a temp file first, and then renames the temp file as a pre-defined file. Therefore, even if redis is running, you can directly use the CP command to copy the file.

CP/usr/loca/redis/demo. Rdb/home/greenerycn/DB/demo. RDB

 

 

How to restore Data?

Shut down redis, overwrite demo. RDB, and restart it.

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.