Oracle by Example brandingPatching a Single Instance Database Using Oracle Enterprise Manager Fleet Maintenance

section 0Before You Begin

This tutorial guides you through the required steps for patching a single instance Oracle database using Oracle Enterprise Manager Fleet Maintenance. The time to complete this task is approximately 1 hour.

Background

Database Fleet Maintenance, part of the Database Lifecycle Management Pack, allows administrators to maintain groups or pools of Oracle Homes and associated databases by applying database updates and patches.

For more information on Fleet Maintenance see Database Fleet Maintenance in Oracle Enterprise Manager Cloud Control Database Lifecycle Management Administrator's Guide.

What Do You Need?

  • Enterprise Manager version 13.2 and above. The latest Release Update of EM 13.4 is recommended. For the latest Enterprise Manager Release Updates, see Installation and Upgrade.
  • An Oracle database discovered in Enterprise Manager. This tutorial uses an Oracle database 18c named hr.subnet.vcn.oraclevcn.com, version 18.3.0.0.0, running on a Linux system.
  • A reference Oracle database home, which is a database Oracle Home already patched to the desired patch level. This reference home will be used to create the Gold Image. This tutorial is using an existing Oracle Home, patched to the level version 18.10.0.0.0 and discovered in EM. For more information on how to discover an oracle home see this Discovery section. For concepts and supported image creation tasks, see also Creating a Gold Image and Fleet Maintenance Emergency Patching.
  • Access to the target database and its host. In this example, the EM administrator has root access to the host the database resides on and privileged credentials set up for the database. For more information on how to set up your access see Checking Host Readiness Before Provisioning or Patching.
  • Access to the Enterprise Manager command line interface utility, emcli. For more information on how to set up EM CLI see Getting Started with EM CLI.

section 1Analyze Your Environment

Before you start a patching task, run an analysis of your environment and check the access to the host you will be patching.

  1. First, check your access to the database host. Log into to the Enterprise Manager console as an Administrator and navigate to Setup > Security > Named Credentials. Select the credential for the database host and click Edit. Click on Test and Save, to test your access.
  2. Run the Configuration Pollution Detection to analyze your database estate. Click Targets > Databases. Then, under Administration, click Software Standardization Advisor. The resulting graphics depict the current configuration and the recommended configuration. To generate reports, click Generate Report. The Recommended Configuration spreadsheet shows you the recommended database versions to standardize on. In this case, the recommended patch level is 18.10.0.0.0.
  3. Review the status of your database targets. Ensure that the target database to be patched shows as UP in the status field, represented by a green arrow.

