Cleanup Operations

Oracle homes and Container Databases consume valuable storage space, they can be cleaned up to release space when they are no longer in use. This operation removes unused, empty no longer needed Oracle Homes or Container Databases (CDB) to help you better administrate space and resources.

Note:

If any target is associated with the given home, Cleanup will be not done for the given home. You have to patch all the targets within an Oracle Home before Cleanup can be done. For RAC Database Oracle Homes, you will need to pass all nodes of Oracle Home name by comma separated value and Cleanup cannot be done from only one of the nodes.

Cleaning Up Oracle Homes

Oracle Homes can have several older versions of the same home, and these can accumulate space. You can modify how many of these previous Oracle Home versions are retained at any given point using the following EMCTL property: emctl set property -name oracle.sysman.emInternalSDK.db.gis.lineageLength -sysman_pwd $em_sysman_pwd –value <value> where <value> is the number of Oracle Homes that will be retained. The default value for how many versions are stored is three.

For example, there are four versions of an Oracle Home with the target running from the fourth version; then only the earliest of them can be deleted if the value is set to three. Similarly if the value is set to one, only the current Oracle home from which the target is running will remain and the other three homes will be deleted.

There are two ways to clean up Oracle Homes:
  • You can cleanup old Oracle Homes of recently Fleet Maintenance patched databases by specifying a database or cluster target list. The Cleanup operation will find older eligible Oracle Homers for the patched database or cluster targets and perform a cleanup.
  • If there are any orphan homes within the lineage path, these can be cleaned up by passing a list of Oracle Homes directly to the db_software_maintenance verb.

To perform an Oracle Home cleanup, the following command string will need to be entered in EM CLI:

emcli db_software_maintenance -performOperation 
-name="cleanup"
-purpose="CLEANUP_SOFTWARE" 
-target_list=<List of home targets>
-target_type=oracle_home 
-normal_credential=NORMALCRED:SYSMAN
-privilege_credential=ROOTCRED:SYSMAN
-workDir=<working directory>
Description of Input Variables
  • name: This is the unique name of the operation.
  • purpose: CLEANUP_SOFTWARE, use this purpose only for Oracle Homes.
  • target_list: This is a comma separated list of databases, clusters or Oracle Home targets which need to be cleaned up.
  • target_type: The type of target on which this operation is being performed.
  • normal_credential: This must be entered in the format <Named Credential: Credential Owner> where:
    • <Named Credential>: Named credential for the host where Oracle home was deployed.
    • <Credential Owner>: The Enterprise Manager user who owns this Named Credential.
  • privilege_credential: This credential must have root privilege and must be entered in the format <Named Credential: Credential Owner> where:
    • <Named Credential>: Named credential for the host where Oracle home was deployed.
    • <Credential Owner>: The Enterprise Manager user who owns this Named Credential.
    These credentials are used to run scripts as root.
  • force: The default value for this optional flag is false. When set to true this flag forces an Oracle Home cleanup to occur even if there are potential conflicts, like a break within the lineage, with the databases contained within.

    In its default value of false, should conflicts arise when performing an Oracle Home cleanup the process stops and you see a warning message in the EM CLI console.

Cleaning Oracle Homes on Windows Single Instance Database Example:

emcli db_software_maintenance 
-performOperation -name="Clean"
-purpose=CLEANUP_SOFTWARE -target_list=ORCLTDE.abc.example.com
-target_type=oracle_database
-normal_credential="LOCALADMIN:SYSMAN"
-workDir="C:\Users\LocalAdmin\work"

Obtain a Report of Oracle Homes Available for Cleanup

Additionaly, you can perform a reportonly operation where the eligible homes for cleanup will be displayed but no further actions will be taken. Credentials are not needed for reportonly operations.

