The Best approach to clean Oracle Database Filesystems or automate scripts.

Use the tfactl purge command to delete diagnostic collections from the TFA repository that are older than a specific time.

Usually tfactl are in the grid user within the following path:

/u01/app/18.1.0.0/grid/tfa/tls/tfa_home/bin/tfactl

tfactl managelogs
Use the tfactl managelogs  command to manage Automatic Diagnostic Repository log and trace files.

tfactl command:

tfactl [run] managelogs [ -purge [[-older <n><m|h|d>] | [-gi] | [-database <all|d1,d2..>] | [-dryrun] ]] [ -show [usage|variation] [ [-older <n><d>] | [-gi] | [-database <all|d1,d2..>] ] ] [-node <all|local|node1,node2..>]
Options:
-purge Purge logs
-older Timeperiod for log purge
-gi Purge Grid Infrastructure logs(all ADR homes under GIBASE/diag and crsdata(cvu dirs))
-database Purge Database logs (Default all else provide list)
-dryrun Estimate logs which will be cleared by purge command
-show Print usage/variation details
-older Timeperiod for change in log volume
-gi Space utilization under GIBASE
-database Space utilization for Database logs (Default all else provide list)

-older <n><m|h|d> Files from past 'n' [d]ays or 'n' [h]ours or 'n' [m]inutes

e.g:
/u01/app/18.1.0.0/grid/tfa/tls/tfa_home/bin/tfactl managelogs -purge -older 30d -dryrun
/u01/app/18.1.0.0/grid/tfa/tls/tfa_home/bin/tfactl managelogs -purge -older 30d
/u01/app/18.1.0.0/grid/tfa/tls/tfa_home/bin/tfactl managelogs -show usage

/u01/app/18.1.0.0/grid/tfa/tls/tfa_home/bin/tfactl run managelogs -purge -older 30d -dryrun
/u01/app/18.1.0.0/grid/tfa/tls/tfa_home/bin/tfactl run managelogs -purge -older 30d
/u01/app/18.1.0.0/grid/tfa/tls/tfa_home/bin/tfactl run managelogs -show usage
tfactl run managelogs -show usage

The result of this command will be like this below, given the summarized total of both Grid Infrastructure Usage and Database Homes Usage:

[root@xxxx tfa]# tfactl run managelogs -show usage
WARNING - TFA Software is older than 180 days. Please consider upgrading TFA to the latest version.


Output from host : lxdbaseodb02p
------------------------------

.--------------------------------------------------------------------------------.
|                            Grid Infrastructure Usage                           |
+--------------------------------------------------------------------+-----------+
| Location                                                           | Size      |
+--------------------------------------------------------------------+-----------+
| /u01/app/grid/diag/rdbms/_mgmtdb/-MGMTDB/alert                     | 61.49 MB

...

+---------------------------------------------------------------------+------------+
| Total                                                               | 9.67 GB    |
'---------------------------------------------------------------------+------------'

.----------------------------------------------------------------------------------.
|                               Database Homes Usage                               |
+---------------------------------------------------------------------+------------+
| Location                                                            | Size       |
+---------------------------------------------------------------------+------------+
| /u01/app/oracle/diag/rdbms/mstr/MSTR/alert                          | 0 bytes    |
| /u01/app/oracle/diag/rdbms/mstr/MSTR/incident                       | 0 bytes    |
| /u01/app/oracle/diag/rdbms/mstr/MSTR/trace                          | 1.73 MB    |
...

+---------------------------------------------------------------------+------------+
| Total                                                               | 1.98 GB    |
'---------------------------------------------------------------------+------------'
 

Before delete, estimate the space that could be freed with “-dryrun” option

[root@xxxx tfa]# tfactl run managelogs -purge -older 30d -dryrun
WARNING - TFA Software is older than 180 days. Please consider upgrading TFA to the latest version.


Output from host : lxdbaseodb02p
------------------------------
2024-11-06 11:31:54: INFO Estimating files older than 30 days

2024-11-06 11:31:54: INFO Space is calculated in bytes [without round off]

