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:
- Snapshot mode (snapshot)
It supports two snapshot modes:
- A scheduled snapshot saves data in the memory to the disk at a certain time.
- 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.
- 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.