On this page本页内容
The following checklist, along with the Development Checklist list, provides recommendations to help you avoid issues in your production MongoDB deployment.下面的清单以及开发清单列表提供了一些建议,帮助您避免生产MongoDB部署中的问题。
Avoid using NFS drives for your 避免将NFS驱动器用于dbPath
. dbPath
。Using NFS drives can result in degraded and unstable performance. 使用NFS驱动器可能导致性能下降和不稳定。See: Remote Filesystems (NFS) for more information.有关详细信息,请参阅:远程文件系统(NFS)。
Linux/Unix: format your drives into XFS or EXT4. Linux/Unix:将驱动器格式化为XFS或EXT4。If possible, use XFS as it generally performs better with MongoDB.如果可能,使用XFS,因为它通常在MongoDB中表现更好。
Configure the oplog size配置oplog大小 to suit your use case:为了适合您的用例:
The replication oplog window should cover the time needed to restore a replica set member from the last backup.“复制操作日志”窗口应涵盖从上次备份恢复副本集成员所需的时间。
Changed in version 3.4.在版本3.4中更改。
local
数据库中必须有足够的磁盘空间,以便在此数据复制阶段期间临时存储这些oplog记录。
With earlier versions of MongoDB, replication oplog window should cover the time needed to restore a replica set member by initial sync.对于早期版本的MongoDB,复制操作日志窗口应涵盖通过初始同步恢复副本集成员所需的时间。
w:"majority"
write concern for availability and durability.w:"majority"
写关注来进行写操作,以确保可用性和耐用性。mongod
instances.mongod
实例之间的完全双向网络连接。Ensure that your replica set contains an odd number of voting members.确保副本集包含奇数个投票成员。
mongod
instances have 0
or 1
votes.mongod
实例有0
或1
票。mongos
routers in accordance with the Production Configuration guidelines.mongod
, mongos
, and config servers.SAN and Virtualization:
mongod
has provisioned IOPS for its dbPath
, or has its own physical drive or LUN.tcp_keepalive_time
) to 100-120. tcp_keepalive_time
)调整为100-120。Adjust the readahead settings on the devices storing your database files.调整存储数据库文件的设备上的预读设置。
For the WiredTiger storage engine, set readahead between 8 and 32 regardless of storage media type (spinning disk, SSD, etc.), unless testing shows a measurable, repeatable, and reliable benefit in a higher readahead value.对于WiredTiger存储引擎,无论存储介质类型如何(旋转磁盘、SSD等),都应将预读设置在8和32之间,除非测试显示较高的预读值具有可测量、可重复和可靠的好处。
MongoDB commercial supportMongoDB商业支持 can provide advice and guidance on alternate readahead configurations.可以提供关于备用预读配置的建议和指导。
If using 如果在RHEL/CentOS上使用tuned
on RHEL / CentOS, you must customize your tuned
profile. tuned
,则必须自定义tuned
配置文件。Many of the RHEL/CentOS附带的许多tuned
profiles that ship with RHEL / CentOS can negatively impact performance with their default settings. tuned
配置文件会对其默认设置的性能产生负面影响。Customize your chosen 自定义您选择的tuned
profile to:tuned
配置文件,以:
noop
or deadline
disk schedulers for SSD drives.noop
或deadline
磁盘调度器。noop
disk scheduler for virtualized drives in guest VMs.noop
磁盘调度程序。mongod
instances with node interleaving. See: MongoDB and NUMA Hardware for more information.ulimit
values on your hardware to suit your use case. If multiple mongod
or mongos
instances are running under the same user, scale the ulimit
values accordingly. See: UNIX ulimit
Settings for more information.noatime
for the dbPath
mount point.Configure sufficient file handles (fs.file-max
), kernel pid limit (kernel.pid_max
), maximum threads per process (kernel.threads-max
), and maximum number of memory map areas per process (vm.max_map_count
) for your deployment. For large systems, the following values provide a good starting point:
fs.file-max
value of 98000,kernel.pid_max
value of 64000,kernel.threads-max
value of 64000, andvm.max_map_count
value of 128000keepalive
time affect MongoDB Deployments? in the Frequently Asked Questions for more information.atime
on Unix-like systems.atime
。Use MongoDB Cloud Manager or Ops Manager, an on-premise solution available in MongoDB Enterprise Advanced or another monitoring system to monitor key database metrics and set up alerts for them. Include alerts for the following metrics:包括以下指标的警报:
Monitor hardware statistics for your servers. 监视服务器的硬件统计信息。In particular, pay attention to the disk use, CPU, and available disk space.特别要注意磁盘使用、CPU和可用磁盘空间。
In the absence of disk space monitoring, or as a precaution:在没有磁盘空间监控的情况下,或作为预防措施:
storage.dbPath
drive to ensure available space if the disk becomes full.storage.dbPath
驱动器上创建一个4 GB的虚拟文件,以确保磁盘已满时的可用空间。cron+df
can alert when disk space hits a high-water mark, if no other monitoring tool is available.cron+df
组合可以在磁盘空间达到高水位时发出警报。