Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis persistent configuration (rdb,aof)

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

There are two ways to persist Redis: 1 snapshot 2 is a log

Configuration options for Rdb snapshots (snapshots in memory are written to disk faster)

Configuration file:

1 write within 900s of save 9001 / 900s, then a snapshot is generated

Save 1000 / / if there are 1000 writes in 300 seconds, a snapshot is generated

Save 60 10000 / / if there are 10000 writes in 60 seconds, a snapshot is generated

(if all three options are masked, rdb is disabled)

When there is an error in the stop-writes-on-bgsave-error yes / / background backup process, does the main process stop writing?

Whether the exported rdb file of rdbcompression yes / / is compressed

Rdbchecksum yes / / when importing rbd recovery data, do you want to verify the integrity of rdb?

Dbfilename dump.rdb / / exported rdb file name

The placement path of dir. / rdb

Configuration of Aof

Appendonly no # whether to turn on aof logging function

Appendfsync always # every command is immediately synchronized to aof. Safe, slow

Appendfsync everysec # compromise, write once per second

Appendfsync no # write work to the operating system, the operating system to determine the size of the buffer, unified write to aof. Low synchronization frequency and high speed

No-appendfsync-on-rewrite yes: # do you want to stop synchronizing aof while exporting rdb snapshots?

Auto-aof-rewrite-percentage 100 # aof file size compared to the size of the last rewrite, when the growth rate is 100%, rewrite

Auto-aof-rewrite-min-size 64mb # aof file, overridden when it exceeds at least 64m

Note: will aof be lost if it stops synchronization during dump rdb?

Answer: no, all operations are cached in the memory queue. After the dump is completed, the operation will be unified.

Note: what is aof rewriting?

A: aof rewriting refers to the data in memory, inverted into commands, and written to the .aof log.

To solve the problem that aof log is too large.

Q: if both rdb files and aof files exist, who is the priority to restore data?

A: aof

Q: can the two be used at the same time?

A: yes, and it is recommended

Q: which is faster to recover, rdb or aof?

Answer: rdb is fast, because it is a memory map of data and is directly loaded into memory, while aof is a command that needs to be executed one by one.

Redis server-side command

Redis 127.0.0.1 6380 > time, showing server time, timestamp (seconds), and microseconds

1) "1375270361"

2) "504511"

Redis 127.0.0.1 key 6380 > dbsize / / number of current database key

(integer) 2

Redis 127.0.0.1 6380 > select 2

OK

Redis 127.0.0.1 redis [2] > dbsize

(integer) 0

Redis 127.0.0.1 6380 [2] >

The BGREWRITEAOF background process overrides AOF

BGSAVE background saves rdb Snapshot

SAVE saves rdb Snapshot

Last saved time of LASTSAVE

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report