开发人员创建了数百万个集合和索引,这意味着数百万个collection-*
文件index-*
。
我在 mongod 3.2.6 的副本集(3 节点)上没有管理登录(数据库用户)。我希望仅使用 Linux 命令初始化 MongoDB 数据目录。在 MariaDB 中有mysql_install_db
命令。
错误信息
2017-01-14T05:25:38.674+0000 E STORAGE [thread2] WiredTiger (24) [1484371538:674300][60390:0x7fcc4bc69700], file:WiredTiger.wt, WT_SESSION.checkpoint: /var/vcap/store/mongodb-data/example/WiredTiger.turtle: handle-open: open: Too many open files
2017-01-14T05:25:38.737+0000 I - [conn2] Assertion: 13538:couldn't open [/proc/60390/stat] errno:24 Too many open files
2017-01-14T05:25:38.738+0000 I NETWORK [conn2] end connection 127.0.0.1:39289 (12 connections now open)
2017-01-14T05:25:38.738+0000 I NETWORK [conn6] end connection 127.0.0.1:39347 (12 connections now open)
2017-01-14T05:25:38.738+0000 I NETWORK [conn9] end connection 127.0.0.1:39453 (12 connections now open)
2017-01-14T05:25:38.769+0000 I COMMAND [conn10] command example command: collStats { collstats: "090f42d6-5368-46c6-80
ca-2a8e7e380693" } keyUpdates:0 writeConflicts:0 numYields:0 reslen:9450 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r:
1 } } } protocol:op_query 161ms
2017-01-14T05:25:38.783+0000 E STORAGE [thread2] WiredTiger (24) [1484371538:783882][60390:0x7fcc4bc69700], checkpoint-server: checkpoint server error: Too many open files
2017-01-14T05:25:38.783+0000 E STORAGE [thread2] WiredTiger (-31804) [1484371538:783983][60390:0x7fcc4bc69700], checkpoint-server: the process must exit and restart: WT_PANIC: WiredTiger
library panic
2017-01-14T05:25:38.784+0000 I - [thread2] Fatal Assertion 28558
2017-01-14T05:25:38.784+0000 I - [thread2]
***aborting after fassert() failure
2017-01-14T05:25:38.784+0000 I - [WTJournalFlusher] Fatal Assertion 28559
2017-01-14T05:25:38.784+0000 I - [WTJournalFlusher]
***aborting after fassert() failure
2017-01-14T05:25:38.789+0000 F - [thread2] Got signal: 6 (Aborted).
0x1383b32 0x1382c89 0x1383492 0x7fcc50af2330 0x7fcc50753c37 0x7fcc50757028 0x130dba2 0x1109083 0x1ae49dc 0x1ae4e9d 0x1ae5284 0x1a69dbb 0x7fcc50aea184 0x7fcc5081737d
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"400000","o":"F83B32","s":"_ZN5mongo15printStackTraceERSo"},{"b":"400000","o":"F82C89"},{"b":"400000","o":"F83492"},{"b":"7FCC50AE2000","o":"10330"},{"b":"7FCC5071D000","o":"36C37","s":"gsignal"},{"b":"7FCC5071D000","o":"3A028","s":"abort"},{"b":"400000","o":"F0DBA2","s":"_ZN5mongo13fassertFailedEi"},{"b":"400000","o":"D09083"},{"b":"400000","o":"16E49DC"
,"s":"__wt_eventv"},{"b":"400000","o":"16E4E9D","s":"__wt_err"},{"b":"400000","o":"16E5284","s":"__wt_panic"},{"b":"400000","o":"1669DBB"},{"b":"7FCC50AE2000","o":"8184"},{"b":"7FCC5071D00
0","o":"FA37D","s":"clone"}],"processInfo":{ "mongodbVersion" : "3.2.6", "gitVersion" : "05552b562c7a0b3143a729aaa0838e558dc49b25", "compiledModules" : [ "enterprise" ], "uname" : { "sysna
me" : "Linux", "release" : "3.19.0-64-generic", "version" : "#72~14.04.1-Ubuntu SMP Fri Jun 24 17:59:48 UTC 2016", "machine" : "x86_64" }, "somap" : [ { "elfType" : 2, "b" : "400000", "bui
ldId" : "88B6197786F38A44F8D924B095DAD84A9E55F2C8" }, { "b" : "7FFF49FFB000", "elfType" : 3, "buildId" : "C89BD46B7CFC47F3E55EF539B3FAF8E450562F6A" }, { "b" : "7FCC52C73000", "path" : "/us
r/lib/x86_64-linux-gnu/libsasl2.so.2", "elfType" : 3, "buildId" : "666B276BD134B0E9579B67D4EE333F2D0FB813CD" }, { "b" : "7FCC52806000", "path" : "/usr/lib/x86_64-linux-gnu/libnetsnmpmibs.s
o.30", "elfType" : 3, "buildId" : "4630C89B4E7BCCAD8B1B4FFB508962666D6663C2" }, { "b" : "7FCC525F7000", "path" : "/usr/lib/x86_64-linux-gnu/libsensors.so.4", "elfType" : 3, "buildId" : "85
9FDBFDD82F0EFDEB44A433D9D8020A232A35E2" }, { "b" : "7FCC523F3000", "path" : "/lib/x86_64-linux-gnu/libdl.so.2", "elfType" : 3, "buildId" : "DA9B8C234D0FE9FD8CAAC8970A7EC1B6C8F6623F" }, { "
b" : "7FCC5218A000", "path" : "/usr/lib/x86_64-linux-gnu/libnetsnmpagent.so.30", "elfType" : 3, "buildId" : "9E02A41B22FEB1F704B60BA109EC5785131A5090" }, { "b" : "7FCC51F80000", "path" : "
/lib/x86_64-linux-gnu/libwrap.so.0", "elfType" : 3, "buildId" : "54FCBC5B0F994A13A9B0EAD46F23E7DA7F7FE75B" }, { "b" : "7FCC51CA6000", "path" : "/usr/lib/x86_64-linux-gnu/libnetsnmp.so.30",
"elfType" : 3, "buildId" : "E9B667050A5D6C0C4D58826C32DEEAF38B16EBAA" }, { "b" : "7FCC518CA000", "path" : "/lib/x86_64-linux-gnu/libcrypto.so.1.0.0", "elfType" : 3, "buildId" : "AAE7CFF83
51B730830BDBCE0DCABBE06574B7144" }, { "b" : "7FCC51683000", "path" : "/usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2", "elfType" : 3, "buildId" : "55F72A23CB9C0F7529F0E0BEE43981864B74C4FE"
}, { "b" : "7FCC5137D000", "path" : "/lib/x86_64-linux-gnu/libm.so.6", "elfType" : 3, "buildId" : "D144258E614900B255A31F3FD2283A878670D5BC" }, { "b" : "7FCC5111E000", "path" : "/lib/x86_6
4-linux-gnu/libssl.so.1.0.0", "elfType" : 3, "buildId" : "74864DB9D5F69D39A67E4755012FB6573C469B3D" }, { "b" : "7FCC50F16000", "path" : "/lib/x86_64-linux-gnu/librt.so.1", "elfType" : 3, "
buildId" : "E2A6DD5048A0A051FD61043BDB69D8CC68192AB7" }, { "b" : "7FCC50D00000", "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1", "elfType" : 3, "buildId" : "36311B4457710AE5578C4BF00791DED
7359DBB92" }, { "b" : "7FCC50AE2000", "path" : "/lib/x86_64-linux-gnu/libpthread.so.0", "elfType" : 3, "buildId" : "31E9F21AE8C10396171F1E13DA15780986FA696C" }, { "b" : "7FCC5071D000", "pa
th" : "/lib/x86_64-linux-gnu/libc.so.6", "elfType" : 3, "buildId" : "CF699A15CAAE64F50311FC4655B86DC39A479789" }, { "b" : "7FCC52E8E000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType"
: 3, "buildId" : "D0F537904076D73F29E4A37341F8A449E2EF6CD0" }, { "b" : "7FCC50394000", "path" : "/usr/lib/libperl.so.5.18", "elfType" : 3, "buildId" : "73F1E3843DAEC3F6114D138BF002C0A122CC
3707" }, { "b" : "7FCC5017A000", "path" : "/lib/x86_64-linux-gnu/libnsl.so.1", "elfType" : 3, "buildId" : "32E56CFD30B8B4FCD8AA69CED88A9782814A9D18" }, { "b" : "7FCC4FEAF000", "path" : "/u
sr/lib/x86_64-linux-gnu/libkrb5.so.3", "elfType" : 3, "buildId" : "77287B3AF8DD293D7367EEF27C652C04353752EC" }, { "b" : "7FCC4FC80000", "path" : "/usr/lib/x86_64-linux-gnu/libk5crypto.so.3
", "elfType" : 3, "buildId" : "49E3D743C2B3741229AD3892B22C4794C646E1F2" }, { "b" : "7FCC4FA7C000", "path" : "/lib/x86_64-linux-gnu/libcom_err.so.2", "elfType" : 3, "buildId" : "8D56938ABD
6462C4C29822D8E48A131BE1C61F6A" }, { "b" : "7FCC4F871000", "path" : "/usr/lib/x86_64-linux-gnu/libkrb5support.so.0", "elfType" : 3, "buildId" : "0B3ABC152466DE0C69954405A0E980B6E0D4B78F" }
, { "b" : "7FCC4F638000", "path" : "/lib/x86_64-linux-gnu/libcrypt.so.1", "elfType" : 3, "buildId" : "FDB9E0552092EB7559F27C7A9915665408D930F0" }, { "b" : "7FCC4F434000", "path" : "/lib/x8
6_64-linux-gnu/libkeyutils.so.1", "elfType" : 3, "buildId" : "0F03635F97B93D3DACD84F0ED363C56BD266044F" }, { "b" : "7FCC4F219000", "path" : "/lib/x86_64-linux-gnu/libresolv.so.2", "elfType
此错误表明该
mongod
进程无法打开更多文件句柄,因为已达到配置的操作系统资源限制(也称为ulimit
类 UNIX 操作系统,如 Linux)。这些ulimit
设置旨在限制单个用户或进程消耗过多的系统资源。验证和增加 ulimits 是 MongoDB 之外的一项管理任务。有关详细信息,请参阅: MongoDB 手册中的UNIX ulimit 设置。
mongod
在 MongoDB 3.4 中,除了在使用适当的配置文件开始之前从另一个部署复制数据文件之外,没有等同于“初始化”MongoDB 数据目录的方法。也没有类似于 的标准设置脚本mysql_install_db
,它执行准备任务,例如创建架构和用户帐户。MongoDB 生产部署通常配置为副本集或分片集群,因此设置需要整体部署的上下文。部署自动化的典型解决方案包括 MongoDB Cloud Manager (SaaS) 和 MongoDB Ops Manager (on-premises)。根据 MongoDB 手册中的生产说明,使用 MongoDB Cloud Manager 配置的新 AWS 环境将包括 O/S 设置。
您可以增加
ulimit
设置以尝试支持此用例,但是对于数百万个集合,您可能会遇到其他性能问题(例如,listDatabases
必须迭代数百万个文件的统计信息之类的命令)。除非数以百万计的集合和索引是意外创建的,否则我会咨询开发人员并建议他们重新考虑他们的数据模型。