mongodb给我们提供了fsync+lock机制把数据暴力的刷到硬盘上
Forces the mongod process to flush all pending writes from the storage layer to disk. Optionally, you can use fsync to lock the mongod instance and block write operations for the purpose of capturing backups.As applications write data, MongoDB records the data in the storage layer and then writes the data to disk within the syncPeriodSecs interval, which is 60 seconds by default. Run fsync when you want to flush writes to disk ahead of that interval.
The fsync command has the following syntax:
{ fsync: 1, async: <Boolean>, lock: <Boolean> }
The fsync command has the following fields:
FieldTypeDescriptionfsync
integer
Enter “1” to apply fsync.
async
boolean
Optional. Runs fsync asynchronously. By default, the fsync operation is synchronous.
lock
boolean
Optional. Locks mongod instance and blocks all write operations.
页:
[1]