section 2Create the Gold Image

  1. Log in to the host where you have set up EM CLI and create an input file with the details of your reference Oracle Home. In this case, the input file is called db18c.inp, saved in the /home/oracle/patch_files directory. This file includes the exact name of the reference Oracle Home as it is discovered in EM and it looks like this:
    IMAGE_NAME=DB18 
    IMAGE_DESCRIPTION=Gold Image 18c 
    REF_TARGET_NAME=refdb18c_home1_2020_05_13_04_10_9.sample.com
    IMAGE_SWLIB_LOC=Fleet Maintenance/
    STORAGE_TYPE_FOR_SWLIB=OmsShared
    STORAGE_NAME_FOR_SWLIB=default_loc
    REF_HOST_CREDENTIALS=ORACLE:MYADMIN
    WORKING_DIRECTORY=/tmp
    VERSION_NAME=18.10
  2. A standard software configuration is referred to as a Gold Image. Create a new Gold Image based on your reference Oracle Home:
    $  emcli db_software_maintenance -createSoftwareImage -input_file="data:/home/oracle/patch_files/db18c.inp"
    You can track the status of operation using the following:
    EMCLI: emcli get_instance_status -exec=AAFAB54748EF28A0E0533400000A43D6
    Browser: https://EM Host:EM Port/em/faces/core-jobs-procedureExecutionTracking?executionGUID=AAFAB54748EF28A0E0533400000A43D6
    
    Verb createSoftwareImage completed successfully
  3. Check the list of all Gold Images available for deployment. Your newly created image should be on this list:
    $ emcli db_software_maintenance -getImages
    
    =================================================================================================================================
    IMAGE ID                         IMAGE NAME         DESCRIPTION        VERSION        CREATION DATE            OWNER
    =================================================================================================================================
    
    AAFAB54748EF28A0E0533400000A43D6    DB18            Gold Image 18c    18.0.0.0.0    2020-07-21 20:45:50.0     MYADMIN
                                            
    ---------------------------------------------------------------------------------------------------------------------------------
    Total Rows: 1
    
    Verb getImages completed successfully
  4. View the software version available for a specific image:
    $ emcli db_software_maintenance -getVersions -image_id=AAFAB54748EF28A0E0533400000A43D6
    
    =================================================================================================================================
    POSITION         VERSION ID            VERSION NAME        DATE CREATED          EXTERNAL ID          HASH CODE         STATUS
    =================================================================================================================================
    1           A5F368AF3DE87756E053          18.10           2020-05-18 21:28:43.  oracle:default[...] C2891773972:B5D7872C CURRENT
                          
                                                                                            
  5. Verify that the newly created Gold Image is applicable. Execute the following command to perform a check to identify the patch conflicts:
    $ emcli db_software_maintenance -checkApplicability -image_id=" AAFAB54748EF28A0E0533400000A43D6 " -target_list=hr.subnet.vcn.oraclevcn.com -target_type=oracle_database > /home/oracle/patch_files/applicability.out
    $ cat /home/oracle/patch_files/applicability.out
    
    Checking applicability for target [hr.subnet.vcn.oraclevcn.com]...
    
    Image is applicable
    More Information: Image has 996 additional bugs fixed.
    Following are the bugs list:
    
    =================================================================================================================================
    #        BUG#                      PATCH#                 PATCH UPI                       BUG DESCRIPTION
    =================================================================================================================================
    1       27006120                 30872794                                             INFRASTRUCTURE FOR BACKPORTING
                                                                                                                                     
    [...]
    Total Rows: 996
    
    Following are the patches:
    
    =================================================================================================================================
    PATCH#      PATCH DESCRIPTION
    =================================================================================================================================
    30872794    Database Release Update : 18.10.0.0.200414 (30872794)
    ---------------------------------------------------------------------------------------------------------------------------------
    30112122    Database Release Update : 18.8.0.0.191015 (30112122)
    ---------------------------------------------------------------------------------------------------------------------------------
    30805598    OJVM RELEASE UPDATE: 18.10.0.0.200414 (30805598)
    ---------------------------------------------------------------------------------------------------------------------------------
    Total Rows: 3

    The report typically shows three distinct categories:
    • Applicable: The image and database target contain the same set of bug fixes. This image can be applied to the specified target.
    • Applicable and Image has more bug fixes: The image contains more bug fixes than those applied on the database, the list of extra bugs is displayed. The image can be applied to the specified target.
    • Not Applicable: The database contains more bug fixes than those included in the image, the list of missing bugs is displayed. In this case, you have to create a new version of the image that includes the missing bug fixes. In this scenario, the image is applicable.
  6. Subscribe the database target hr.subnet.vcn.oraclevcn.com to the Gold Image you created:
    $ emcli db_software_maintenance -subscribeTarget -target_name=hr.subnet.vcn.oraclevcn.com -target_type=oracle_database -image_id="AAFAB54748EF28A0E0533400000A43D6"
    Target 'hr.subnet.vcn.oraclevcn.com' subscribed successfully.
    Verb subscribeTarget completed successfully

section 3Patch Your Database

