mongodb给我们提供了fsync+lock机制把数据暴力的刷到硬盘上
能不能把数据暴力的刷到硬盘上,当然是可以的,mongodb给我们提供了fsync+lock机制就能满足我们提的需求。
fsync+lock首先会把缓冲区数据暴力刷入硬盘,然后给数据库一个写入锁,其他实例的写入操作全部被阻塞,直到fsync
+lock释放锁为止。
这里就不测试了。
加锁: db.runCommand({"fsync":1,"lock":1})
释放锁: db.$cmd.unlock.findOne()
fsync
-
Forces the
mongodprocess to flush all pending writes from the storage layer to disk. Optionally, you can usefsyncto lock themongodinstance 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
syncPeriodSecsinterval, which is 60 seconds by default. Runfsyncwhen you want to flush writes to disk ahead of that interval.The
fsynccommand has the following syntax:{ fsync: 1, async: <Boolean>, lock: <Boolean> }The
fsynccommand has the following fields:Field Type Description fsyncinteger Enter “1” to apply fsync.asyncboolean Optional. Runs fsyncasynchronously. By default, thefsyncoperation is synchronous.lockboolean Optional. Locks mongodinstance and blocks all write operations.
Examples
Run Asynchronously
The fsync operation is synchronous by default. To run fsync asynchronously, use the async field set totrue:
{ fsync: 1, async: true }
The operation returns immediately. To view the status of the fsync operation, check the output ofdb.currentOp().
Lock mongod Instance
NOTE
Changed in version 3.2: fsync command with the lock option can ensure that the data files do not change for MongoDB instances using either the MMAPv1 or the WiredTiger storage engines, thus providing consistency for the purposes of creating backups.
In previous MongoDB versions, fsync command with the lock option cannot guarantee a consistent set of files for low-level backups (e.g. via file copy cp, scp, tar) for WiredTiger.
The primary use of fsync is to lock the mongod instance in order to back up the files within mongod‘sdbPath. The operation flushes all data to the storage layer and blocks all write operations until you unlock themongod instance.
To lock the database, use the lock field set to true:
{ fsync: 1, lock: true }
You may continue to perform read operations on a mongod instance that has a fsync lock. However, after the first write operation all subsequent read operations wait until you unlock the mongod instance.
见:https://docs.mongodb.com/manual/reference/command/fsync/
mongodb给我们提供了fsync+lock机制把数据暴力的刷到硬盘上的更多相关文章
- 转载:Java Lock机制解读
Java Lock机制解读 欢迎转载: https://blog.csdn.net/chengyuqiang/article/details/79181229 1.synchronized synch ...
- C# Note26: [MethodImpl(MethodImplOptions.Synchronized)]与lock机制
在进行.NET开发时,经常会遇见如何保持线程同步的情况.在众多的线程同步的可选方式中,加锁无疑是最为常用的.如果仅仅是基于方法级别的线程同步,使用System.Runtime.CompilerServ ...
- [MethodImpl(MethodImplOptions.Synchronized)]与lock机制
[MethodImpl(MethodImplOptions.Synchronized)]与lock机制 在进行.NET开发时,经常会遇见如何保持线程同步的情况.在众多的线程同步的可选方式中,加锁无疑是 ...
- 使用Spring提供的缓存抽象机制整合EHCache为项目提供二级缓存
Spring自身并没有实现缓存解决方案,但是对缓存管理功能提供了声明式的支持,能够与多种流行的缓存实现进行集成. Spring Cache是作用在方法上的(不能理解为只注解在方法上),其核心思想是 ...
- 如何通过Openssl实现私有CA,并为HTTP服务提供TLS/SLL安全机制
原文链接:http://guodayong.blog.51cto.com/263451/1181059 Openssl是SSL的开源实现(可以免费下载应用程序),是一种安全机密程序,主要用于提高远程登 ...
- 利用LOCK机制来定位前缀劫持者
一.文章信息 作者:Tongqing Qiu, Lusheng Ji, Dan Pei等 单位:佐治亚理工学院.美国电话电报公司实验室.康奈尔大学等 来源:Conference on Usenix S ...
- JUC包Lock机制的支持--AQS
在上一次总结中,提到了JUC包下使用Lock接口实现同步的方法,以及和Synchronized关键字的一些比较,那么使用Lock完成锁机制的底层支持又是什么呢?总结如下: 1 AQS是什么 AQS是一 ...
- (Android数据传递)Intent消息传递机制 “Intent”“数据传递”
Intent类的继承关系: 需要注意的是,该类实现了Parcelable(用于数据传递)和Cloneable接口. Intent是一种(系统级别的)消息传递机制,可以在应用程序内使用,也可以在应用 ...
- 使用HTML5 的跨域通信机制进行数据同步
离线应用系统的设计目标就是在网络离线情况下依然可以操作我们的应用系统,并在网络畅通的情况下与服务器进行数据交互. 所以离线应用系统最终会做成类似C/S架构的客户端应用程序.这边基于Chrome或者 S ...
随机推荐
- VS2010 + WinDDK 搭建驱动开发环境(转)
因工作需要,需要研究一下Windows驱动开发.我们知道,编译驱动程序主要是通过两种方案:第一种是通过WinDDK提供的build命令+source文件进行编译:另外一种是通过VC的IDE进行编译. ...
- 【IntelliJ IDEA】在idea上安装使用svn
1.在电脑上安装SVN 下载地址:64位SVN下载 然后一路next,安装完成即可. 如果忘记勾选第二个,可以重新点击安装包 重新安装,然后选择modify,然后勾选command line cli ...
- iOS -- 十进制、十六进制字符串,byte,data等之间的转换
十进制->十六进制 Byte bytes[]={0xA6,0x27,0x0A}; NSString *strIdL = [NSStringstringWithFormat:]]]; 十六进制-& ...
- C#开发ActiveX控件,.NET开发OCX控件案例 【转】
http://xiaochen.2003.4.blog.163.com/blog/static/480409672012530227678/ 讲下什么是ActiveX控件,到底有什么作用?在网页中又如 ...
- Html5学习笔记1 元素 标签 属性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Android 适配器教程 (六)
我们的适配器学习已经接近尾声了.尽管这不是一个大问题,可是确实是值得学习的一块知识,回忆一下之前五讲的知识.我们已经学到了非常多东西了. 在之前五讲中.我们已经由浅入深的认识了适配器,从最简单的Lis ...
- 小胖说事20--------GCD笔记
1.系统提供的dispatch方法 为了方便的使用GCD.苹果提供了一些方法方便我们将BLOCK放在主线程或者后台程序运行.或者延后运行. //后台运行: dispatch_async(dispatc ...
- Apcahe Shiro学习笔记(二):通过JDBC进行权限控制
一.概述: 官方对Realm(领域)的描述:https://www.infoq.com/articles/apache-shiro 其功能本质上是一个安全特定的DAO,用于链接数据持久层(任何形式的都 ...
- IOS8 TouchID使用介绍
本文转载至 http://blog.csdn.net/jinkaiouyang/article/details/35555123 IOS8将指纹识别技术开放出来了.我们能够利用用户设置的touch I ...
- springboot实战--笔记
由于这本书看过一遍,所以这里是二次复习,记录的东西比较少,就不分章节了. 共12章,524页,预计时间是18h 第一章 spring基础: 第二章 spring常用配置: bean的Scope:sin ...