Monday, February 6, 2017

Mongod logrotate failure

I had an issue with rocketchat and mongod with RedHats SCL version of mongod. Basically mongod failed when it tried to rotate its own logs which then caused rocketchat to fail.

There are a number of sources on line for this notably here:

https://jira.mongodb.org/browse/SERVER-11087

https://serverfault.com/questions/540423/mongodb-proper-way-to-rotate-logs/653095


Here is my (apparently) successful version:

 cat /etc/logrotate.d/rh-mongodb26-mongodb  

 /var/opt/rh/rh-mongodb26/log/mongodb/*.log {  
 weekly  
 rotate 10  
 copytruncate  
 delaycompress  
 compress  
 notifempty  
 missingok  
 create  
 postrotate  
 # Original line  
 # /bin/kill -USR1 `cat /var/opt/rh/rh-mongodb26/run/mongodb/mongod.pid 2>/dev/null` 2> /dev/null|| true  
 # New line  
 /usr/bin/kill -USR1 `cat /var/opt/rh/rh-mongodb26/run/mongodb/mongod.pid 2>/dev/null` 2> /dev/null|| true  
 rm /var/opt/rh/rh-mongodb26/log/mongodb/mongod.log.????-??-??T??-??-??  
 endscript  
 }  


Test with:

 logrotate -v -f /etc/logrotate.d/rh-mongodb26-mongodb  

No comments:

Post a Comment