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 ...
随机推荐
- Maven出现User setting file does not exist ...\.m2\setting.xml的问题解决(同时也解决用户.m2目录下无setting.xml文件)
如果Eclipse中出现User setting file does not exist ...\.m2\setting.xml这样的问题,解决方法如下: 1.拷贝%M2_HOME%/conf/set ...
- 配置laravel的nginx站点
server{}配置 server{ #端口配置 listen 80; #域名配置 server_name laravel.cc; index index.php index.html index.h ...
- debug : 调试主进程启动的子进程
http://blog.csdn.net/lostspeed/article/details/10109867
- javascript --- 原型初探七日谈(二)
扩展内建对象: 在javascript中,内建对象的构造函数都是可以通过其原型来进行扩展的.这意味着我们可以做一些事情,例如我们要往数组原型中添加一个新方法,就可以在其所有的数组中使用,下面我们来试试 ...
- 【spring data jpa】repository中使用@Query注解使用hql查询,使用@Param引用参数,报错:For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on
在spring boot中, repository中使用@Query注解使用hql查询,使用@Param引用参数 如题报错: For queries with named parameters you ...
- Sales Team 仪表盘
实际设定值 仪表定义 <div class="oe_center" t-if="record.invoiced_ta ...
- Convert Sorted List to Binary Search Tree——将链表转换为平衡二叉搜索树 &&convert-sorted-array-to-binary-search-tree——将数列转换为bst
Convert Sorted List to Binary Search Tree Given a singly linked list where elements are sorted in as ...
- 修改host文件原理 localhost,127.0.0.1之间有什么区别
修改host文件原理http://www.zhihu.com/question/19782572 localhost与127.0.0.1的区别是什么 相信有人会说是本地ip,曾有人说,用127.0.0 ...
- c#打包文件解压缩 C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法 一个简单例子理解C#的协变和逆变 对于过长字符串的大小比对
首先要引用一下类库:using Ionic.Zip;这个类库可以到网上下载. 下面对类库使用的封装方法: 得到指定的输入流的ZIP压缩流对象 /// <summary> /// 得到指定的 ...
- uboot下载地址
非常奇怪百度搜索都搜不到一个好的uboot下载的说明,仅此标记 HOME http://www.denx.de/wiki/U-Boot/SourceCode sourcecode http://www ...