目前我的日志文件是32兆。我是否错过了在日志文件增长时拆分日志文件的选项?
How can I deploy a Django project that uses MongoDB to AWS? I have a project made using Django and have been using MongoDB and its Compass app and was wondering if you could deploy said project and ...
目前我的日志文件是32兆。我是否错过了在日志文件增长时拆分日志文件的选项?
您可以使用logrotate来完成此工作。
将其放入/etc/logrotate.d/mongod
中(假设您使用Linux并安装了logrotate
):
/var/log/mongo/*.log {
daily
rotate 30
compress
dateext
missingok
notifempty
sharedscripts
copytruncate
postrotate
/bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
endscript
}
如果您认为32兆欧对于一个日志文件来说太大,您可能还需要查看它包含的内容。
如果日志看起来基本上是无害的(“打开连接”,”关闭连接“),那么您可能需要使用--quiet
开关启动mongod
。这将减少一些更详细的日志记录。
使用logrotate是一个不错的选择。同时,它将生成fmchan评论的2个日志文件,您必须遵循Brett的建议,“在您的postrotate脚本中添加一行,以删除所有mongod风格的旋转日志”。
此外,复制截断不是最好的选择。在复制和截断之间总是有一个窗口。一些原木可能会丢失。可以检查logrotate手册页或参阅此复制截断讨论。
只需再提供一个选项。您可以编写一个脚本,将旋转信号发送到mongod并删除旧的日志文件mongoxrate.sh是我写的一个简单的参考脚本。你可以写一个简单地cron作业或脚本,每隔30分钟周期性地调用它。
How can I deploy a Django project that uses MongoDB to AWS? I have a project made using Django and have been using MongoDB and its Compass app and was wondering if you could deploy said project and ...
Whats the best way to access/query a DB Ref: UPDATE: users: name, groupref : {$ref:"groups",$id:"ObjectId ..." } } groups: name, topic, country,...,.. Assumption is that user belongs to only one ...
Example: > db.stuff.save({"foo":"bar"}); > db.stuff.find({"foo":"bar"}).count(); 1 > db.stuff.find({"foo":"BAR"}).count(); 0
What re the best practices to store nested sets (like trees of comments) in MongoDB? I mean, every comment can have a parent comment and children-comments (answers). Storing them like this: { ...
I ve been using the following web development stack for a few years: java/spring/hibernate/mysql/jetty/wicket/jquery For certain requirements, I m considering switching to a NoSQL datastore with an ...
I m building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document ...
I have the following setup: Mac Pro with 2 GB of RAM (yes, not that much) MongoDB 1.1.3 64-bit 8 million entries in a single collection index for one field (integer) wanted Calling .ensureIndex(...) ...
My application creates pieces of data that, in xml, would look like this: <resource url="someurl"> <term> <name>somename</name> <frequency>somenumber</...