无法创建超过 500 兆字节的上限集合 [英] Cannot create a capped collection larger than 500 Megabytes
问题描述
我在 32 位系统上使用 Mongo db,我需要创建一个最大大小为 1GB 的大型上限集合.在 64 位系统上一切正常,但在 32 位系统上出现错误:
I'm using a Mongo db on 32bit system and I need to create a large capped collection with a max size of 1GB. Everything works fine on 64bit system, but on 32bit I'm getting the error:
com.mongodb.CommandResult$CommandFailure: command failed [command failed [create] {
"serverUsed" : "localhost:27017" ,
"errmsg" : "exception: assertion db\\pdfile.cpp:437" ,
"code" : 0 ,
"ok" : 0.0}
在 32 位系统上,服务器的总存储大小为 2GB,但即使有这个大小,我也无法创建大于 500MB 的集合.这个神奇的数字是什么意思?
The total storage size for the server is 2GB on 32bit system, but even with this size I can't create a collection larger than 500MB. What does this magic number mean?
Mongo db 服务器版本为 2.0.6
Mongo db server version is 2.0.6
附加信息:
我有几个数据库文件,总大小为 34MB
.在运行 mongo db 之前,我将这些文件复制到data"目录中,启动 Mongo db,然后在 shell 中我看到总大小相同的数字 - 35651584 (34MB)
(命令使用的是从下面的评论中获取的).如果我尝试创建一个大小为 500MB 的集合,我会看到添加了一个新文件 (512MB).但是,例如,如果我尝试创建一个大小为 600MB 的集合,则会出现上面描述的错误(但仍添加了 512MB 的文件).
I have a couple of database files, the total size of which is 34MB
. Before running a mongo db, I'm copying those files into the 'data' directory, starting Mongo db and then in shell I see the same number for the totat size - 35651584 (34MB)
(the command used is taken from the comments below). If I try to create a collection of size 500MB I see a new file added (512MB). But if for example I will try to create a collection of size 600MB, I have an error discribed above (but the 512MB file still added).
Mongo db 使用命令行选项启动:
The Mongo db is started with the command line options:
> db.adminCommand("getCmdLineOpts")
{
"argv" : [
"mongod.exe",
"--dbpath",
"..\\data",
"-vvvvvv",
"--logpath",
"..\\log\\server.log"
],
"parsed" : {
"dbpath" : "..\\data",
"logpath" : "..\\log\\server.log",
"vvvvvv" : true
},
"ok" : 1
}
>
推荐答案
MongoDB 运行在 64 位系统上好多了,你能改成 x64 吗?正如 Stennie 所说,由于数据库中的其他数据,您很可能会达到 mmap 限制.
MongoDB runs much better on a 64-bit system, can you change to x64? As Stennie said you're must likely hitting a mmap limit due to other data in your database.
您能否通过连接 mongo shell 并尝试通过运行一个比 512 MB 大 1 个字节的新集合来创建一个新集合来测试这个假设 -
Can you test this hypothesis by connecting with the mongo shell and trying to create a new by running a new collection that is 1 byte larger than 512 MB -
db.createCollection("mycoll6", {capped:true, size:536870913})
您应该会收到以下错误消息 -
You should hopefully get the following error message -
"errmsg" : "exception: can't map file memory - mongo requires 64 bit build for larger datasets",
在 Mongo shell 中,连接到 admin 数据库,查看你的数据库大小,看看你有多少数据 -
In the Mongo shell, connect to the admin database and view the size of your database to see how much data you have -
use admin
show dbs
更新:基于一些额外的测试(我使用的是 Ubuntu 12.04 32 位),这似乎是一个错误.
Update: based on some additional testing (I used Ubuntu 12.04 32-bit), this seems like it could be a bug.
Ubuntu 测试
db.createCollection("my13", {ipped:true, size:536608768}){"errmsg" : "异常:断言 db/pdfile.cpp:437",代码":0,好的":0}db.createCollection("my13", {capped:true, size:536608767}){ "ok" : 1 }`
db.createCollection("my13", {capped:true, size:536608768}) { "errmsg" : "exception: assertion db/pdfile.cpp:437", "code" : 0, "ok" : 0 } db.createCollection("my13", {capped:true, size:536608767}) { "ok" : 1 }`
536608767 字节略低于 512 MB,为文件中的某种标题留出空间.
536608767 bytes is a little under 512 MB, leaving room for some sort of header in the file.
我认为这可能与 [smallfiles][2]
相关,因为所有 32 位安装都使用该选项运行,但是,带有 smallfiles
的 x64 构建确实如此没有表现出相同的症状.
I thought it was maybe related to [smallfiles][2]
as all 32-bit installs run with that option, however, an x64 build with the smallfiles
does not display the same symptoms.
我已针对此问题记录了 SERVER-6722.
I have logged SERVER-6722 for this issue.
这篇关于无法创建超过 500 兆字节的上限集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!