mongodb线上部署注意事项

来源:互联网 发布:python struct模块 编辑:程序博客网 时间:2024/05/16 15:55

mongodb支持的平台及建议使用平台如下:
Amazon Linux
Debian 7.1
RHEL / CentOS 6.2+
SLES 11+
Ubuntu LTS 12.04
Ubuntu LTS 14.04
Windows Server 2012 & 2012 R2

并发
MMAPv1
在3.0开始,MMAPv1提供集合级别的锁,所有的集合有一个唯一的读写锁,允许多个客户端同时对不同的集合进行修改。
wiredtiger
提供在一个集合内读写的并发访问,客户端在写入的时候可以读,在同一时间,多个线程能同时修改一个集合中的不同文档。

数据一致性
需要开启journaling来启用wal,方便故障恢复。

禁用http接口
管理连接池的大小
避免设置过大的连接池浪费资源,一开始设置当前数据库请求的110%~115%的大小。connpoolstats命令能查看连接池的情况

内存及cpu

MMAPv1,由于并发模型的关系,MMAPv1不需要太多的cpu核数,所以确保足够的内存,cpu要求不是很高。确保mongod,mongos能有2个cpu或一个物理核

WiredTiger这个存储引擎是多线程的,能利用多核cpu,内存上,这个存储引擎使用它自己的内部缓存及系统缓存,在3.4开始,wiredtiger的内部缓存使用下面2个值较大的:
50% of RAM minus 1 GB, or
256 MB.
对于系统缓存,mongodb自动使用所有的剩余的缓存,为了调整wiredtiger的内部缓存,
storage.wiredTiger.engineConfig.cacheSizeGB and –wiredTigerCacheSizeGB.

The storage.wiredTiger.engineConfig.cacheSizeGB limits the size of the WiredTiger internal cache. The operating system will use the available free memory for filesystem cache, which allows the compressed MongoDB data files to stay in memory. In addition, the operating system will use any free RAM to buffer file system blocks and file system cache.
为了查看内存的使用,查看serverstatus中的wiredTiger.cache字段
未完
https://docs.mongodb.com/manual/administration/production-notes/#architecture

原创粉丝点击