问题描述
我有一个可写入副本集的JAVA应用程序.我正在使用3.0.7版本的MongoDB服务器. Java的mongo驱动程序是3.0.4.一切正常,但现在所有写入都出现以下错误:
I have a JAVA app which writes to a replicaset. Am using 3.0.7 version of MongoDB server. The mongo-driver for Java is 3.0.4.It was working just fine but now am getting the following error on ALL writes:
com.mongodb.MongoWriteException: quota exceeded
at com.mongodb.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:487)
at com.mongodb.MongoCollectionImpl.update(MongoCollectionImpl.java:474)
at com.mongodb.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:325)
已经查看了MongoDB的配置文档,但我尚未在mongod.conf中设置任何配额限制.我也不使用smallFiles.
Have looked at the MongoDB config documentation and I have not set any quota limits in mongod.conf. Am not using smallFiles either.
但是我认为已经遇到了文件大小限制.我的数据库的文件大小如下:
But I think am running into fileSize limits. The file sizes for my DB are as follows:
total 6240548
-rw------- 1 mongod mongod 67108864 Dec 8 16:55 2015.0
-rw------- 1 mongod mongod 134217728 Dec 8 12:15 2015.1
-rw------- 1 mongod mongod 268435456 Dec 8 12:15 2015.2
-rw------- 1 mongod mongod 536870912 Dec 8 12:15 2015.3
-rw------- 1 mongod mongod 1073741824 Dec 8 12:15 2015.4
-rw------- 1 mongod mongod 2146435072 Dec 8 16:06 2015.5
-rw------- 1 mongod mongod 2146435072 Dec 8 16:06 2015.6
-rw------- 1 mongod mongod 16777216 Dec 8 16:55 2015.ns
drwxr-xr-x 2 mongod mongod 4096 Dec 7 09:14 _tmp
/etc/mongod.conf如下:
The /etc/mongod.conf is as follows:
storage:
dbPath: /data/mongoDB
indexBuildRetry: true
repairPath: /data/mongoDB/repair
journal:
enabled: true
directoryPerDB: true
syncPeriodSecs: 60
engine: mmapv1
mmapv1:
preallocDataFiles: false
nsSize: 16
quota:
enforced: false
maxFilesPerDB: 8
smallFiles: false
journal:
debugFlags: 0
commitIntervalMs: 100
怎么可能出问题了?
PS:/etc/mongod.conf正在被使用.
PS: /etc/mongod.conf is being used.
mongod 10864 1 0 Nov16 ? 03:10:34 /usr/bin/mongod -f /etc/mongod.conf
Update-1.通过将集合名称更改为新集合来尝试相同的更新.工作了!但还没有解释这个问题. 2.将Java驱动程序更改为3.0.3,但没有帮助.
Update- 1 .Tried the same update by changing collection name to a new collection. THat worked! but doesnt explain the issue yet. 2. Changed java driver to 3.0.3, that didnt help.
更新-2:(12/9):添加集合统计信息,因为这与集合本身和java驱动程序有关.让我知道是否有什么问题.
Update- 2:(12/9) Adding Collection Stats, since it is something to do with the collection itself and the java driver. Let me know if something seems awry pls.
{
"ns" : "2015.events",
"count" : 827054,
"size" : 3814018,
"avgObjSize" : 4722,
"numExtents" : 22,
"extents" : [
{
"len" : 8192,
"loc: " : {
"file" : 0,
"offset" : 20480
}
},
{
"len" : 32768,
"loc: " : {
"file" : 0,
"offset" : 2134016
}
},
{
"len" : 131072,
"loc: " : {
"file" : 0,
"offset" : 2166784
}
},
{
"len" : 524288,
"loc: " : {
"file" : 0,
"offset" : 2297856
}
},
{
"len" : 2097152,
"loc: " : {
"file" : 0,
"offset" : 2822144
}
},
{
"len" : 8388608,
"loc: " : {
"file" : 0,
"offset" : 4919296
}
},
{
"len" : 11325440,
"loc: " : {
"file" : 0,
"offset" : 14356480
}
},
{
"len" : 15290368,
"loc: " : {
"file" : 0,
"offset" : 28827648
}
},
{
"len" : 20643840,
"loc: " : {
"file" : 0,
"offset" : 44118016
}
},
{
"len" : 27869184,
"loc: " : {
"file" : 1,
"offset" : 8192
}
},
{
"len" : 37625856,
"loc: " : {
"file" : 1,
"offset" : 36265984
}
},
{
"len" : 50798592,
"loc: " : {
"file" : 1,
"offset" : 78086144
}
},
{
"len" : 68579328,
"loc: " : {
"file" : 2,
"offset" : 8396800
}
},
{
"len" : 92585984,
"loc: " : {
"file" : 2,
"offset" : 93753344
}
},
{
"len" : 124993536,
"loc: " : {
"file" : 3,
"offset" : 8192
}
},
{
"len" : 168742912,
"loc: " : {
"file" : 3,
"offset" : 125001728
}
},
{
"len" : 227803136,
"loc: " : {
"file" : 4,
"offset" : 8192
}
},
{
"len" : 307535872,
"loc: " : {
"file" : 4,
"offset" : 239136768
}
},
{
"len" : 415174656,
"loc: " : {
"file" : 4,
"offset" : 595939328
}
},
{
"len" : 560488448,
"loc: " : {
"file" : 5,
"offset" : 8192
}
},
{
"len" : 756662272,
"loc: " : {
"file" : 5,
"offset" : 607756288
}
},
{
"len" : 1021497344,
"loc: " : {
"file" : 6,
"offset" : 8192
}
}
],
"storageSize" : 3826952,
"lastExtentSize" : 997556,
"paddingFactor" : 1,
"paddingFactorNote" : "paddingFactor is unused and unmaintained in 3.0. It remains hard coded to 1.0 for compatibility only.",
"userFlags" : 1,
"capped" : false,
"nindexes" : 8,
"indexDetails" : {
},
"totalIndexSize" : 348270,
"indexSizes" : {
"_id_" : 47123,
"remoteRequest.uri_1" : 76969,
"transactionId_1" : 59611,
"startTime_1" : 39027,
"endTime_1" : 35235,
"remoteRequest.queryParams.q_1" : 20328,
"remoteRequest.queryParams.fq_1" : 38285,
"elapsedTimeInNanos_1" : 31689
},
"ok" : 1
}
推荐答案
您的mongod.conf
具有 quota .基于该mongod.conf
文件,您将无法创建8个以上的数据库文件,这将您的最大存储空间限制为大约6.4 GB.您提到可以通过使用新集合来解决此问题,因此我对您的数据目录现在的状态很感兴趣.我不希望您能够绕过此硬限制,但是由于内部数据结构的原因,有可能在短时间内绕过"它.
Your mongod.conf
has a quota enabled for each database. Based on that mongod.conf
file, you will be unable to create more than 8 database files, which limits you to a max of about 6.4 GB of storage. You mention that you are able to get around this issue by using a new collection, so I am interested in what your data directory looks like now. I would not expect you to be able to bypass this hard limit, however due to internal data structures, it may be possible to "bypass" it for a short time.
您可以通过运行 dbStats命令来验证存储了多少实际数据.
use 2015
db.stats(1024*1024)
此输出将告诉您数据库中实际有多少数据,以及分配的存储量.这些数字将不匹配,这是预期的,因为文档中包含用于填充的空白空间.
This output will tell you how much data you actually have in the db, vs the amount of allocated storage. These numbers will not match, this is expected as documents include empty space for padding.
我的下一个问题是,您是否有理由人为地限制了mongod
可以分配的存储空间量?也许上限集合会更适合您的需求?如果您可以扩展使用范围,我也许可以为您提供更好的答案.
My next question would be, is there are reason you are artificially limiting the amount of storage space your mongod
can allocate? Perhaps a capped collection would better suit your needs? If you could expand on your use, I can perhaps give you a better answer.
这篇关于在写入时遇到MongoDB错误-超出配额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!