Configuring optimal log rotation is important to ensure the performance and stability of NetBrain system. To avoid the disk space of your Linux server being insufficient for large amounts of log files, the following three parameters can be configured/updated:
- rotation count limit (the maximum number of log files)
- size limit for each log file
- frequency for log rotation
For example, at most 50 log files can be generated and the maximum size for each log file is 10MB. That means, at least 500MB free space (550MB is better for tolerance in case one log file might exceed 10MB) must be reserved to store MongoDB logs. If the sum size of log files exceeds 500MB, log files will be rotated and old log files will be gradually overwritten by new ones.
 
NetBrain Tip: The detection for log rotation is performed at a predefined frequency, for example, 10 minutes. Therefore, to avoid too many logs generated before the log rotation can start, it is highly recommended to set a smaller value for the log rotation frequency, or reserve much more free disk space for logs.
 
Solution
Important: Following any logging configuration updates the affected service(s) will need to be restarted.
 
MongoDB
1. Open the mongod.conf file under the /etc/logrotate.d directory, and modify the value of the "size" and "rotate" parameters.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | /opt/mongodb/log/mongod.log{
     nodateext
     size 10M     //configurable
     nocompress
     rotate 50    //configurable
     create 644 netbrain netbrain
     sharedscripts
     notifempty
     missingok
     postrotate
       /bin/kill -SIGUSR1 `cat /opt/mongodb/data/mongod.lock2> /dev/null` 2> /dev/null|| true
     endscript
 }
 | 
 
2. Run the crontab -e command to modify the log rotation frequency.
*/10****/usr/sbin/logrotate -v /etc/logrotate.d/mongod.conf
 
ElasticSearch
1. Modify the value of the parameters in the log4j2.properties file under the /etc/elasticsearch/ directory.
 

 
2. Decrease the values of the following parameters in the jvm.options file to limit the size of each gc.log file.
- NumberOfGCLogFiles=32
- GCLogFileSize=64M
 gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
 
Redis
1. Open the redis.conf file under the /etc/logrotate.d directory, and modify the value of the "weekly" and "rotate" parameters. The default values indicate that log files will be rotated by week (daily or hourly is supported) and at most 52 files will be kept. That means, 1 year of log will be covered.
For IEv8.0:
| 1 2 3 4 5 6 7 8 9 | /var/log/redis/redis*.log{
         weekly    //configurable
         missingok
         rotate 52
         compress
         delaycompress
         notifempty
         create 0660 root redis
 }
 | 
 
For IEv8.01:
| 1 2 3 4 5 6 7 8 9 | /var/log/netbrain/redis/redis*.log{
         weekly    //configurable
         missingok
         rotate 52
         compress
         delaycompress
         notifempty
         create 0644 redis redis
 }
 | 
 
2. Run the crontab -e command to modify the log rotation frequency.
*/10****/usr/sbin/logrotate -v /etc/logrotate.d/redis.conf
 
 
 
RabbitMQ
Open the rabbitmq.config file under /etc/rabbitmq/ directory, and modify the value of the “size” and “count” parameters. The default values mean log files will be rotated by size of 5242880 bytes and at most 10 files will be kept.
 
| 1 2 3 4 5 | {log, [
      {file, [
              {size, 5242880}, {date, "$D20"}, {count, 10}
              ]}
      ]},
 | 
 
Refer to http://www.rabbitmq.com/logging.html for more details.