设为首页 收藏本站
查看: 2362|回复: 0

[经验分享] mongodb3.4.4安装副本集,wt引擎配置优化(二)

[复制链接]

尚未签到

发表于 2018-10-25 09:05:47 | 显示全部楼层 |阅读模式
  今天大概研究下wiredtiger引擎,mongo从3.0开始引入,主要为了解决吃内存多,占用大量磁盘空间的问题,其实即使用了wt引擎,在性能上还是比tokuft要差,但是tokuft 在功能上代码迭代的太慢,退而求其次大家还是用了mongo,首先3.0的时候默认还是mmapv1 引擎,所以需要重新指定wt引擎,从3.2版本后就是默认了wt了,我用的现在是3.4  主要是配置上的优化,看了好多人的写的东西,都特么是抄的,我写个官方文档上的吧,以此记录
storage.wiredTiger Options  
storage:
  
   wiredTiger:
  
      engineConfig:
  
         cacheSizeGB:
  
         journalCompressor:
  
         directoryForIndexes:
  
      collectionConfig:
  
         blockCompressor:
  
      indexConfig:
  
         prefixCompression:
  这个是官方的,一下是我自己的
storage:  
  dbPath: /var/lib/mongo
  
  journal:
  
    enabled: true
  
#  engine:
  
#  mmapv1:
  
#  wiredTiger:
  
   wiredTiger:
  
      engineConfig:
  
         cacheSizeGB: 0.25
  
         ###这里Size是WT本身的Cache大小并不代表Mongod使用的内存,
  
         ###默认是Max(1G,内存的1/2),这里尽可能给多一些吧,尽量把热数据都可以Cache住,
  
         ###保证Dirty 不要超过1%,当然这个跟自己的业务、读写查询快慢有关,
  
         ###另外它Cache的单位是Page而不是Document。
  

  
         journalCompressor: snappy
  
         ##单独为Journal Log指定压缩方式,默认snappy,支持"none、snappy、zlib",
  
         ##一般情况下不需要用zlib,虽然压缩率较大,但cpu的占用率也高。
  

  
         directoryForIndexes: true   ## Index文件和数据文件分离,索引一个目录,数据一个目录。
  
      collectionConfig:
  
         blockCompressor: zlib
  
         ####数据库中Collection的压缩方式,默认是snappy,同样支持"none、snappy、zlib"",
  
         ####一般snappy足够,snappy cpu使用率较低,压缩率不是非常高,但可以满足一般业务需求,
  
         ####zlib是压缩率最高的,cpu使用率也较高,如果cpu资源充裕,就为了降低磁盘空间可以选择zlib。
  
      indexConfig:
  
         prefixCompression: true
  
         ###是否开启索引的前缀压缩,这里影响所有DB的索引。它会一次存储所有前缀一样的索引,
  
         ###减少内存、磁盘IO的消耗,默认开启。
  官方原文:
  Values can range from 256MB to 10TB and can be a float. In addition, the default value has also changed.
  Starting in 3.4, the WiredTiger internal cache, by default, will use the larger of either:

  •   50% of RAM minus 1 GB, or
  •   256 MB.

  Avoid increasing the WiredTiger internal cache>  With WiredTiger, MongoDB utilizes both the WiredTiger internal cache and the filesystem cache.
  Via the filesystem cache, MongoDB automatically uses all free memory that is not used by the WiredTiger cache or by other processes. Data in the filesystem cache is compressed.
  由此可以看出,在内存足够大的情况下,还是要以提高cpu性能为主,zlib虽然是最高压缩,但也最吃cpu另外,在存储引擎切换的时候,先从second开始,进入服务器,db.shutdownServer(),把服务器关掉,然后清空所有数据,然后配置wt引擎,然后在挂载回去,进行重新同步
  官方的原文:http://docs.mongoing.com/manual-zh/tutorial/change-replica-set-wiredtiger.html
步骤
  这个步骤将复制集中 secondary 的数据完全移除, 然后使用 WiredTiger 存储引擎重启 mongod, 利用:doc:`初始化同步 完成数据同步.
  在升级复制集中的成员存储引擎时, 首先升级 secondary 成员. 然后将 primary 降级为从节点, 之后升级降级为从节点的成员.
  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 new mongod running with WiredTiger.
  Prepare a data directory for the new mongod instance that will run with the WiredTiger storage engine.mongod must have 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 entirely.
  mongod with WiredTiger will not start with data files created with a different storage engine.
  3
Start mongod with WiredTiger.
  Start mongod, specifying wiredTiger as the --storageEngine and the prepared data directory for WiredTiger as the --dbpath. Specify additional options as appropriate for this replica set member.
mongod --storageEngine wiredTiger --dbpath  --replSet
  Since no data exists in the --dbpath, the mongod will perform an initial sync. The length of the initial sync process depends on the>  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 members of the replica set you wish to use the WiredTiger storage engine.



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-626162-1-1.html 上篇帖子: mongodb3.4.4安装副本集,分片和遇到的一些问题(一) 下篇帖子: mongodb非正常关闭无法启动
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表