Today probably research under wiredtiger engine, MONGO from 3.0, mainly in order to solve the problem of eating more memory, occupy a lot of disk space, in fact, even with the WT engine, in the performance is still worse than tokuft, but tokuft in the function of the code iteration too slow, back to the second we still use the MONGO, First 3.0 when the default is still MMAPV1 engine, so need to re-specify the WT engine, from 3.2 version is the default WT, I use the current is 3.4 is the optimization of the configuration, read a lot of people write things, are special is copied, I write an official document on the bar, to this record
Storage.wiredtiger Optionsstorage:wiredTiger:engineConfig:cacheSizeGB: <number> journalcom Pressor: <string> directoryforindexes: <boolean> collectionconfig:blockcompressor: <s Tring> indexconfig:prefixcompression: <boolean>
This is official, and it's my own.
storage: dbpath: /var/lib/mongo journal: enabled: true# engine:# mmapv1:# wiredTiger: wiredTiger: engineconfig: cachesizegb: 0.25 ## #这里Size是WT本身的Cache大小并不代表Mongod使用的内存, ## #默认是Max (1G, Memory 1/2), here as much as possible, as far as possible to the thermal data can be cache, ## #保证Dirty Not more than 1%, of course, this with their own business, read and write query speed related, ## #另外它Cache的单位是Page而不是Document. journalcompressor: snappy # #单独为Journal Log specifies the compression method, default snappy, support "None, Snappy, zlib",  , # #一般情况下不需要用zlib, although the compression rate is large, but the CPU occupancy rate is also high. Directoryforindexes: true ## index files and data files, index a directory, a directory of data. collectionConfig: blockcompressor: zlib ### #数据库中Collection的压缩方式, The default is snappy, which also supports "none, Snappy, zlib", ### #一般snappy足够, snappy &NBSP;CPU use is low, the compression rate is not very high, but can meet the general business needs, ### #zlib是压缩率最高的, CPU utilization is also high, if the CPU resources are abundant, in order to reduce disk space can choose Zlib. indexConfig: prefixcompression: true ## #是否开启索引的前缀压缩, which affects the index of all the db. It stores all prefixes of the same index at once, ## #减少内存,Disk IO Consumption is turned on by default.
Official text:
Values can range from 256MB to 10TB and can is a float. In addition, the default value has also changed.
Starting in 3.4, the Wiredtiger internal cache, by default, would use the larger of either:
Avoid increasing the Wiredtiger internal cache size above its default value.
With Wiredtiger, MongoDB utilizes both the Wiredtiger internal cache and the filesystem cache.
Via the filesystem cache, MongoDB automatically uses all free memory that's not used by the Wiredtiger cache or by other Processes. Data in the filesystem cache is compressed.
It can be seen that, in the case of large enough memory, or to improve CPU performance mainly, zlib although the highest compression, but also the most eat CPU In addition, when the storage engine switches, start from second, go to the server, Db.shutdownserver (), turn off the server, then clear all the data, then configure the WT engine, and then mount it back, re-sync
Official Original: http://docs.mongoing.com/manual-zh/tutorial/change-replica-set-wiredtiger.html
Steps
This step completely removes the data from the replication set secondary and then restarts the Mongod with the Wiredtiger storage engine , using :d OC: ' Initialize synchronization to complete data synchronization.
When you upgrade a member storage engine in a replication set, the secondary member is upgraded first. The primary is then demoted to a member from the node, after which the upgrade is demoted to the slave nodes.
1
Shut down the secondary member.
In the MONGO Shell, shut down the secondary Mongod instance you wish to upgrade.
Db.shutdownserver ()
2
Prepare A data directory for the newMongodRunning with Wiredtiger.
Prepare A data directory for the new Mongod instance, that would run with the Wiredtiger storage engine. Mongod must has read and write permissions for this directory. You can either delete the contents of the stopped secondary member ' s current Data directory or create a new directory Enti Rely.
Mongod with Wiredtiger won't start with the data files created with a different storage engine.
3
StartMongodWith Wiredtiger.
Start mongod, specifying wiredtiger as the--storageengine and the prepared data directory for Wiredtige R as the--dbpath. Specify additional options as appropriate for this replica set member.
mongod --storageengine wiredtiger --dbpath <newwiredtigerdbpath> --replset <replsetname>
Since no data exists in the --dbpath, the Mongod would perform an initial sync. The length of the initial sync process depends on the size of the database and network connection between members of the R Eplica set.
You can also specify the options in a configuration file. To specify the storage engine, use thestorage.engine setting.
4
Repeat the procedure for other replica set secondaries you wish to upgrade.
Perform This procedure again for the rest of the secondary , the replica set you wish to the Wiredti GER Storage engine.
mongodb3.4.4 installation replica set, WT engine configuration optimization (ii)