There are two ways to get reports for Oracle Home cleanup:
  • List the Oracle Homes for given target_list of given target_type:
    emcli db_software_maintenance 
    -performOperation 
    -name="cleanup"
    -purpose="CLEANUP_SOFTWARE" 
    -target_list=<List of home targets>
    -target_type=oracle_home 
    -reportonly=true
  • List the Oracle Homes Using a Filter:
    emcli db_software_maintenance 
    -performOperation 
    -name="cleanup"
    -purpose="CLEANUP_SOFTWARE" 
    -filter="target_type:host#target_list:<List of host targets>"
    -reportonly=true
Description of Input Variables
  • filter: target_type (mandatory) and target_list (optional) can be specified using the following format: - target_type:cluster#target_list: <List of cluster targets>
  • reportOnly: The default value is false. If set to true, it prints the eligible Oracle Homes or CDBs for cleanup but these are not deleted.

    Note:

    This flag will show No CDB or Oracle Home is eligible for cleanup if you have Pluggable Databases (PDB) associated with an old CDB. Make sure the PDB is pointing to the new Oracle Home or CDB.

Cleaning Up Container Databases

When Fleet Maintenance patching operations occur, new Oracle Homes, and new Container Databases are deployed. As the individual PDB instances are patched, they are relocated to the newly deployed CDBs. Once all the PDBs in a CDB are patched, the old CDBs need to be deleted. The CLEANUP operation, part of the db_software_maintenance verb, automates the removal of old CDBs upon completion of a patching cycle.

Note:

Cleaning up container databases will clean all eligible homes corresponding to a CDB.
To perform an Oracle Container Database cleanup, the following command string will need to be entered in EM CLI:
emcli db_software_maintenance 
-performOperation 
-purpose="CLEANUP"
-target_list =<target CDB names> 
-target_type=oracle_pdb  
-name="Cleanup CDBs"
-normal_credential=NORMALCRED:SYSMAN  
-privilege_credential=ROOTCRED:SYSMAN 
-workDir=<working directory>
You can cleanup lost lineage Oracle Container Databases with the following command string:
emcli db_software_maintenance 
-performOperation 
-purpose="CLEANUP"
-target_list =<target CDB names>  
-target_type=<oracle_database/rac_database> 
-name="Cleanup orphan CDBs" 
-normal_credential=NORMALCRED:SYSMAN
-privilege_credential=ROOTCRED:SYSMAN  
-workDir=<working directory>
Description of Input Variables for Cleaning Container Databases
  • name: This is the unique name of the operation.
  • purpose: CLEANUP, use this purpose only for CDB cleanup.
  • target_type: The type of target on which this operation is being performed.
  • target_list: This is a comma separated list of targets which need to be cleaned up.
  • normal_credential: This must be entered in the format <Named Credential: Credential Owner> where:
    • <Named Credential>: Named credential for the Oracle Home where the CDB is deployed.
    • <Credential Owner>: The Enterprise Manager user who owns this Named Credential.
  • privilege_credential: This must be entered in the format <Named Credential: Credential Owner> where:
    • <Named Credential>: Named credential for the host where the CDB was deployed.
    • <Credential Owner>: The Enterprise Manager user who owns this Named Credential.
    These credentials are used to run scripts as root.
  • force: Optional flag, its default value is false. Cleanup of Oracle home affects the databases running from that home. By default the cleanup is skipped if processes (databases, listeners, cluster) are found running from this home. You can provide the force=true flag to skip the verification and remove all processes running from this home. This removes all processes running from the home which were not discovered in Enterprise Manager as well.

    Note:

    This is a severely destructive operation, the procedure will start after a 5 minute delay, providing you with the opportunity to abort the procedure. .
  • reportOnly: The default value is false. When set to true, it prints the eligible CDBs for deletion but the Datbasese are not deleted.

    The flag will show No CDB or Oracle Home is eligible for cleanup if you have PDBs associated with the old CDB. Make sure the PDBs are pointing to the new Oracle Home or CDB.

    Note:

    When using reportOnly credentials are not required.

Note:

For further information on CLEANUP_SOFTWARE and database software maintenance tasks and using db_software_maintenance see the following: