When making a MongoDB shard, when the MONGOs routing service is enabled, we specify a location for the log to be stored:
MONGOs--configdb 127.0.0.1:27019--logpath/var/log/mongodb/mongos.log--pidfilepath/var/run/mongodb/mongos.pid-- Logappend--logrotate Reopen--fork
Above we specify the location of the log in the/var/log/mongodb/mongos.log file, when the system data volume is large, after a long run time, the Mongos.log file will become a few g size, which will certainly affect the performance of MONGOs routing.
In this case we can borrow the system logrotate log automatic cutting service, to change the size of the Mongos.log file, into the cd/etc/logrotate.d/ directory, create a file: Touch MONGOs, The editor adds the following content:
/var/log/mongodb/mongos.log{rotate 1 Daily dateext size 200M postrotate/bin/kill-sigusr1 ' Cat/va R/run/mongodb/mongos.pid 2>/dev/null ' 2>/dev/null | | True Endscript}
A simple description of the above configuration:
Size: Specifies that files are automatically cut when the Mongos.log file exceeds 200M
Dateext: Specifies how the backup file is named when the file is cut
Rotate 5:5 archive logs will be stored at a time. For a sixth archive, the oldest archive will be deleted.
Daily: Log file will be polled by day
Postrotate/endscript: After the execution of other commands, execute the command inside.
This article is from the "connected with the Internet" blog, please be sure to keep this source http://suiwnet.blog.51cto.com/2492370/1630994
MongoDB System Log Start cutting implementation method