cureetly we are not having log rotater in my mongod.conf file.my version is mongodb3.4.3 how can i give log rotater in my mongod.conf file please check my conf file and give me suggestion where to add the log rotator in my conf fileand what to add
1 Answer
If you are using *nix system, you have few choices. You can use logrotate service and send SIGUSR1 signal to mongod/mongos process. Or you can change your config systemLog.logRotate: rename
and again send SIGUSR1.
To rotate log you can give command db.adminCommand( { logRotate : 1 } )
too.
How you do it on the windows side, that I don't know.
-
we are using centos7 and we have 4 shard cluster of each in each replicatset consits of (primary+secondary+arbiter ) and config server(primary+2secondaries) and mongos is in windows instance so i need to execute in all instances or can i run it in mongos– ashkDec 8, 2017 at 11:11
-
Yes.. All Linux mongod instance logs you can handle with my answer. Those windows mongos must use some other method, but I guess that google can answer to that question. I guess that only working solution is that adminCommand with rename.– JJussiDec 8, 2017 at 13:32
-
In every mongod instance i should run the db.adminCommand( { logRotate : 1 } ) is it correct also in arblter also– ashkDec 8, 2017 at 17:42
-
Yes, you can rotate arbiter log file with
db.adminCommand( { logRotate : 1 } )
too– JJussiDec 9, 2017 at 8:26 -
/var/log/mongodb/*.log { daily rotate 5 compress dateext missingok notifempty sharedscripts copytruncate postrotate /bin/kill -SIGUSR1
cat /var/lib/mongodb/mongod.lock 2> /dev/null
2> /dev/null || true endscript } can i add this script in all mongod instances– ashkDec 10, 2017 at 15:51