Purpose
Purging may not have been set up at installation time. If the OMK database has grown large it's a good idea to select an event retention period and manually purge the OMK database.
Related Documents
Purging of old data in opEvents
Determine Retention Interval
Select a retention period that provides infrastructure engineers with necessary event information and also complies with your organizations security and compliance policies.
Run the opEvents Purge Command
First run the command in simulate mode to ensure the math is correct
[root@opmantek ~]# /usr/local/omk/bin/opevents-cli.exe act=purge events_purge_older_than=52560 debug=1 simulate=true [Fri Dec 15 05:54:31 2017] [debug] cli[31377] Purging unwanted database indices [Fri Dec 15 05:54:31 2017] [debug] cli[31377] Db purge of rawlogs: 0 entries (of 7161464) in rawLogs are older than 1y270d50m Db purge of rawlogs: 0 entries (of 7161464) in rawLogs are older than 1y270d50m [Fri Dec 15 05:54:31 2017] [debug] cli[31377] Simulated purging rawlogs: would remove 0 (of 7161464) entries from rawLogs Simulated purging rawlogs: would remove 0 (of 7161464) entries from rawLogs [Fri Dec 15 05:54:31 2017] [debug] cli[31377] Purging disabled for archivelogs Purging disabled for archivelogs [Fri Dec 15 05:54:33 2017] [debug] cli[31377] Db purge of events: 4692044 entries (of 5060913) in events are older than 36d12h Db purge of events: 4692044 entries (of 5060913) in events are older than 36d12h [Fri Dec 15 05:54:33 2017] [debug] cli[31377] Simulated purging events: would remove 4692044 (of 5060913) entries from events Simulated purging events: would remove 4692044 (of 5060913) entries from events [Fri Dec 15 05:54:37 2017] [debug] cli[31377] Db purge of events: 12831334 entries (of 13803156) in actionlog are older than 36d12h Db purge of events: 12831334 entries (of 13803156) in actionlog are older than 36d12h [Fri Dec 15 05:54:37 2017] [debug] cli[31377] Simulated purging events: would remove 12831334 (of 13803156) entries from actionlog Simulated purging events: would remove 12831334 (of 13803156) entries from actionlog [Fri Dec 15 05:54:37 2017] [debug] cli[31377] Purging disabled for reports Purging disabled for reports
Once satisfied that the desired action will occur; remove the debug option and run the command again.
Continue this 90 day cycle until the desired retention period is attained.
Recover Disk Space - Compact MongoDB
The old records have been removed, but the data base is still taking the same amount of storage. In order to recover the disk space we will need to issue that MongoDB 'compact' command that will rewrite and defrag the database. The safe approach is to shut down all daemons that are writing the the database prior to issuing the 'compact' command.
Shutdown OMK Services
service opeventsd stop service opflow stop service opconfigd stop service nmisd stop service omkd stop
Enter the mongo Shell and Compact opEvents Collections
[root@opmantek ~]# mongo -u opUserRW -p op42flow42 admin MongoDB shell version v3.4.9 connecting to: mongodb://127.0.0.1:27017/admin MongoDB server version: 3.4.9 > db.runCommand({compact: 'events'}) { "ok" : 1 } > db.runCommand({compact: 'rawlogs'}) { "ok" : 1 > db.runCommand({compact: 'actionlog'}) { "ok" : 1 } >
Start OMK Services
service omkd start service nmisd start service opeventsd start service opconfigd start service opflowd start
Set Purging Policy
Now that the database has been cleaned up, set the purging policy in opCommon. That procedure is found here: Purging of old data in opEvents