2024-11-06 11:31:54: INFO Estimating purge for diagnostic destination "diag/rdbms/_mgmtdb/-MGMTDB" for files ~ 129 files deleted , 51.25 MB freed ]
2024-11-06 11:31:54: INFO Estimating purge for diagnostic destination "diag/asm/user_root/host_1807229628_110" for files ~ 0 files deleted , 0 bytes freed ]
2024-11-06 11:31:56: INFO Estimating purge for diagnostic destination "diag/asm/+asm/+ASM2" for files ~ 62595 files deleted , 91.07 MB freed ]
2024-11-06 11:31:56: INFO Estimating purge for diagnostic destination "diag/asm/user_grid/host_1807229628_110" for files ~ 0 files deleted , 0 bytes freed ]
2024-11-06 11:31:56: INFO Estimating purge for diagnostic destination "diag/crs/xxx/crs" for files ~ 105 files deleted , 1.37 GB freed ]
...
...
... 

tfactl run managelogs -purge -older: Purges older log files across the Oracle environment using the managelogs utility.

  • Purpose: This command invokes the managelogs utility via the tfactl interface to purge older log files across various components of the Oracle stack.
  • Scope: It targets a wide range of log files, including database alert logs, listener logs, ASM logs, and other diagnostic logs scattered throughout the Oracle environment.
  • Functionality: The managelogs utility is designed to manage and clean up log files based on age or size criteria, helping to free up disk space and maintain system performance.
tfactl run managelogs -purge -older 30d

The result

[root@xxxx tfa]# tfactl run managelogs -purge -older 30d
WARNING - TFA Software is older than 180 days. Please consider upgrading TFA to the latest version.


Output from host : lxdbaseodb02p
------------------------------
2024-11-06 11:49:22: INFO Purging files older than 30 days

2024-11-06 11:49:22: INFO Space is calculated in bytes [without round off]

2024-11-06 11:49:22: INFO Cleaning Grid Infrastructure destinations

2024-11-06 11:54:56: INFO Purging diagnostic destination "diag/rdbms/_mgmtdb/-MGMTDB" for files - 125 files deleted , 50.16 MB freed
2024-11-06 11:54:56: INFO Purging diagnostic destination "diag/asm/user_root/host_1807229628_110" for files - 0 files deleted , 0 bytes freed
...
...

tfactl purge:

tfactl -purge -older:

  • Purpose: This command uses the built-in -purge option of the tfactl utility to clean up older diagnostic collections and files specifically within the TFA repository.
  • Scope: It is limited to purging data collected by TFA, such as diagnostic data, incidents, and collections stored in the TFA repository.
  • Functionality: The command helps manage the size of the TFA repository by removing older diagnostic data that is no longer needed, ensuring that the repository doesn’t consume excessive disk space.

tfactl purge -older number [h | d]

tfactl purge -older 30d

tfactl diagnostics commands

Run the diagnostic collection commands to collect diagnostic data.

tfactl collection
Use the tfactl collection  command to manage Oracle Trace File Analyzer collections.
tfactl dbglevel
Use the tfactl dbglevel command to set Oracle Grid Infrastructure trace levels.
tfactl diagcollect
Use the tfactl diagcollect command to perform on-demand diagnostic collection.
tfactl diagcollect -srdc
Use the tfactl diagcollect -srdc command to run a Service Request Data Collection (SRDC).
tfactl directory
Use the tfactl directory command to add a directory to, or remove a directory from the list of directories to analyze their trace or log files.
tfactl ips
Use the tfactl ips  command to collect Automatic Diagnostic Repository diagnostic data.
tfactl managelogs
Use the tfactl managelogs  command to manage Automatic Diagnostic Repository log and trace files.
tfactl purge
Use the tfactl purge command to delete collections and log files from AHF components from the local node.

For more information about cleaning and purging logs and traces, please check the following Oracle Doc ID

purgeLogs: Archive & Cleanup traces, logs in one command (Doc ID 2081655.1)

Podcast also available on PocketCasts, SoundCloud, Spotify, Google Podcasts, Apple Podcasts, and RSS.

Leave a comment

The Blog

About the Blog