The patching process consists of two phases: the deployment of the software and update of the Oracle Home. The deployment phase occurs outside of a maintenance window, allowing regular database activities to continue. The update operation occurs during a short maintenance window.

  1. Create an input file for deploy1810_hr.inp to specify the details about your patching task. This file simply has the location of the new Oracle Home. In this case, the content of this file is:
    NEW_ORACLE_HOME_LIST=/u01/app/oracle/product/18/db_home2
  2. Deploy the Gold Image in a new Oracle Home, on the host where the database target is running:
    $ emcli db_software_maintenance -performOperation -name="deploy1810" -purpose=DEPLOY_DB_SOFTWARE -target_type=oracle_database -target_list=hr.subnet.vcn.oraclevcn.com -normal_credential=ORACLE:MYADMIN -privilege_credential=ROOT:MYADMIN -input_file="data:/home/oracle/patch_files/deploy1810_hr.inp" -procedure_name_prefix="DEPLOY"
    Processing target "hr.subnet.vcn.oraclevcn.com"...
    Checking image subscription...
    Check image subscription passed.
    Oracle home  provisioned for this target [hr.subnet.vcn.oraclevcn.com] has been removed. Redeploying the Oracle Home again
    Oracle home target list is 8486EAEF4933931CB507E3A286F00E57
    Operation 'deploy1810' created successfully.
    
    Deploy Oracle home software operation for  database hr.subnet.vcn.oraclevcn.com can be monitored using:
    EMCLI: emcli get_instance_status -exec=AAFAB54748EF28A0E0533400000A43D6 -details -xml
    Browser: https://EM Host:EM Port/em/faces/core-jobs-procedureExecutionTracking?executionGUID=AAFAB54748EF28A0E0533400000A43D6
    
    Verb performOperation completed successfully

    To review the execution activity details in Enterprise Manager navigate, Enterprise > Provisioning and Patching > Procedure Activity. Click on your execution under the Run column.

  3. Now, migrate the listener to the newly deployed Oracle Home. Use this command to migrate the listener:
    $ emcli db_software_maintenance -performOperation -name="Migrate Listener" -purpose=migrate_listener -target_type=oracle_database -target_list="hr.subnet.vcn.oraclevcn.com" -normal_credential="ORACLE:MYADMIN" -privilege_credential="ROOT:MYADMIN"
    Processing target "hr.subnet.vcn.oraclevcn.com"...
    Checking if target is already running from the current version of the image...
    Checking image subscription...
    Check image subscription passed.
    Operation 'Migrate Listener' created successfully.
    
    Listener migration for  hr.subnet.vcn.oraclevcn.com can be monitored using:
    EMCLI: emcli get_instance_status -exec=AAFAB54748EF28A0E0533400000A43D6 -details -xml
    Browser: https://EM Host:EM Port/em/faces/core-jobs-procedureExecutionTracking?executionGUID=AAFAB54748EF28A0E0533400000A43D6
    
    Verb performOperation completed successfully

    To review the execution activity details in Enterprise Manager, navigate to Enterprise > Provisioning and Patching > Procedure Activity. Click on Fleet_(migrate_date & time) under the Run column.

  4. Update the database target to switch to the new Oracle Home:
    $ emcli db_software_maintenance -performOperation -name="Update DB" -purpose=UPDATE_DB -target_type=oracle_database -target_list=hr.subnet.vcn.oraclevcn.com -normal_credential=ORACLE:MYADMIN -privilege_credential=ROOT:MYADMIN -database_credential=sales_SYS:SYSMAN
    Processing target "hr.subnet.vcn.oraclevcn.com"...
    Checking if target is already running from the current version of the image...
    Check Passed.
    Checking image subscription...
    Check image subscription passed.
    Operation 'Update DB' created successfully.
    
    Patching operation for database hr.subnet.vcn.oraclevcn.com can be monitored using:
    EMCLI: emcli get_instance_status -exec=AAFAB54748EF28A0E0533400000A43D6 -details -xml
    Browser: https://EM Host:EM Port/em/faces/core-jobs-procedureExecutionTracking?executionGUID=AAFAB54748EF28A0E0533400000A43D6
    
    Verb performOperation completed successfully

    To review the execution activity details in Enterprise Manager go to Enterprise > Provisioning and Patching > Procedure Activity. Click on Fleet_update_(date & time) under the Run column.

  5. If the database needs to be switched back to the original Oracle Home, you may perform a Rollback operation at this time:
    emcli db_software_maintenance -performOperation -name="Rollback Home" -purpose=ROLLBACK_DB -target_type=oracle_database -target_list="hr.subnet.vcn.oraclevcn.com" -normal_credential="ORACLE:MYADMIN" -privilege_credential="ROOT:MYADMIN"
    Checking image subscription...
    Check image subscription passed.
    Operation 'Rollback' created successfully.
    [...]
    Review the execution activity details in Enterprise Manager, Enterprise > Provisioning and Patching > Procedure Activity. If you do perform the Rollback operation, re-run step 4 above (step 4 under Patch Your Database) to re-update your database.

section 4Cleanup the Old Oracle Home

A cleanup operation is recommended to remove old Oracle Home that is no longer used. This will remove old Oracle Home and free up valuable disk space.

  1. First, run a reportOnly cleanup operation to list the possible Oracle Homes to be cleaned:
    $ emcli db_software_maintenance -performOperation -name="Cleanup old oracle homes" -purpose=CLEANUP_SOFTWARE -target_type=oracle_database -normal_credential=ORACLE:MYADMIN -privilege_credential=ROOT:MYADMIN -target_list=hr.subnet.vcn.oraclevcn.com -workDir=/tmp -reportOnly=true
    Processing cleanup database software.
    The following Oracle homes are chosen for removal by policy.
    
    =================================================================================================================================
    NO.          HOST                   ORACLE HOME              TARGET NAME               NO. OF ASSOCIATED TARGETS
    ================================================================================================================================
    1   hr.subnet.vcn.oraclevcn.com   /u01/app/1806/hr    OraDB18Home3_6_db.subnetvcn           0
                                                                                                    
    ---------------------------------------------------------------------------------------------------------------------------------
    Total Rows: 1
    
    Verb performOperation completed successfully
    								
  2. Now cleanup the Oracle Home listed in the report:
    $ emcli db_software_maintenance -performOperation -name="Cleanup old oracle homes" -purpose=CLEANUP_SOFTWARE -target_type=oracle_database -normal_credential=ORACLE:MYADMIN -privilege_credential=ROOT:MYADMIN -target_list=hr.subnet.vcn.oraclevcn.com -workDir=/tmp
    Processing cleanup database software.
    The following Oracle homes are chosen for removal by policy.
    
    =================================================================================================================================
    NO.          HOST                   ORACLE HOME              TARGET NAME               NO. OF ASSOCIATED TARGETS
    ================================================================================================================================
    1   hr.subnet.vcn.oraclevcn.com   /u01/app/1806/hr    OraDB18Home3_6_db.subnetvcn           0
                                                                                                    
    ---------------------------------------------------------------------------------------------------------------------------------
    Total Rows: 1
    Cleaning up targets OraDB18Home3_6_db.subnetvcn.sample.com_3478

    To review the cleanup activity details in Enterprise Manager, go to Enterprise > Provisioning and Patching > Procedure Activity. Click on CLEANUP_SOFTWARE_(date & time) under the Run column.


more informationWant to Learn More?