Discussion:
[mongodb-user] Log rotate in mongo how it works
Virendra Agarwal
2016-07-04 05:26:12 UTC
Permalink
Hi All I was trying to run Mongo DB with log rotate to rotate mongo logs on
daily basis.
I tried with this

nohup /opt/mongodb/bin/mongod --port=27017 --config /opt/mongodb.conf
--dbpath=/data/mongoData/ --replSet businessSet --maxConns=20000
--logpath=/data/log/mongodb.log* --logRotate reopen --logappend*
--storageEngine mmapv1 &

I am not sure how logRoatte will rotate the log files as i could not find
any parameter which takes size input.
Could you please explain this.

Thanks
Virendra Agarwal
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/430c0089-ddaa-4a75-b4a4-1ba56ae5af71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Roswitha
2016-07-16 00:20:52 UTC
Permalink
Hi Virendra,

I am not sure how logRoatte will rotate the log files


The logRotate
<https://docs.mongodb.com/manual/reference/configuration-options/#systemLog.logRotate>
configuration option determines the behavior when the *logRotate administrative
command* is invoked: either renaming, or closing and reopening the log
file. The *logRotate* command does not run automatically; you need to
invoke this as an administrative user or set up scheduled log rotation
using your O/S facilities (eg. `cron` on Linux).

i could not find any parameter which takes size input.


If you want to limit the size of log files, you need to use an external
utility to monitor and trigger the log rotation. The common Linux approach
for this is to write logs to the syslog facility (see: Syslog Log Rotation
<https://docs.mongodb.com/manual/tutorial/rotate-log-files/#syslog-log-rotation>)
and configure archiving rules using the Linux *logrotate* service (eg: Setting
Up Logrotate on RedHat Linux
<https://linuxconfig.org/setting-up-logrotate-on-redhat-linux>).

For more information, please refer to the Rotate Log Files tutorial
<https://docs.mongodb.com/manual/tutorial/rotate-log-files/> and the
*logRotate* configuration option
<https://docs.mongodb.com/manual/reference/configuration-options/#systemLog.logRotate>
.


nohup /opt/mongodb/bin/mongod --port=27017 --config /opt/mongodb.conf
--dbpath=/data/mongoData/ --replSet businessSet --maxConns=20000
--logpath=/data/log/mongodb.log* --logRotate reopen --logappend*
--storageEngine mmapv1 &
I noticed the command line you provided uses a config file to start
`mongod` in addition to specifying options. This may lead to an overlap in
the settings for the different options as well as potentially different
behavior if you don't use the same set of command line parameters when
starting `mongod`. I would recommend setting all values in the
configuration file
<https://docs.mongodb.com/manual/reference/configuration-options/> for
clarity.

Please let us know if you have any further questions about this.

Kindly,
Roswitha
Hi All I was trying to run Mongo DB with log rotate to rotate mongo logs
on daily basis.
I tried with this
nohup /opt/mongodb/bin/mongod --port=27017 --config /opt/mongodb.conf
--dbpath=/data/mongoData/ --replSet businessSet --maxConns=20000
--logpath=/data/log/mongodb.log* --logRotate reopen --logappend*
--storageEngine mmapv1 &
I am not sure how logRoatte will rotate the log files as i could not find
any parameter which takes size input.
Could you please explain this.
Thanks
Virendra Agarwal
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/9153ba13-a59e-4908-a548-b988f6c69e97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...