Tuesday, June 23, 2020

Oracle Enterprise Manager Patch Plans using emcli

Oracle Enterprise Manager Patch Plans help you create a consolidated list of patches you want to apply as a group to one or more targets. Patch plans have states (or status) that map to key steps in the configuration change management process. Any administrator or role that has view privileges can access a patch plan.

Patch plan supports the following types of patches:

  • Patch Sets
  • Patches (One-Off)
    • Interim Patches that contain a single bug fix or a collection of bug fixes provided as required. Also include one-offs for customer-specific security bug fixes.
    • Diagnostic Patches, intended to help diagnose or verify a fix or a collection of bug fixes.
    • Patch Set Updates (PSU), contain a collection of high impact, low risk, and proven fixes for a specific product or component.
    • Critical Patch Updates (CPU), contain a collection of security bug fixes.
The below screenshot from EM has the details of available patch plan and then there are good document for creating patch plan.



I have piloted few projects for Oracle Customers to patch database and weblogic using EM GUI , it works great. But what if they have to be automated ?

Here I am giving some snippet of emcli commands which are used to create patch plan and analyze it.
This post does not cover full automation but will help you to get started. I hope this helps 😐

Download emcli utility : https://em.galaxy.com/em/public_lib_download/emcli/kit/emclikit.jar

Documentation : https://docs.oracle.com/cd/E73210_01/EMCLI/toc.htm

Downloading and Deploying EM CLI

onetime setup taOracle
./emcli setup -url=https://em.galaxy.com -username=empatchadmin -autologin



[mars@mars-linux Oracle_PatchPlan_002]$ export PATH=$PATH:/home/mars/emproject/emctl_standard/

[mars@mars-linux ~]$ emcli login -username=empatchadmin
Enter password :

Login successful
[mars@mars-linux ~]$

[mars@mars-linux ~]$ emcli get_connection_mode
Connection Mode : online.
[mars@mars-linux ~]$



[mars@mars-linux Oracle_PatchPlan_002]$ cat Oracle_PatchPlan_002.plan
name=Oracle_PatchPlan_002
description=Oracle_PatchPlan_002
deployment_date=
planPrivilegeList=empatchadmin
patch.0.patch_id=27734982
patch.0.release_id=80112040
patch.0.platform_id=226
patch.0.language_id=0
patch.0.target_name=PROD_ap01marscloud
patch.0.target_type=oracle_database

deploymentOptions.AdvancedOPatchOptions=null
deploymentOptions.StageLocation=%emd_emstagedir%
deploymentOptions.StagePatches=true
deploymentOptions.isStageLocationShared=false
deploymentOptions.notify.enabled=false
deploymentOptions.performAruAnalysis=true
deploymentOptions.DISPATCHER_LOC=%emd_emstagedir%
deploymentOptions.cloneAndPatch.selected=true
deploymentOptions.cloneAndPatch.element.0.host=ap01marscloud.galaxy.com
deploymentOptions.cloneAndPatch.element.0.source.oh=/PROD/oracle/product/11204
deploymentOptions.cloneAndPatch.element.0.destination.oh=/PROD/oracle/product/11204_1544778399754
deploymentOptions.cloneAndPatch.element.0.destination.name=
deploymentOptions.cloneAndPatch.element.0.destination.base=/PROD/oracle/product
deploymentOptions.cloneAndPatch.element.0.destination.migrateOnly=false
deploymentOptions.deploymentProcedure=CLONE_PATCH_SIDB:oracle:true
deploymentOptions.isDispatcherEnabled=true
deploymentOptions.isDispatcherLocShared=false
[mars@mars-linux Oracle_PatchPlan_002]$


[mars@mars-linux Oracle_PatchPlan_002]$ emcli create_patch_plan -name=Oracle_PatchPlan_002 -input_file=data:Oracle_PatchPlan_002.plan
The "Oracle_PatchPlan_002" patch plan is created successfully.
[mars@mars-linux Oracle_PatchPlan_002]$


[mars@mars-linux Oracle_PatchPlan_002]$ emcli list_patch_plans -name="Oracle_PatchPlan_002"
Name Status Execution ID Execution Status URL Type Planned Deployment Date Created By Deployable Plan Privilege 
Oracle_PatchPlan_002 new NULL NULL PATCH NULL  true FULL  
[mars@mars-linux Oracle_PatchPlan_002]$



[mars@mars-linux Oracle_PatchPlan_002]$ emcli get_patch_plan_data -name="Oracle_PatchPlan_002"
name=Oracle_PatchPlan_002
description=
deployment_date=
planPrivilegeList=empatchadmin:ADMIN:VIEW

patch.0.patch_id=27734982
patch.0.release_id=80112040
patch.0.platform_id=226
patch.0.language_id=0
patch.0.target_name=PROD_ap01marscloud
patch.0.target_type=oracle_database

deploymentOptions.AdvancedOPatchOptions=null
deploymentOptions.StageLocation=%emd_emstagedir%
deploymentOptions.StagePatches=true
deploymentOptions.isStageLocationShared=false
deploymentOptions.notify.enabled=false
deploymentOptions.performAruAnalysis=true
deploymentOptions.DISPATCHER_LOC=%emd_emstagedir%
deploymentOptions.cloneAndPatch.selected=true
deploymentOptions.cloneAndPatch.element.0.host=ap01marscloud.galaxy.com
deploymentOptions.cloneAndPatch.element.0.source.oh=/PROD/oracle/product/11204
deploymentOptions.cloneAndPatch.element.0.destination.oh=/PROD/oracle/product/11204_1544779113411
deploymentOptions.cloneAndPatch.element.0.destination.name=
deploymentOptions.cloneAndPatch.element.0.destination.base=/PROD/oracle/product
deploymentOptions.cloneAndPatch.element.0.destination.migrateOnly=false
deploymentOptions.deploymentProcedure=CLONE_PATCH_SIDB:oracle:true
deploymentOptions.isDispatcherEnabled=true
deploymentOptions.isDispatcherLocShared=false
[mars@mars-linux Oracle_PatchPlan_002]$



[mars@mars-linux Oracle_PatchPlan_002]$ emcli show_patch_plan -name="Oracle_PatchPlan_002" -info
<planDetails>
<plan_id>CDF7219F4251677526E7A0976AE17F3C</plan_id>
<name>Oracle_PatchPlan_002</name>
<type>PATCH</type>
<description/>
<conflict_check_date/>
<conflict_check_date_ms/>
<is_deployable>1</is_deployable>
<plan_status>NEVER</plan_status>
<review_status>CONFLICT_FREE</review_status>
<created_date>Thu Dec 13 21:18:34 CST 2018</created_date>
<created_date_ms>1544757514000</created_date_ms>
<created_by>empatchadmin</created_by>
<last_updated_date>Thu Dec 13 21:18:34 CST 2018</last_updated_date>
<last_updated_date_ms>1544757514000</last_updated_date_ms>
<last_updated_by>empatchadmin</last_updated_by>
<grant_priv>yes</grant_priv>
<user_plan_privilege>FULL</user_plan_privilege>
<see_all_targets>N</see_all_targets>
<homogeneousGroupLabel>Database Instance 11.2.0.4.180417 (Linux x86-64) </homogeneousGroupLabel>
<executeGuid/>
<executeUrl/>
</planDetails>
[mars@mars-linux Oracle_PatchPlan_002]$



[mars@mars-linux Oracle_PatchPlan_002]$ emcli submit_patch_plan -name="Oracle_PatchPlan_002" -action=analyze
The "analyze" action was successfully submitted on the "Oracle_PatchPlan_002" patch plan at 12/14/18 3:21 AM. Run the following command to check the latest status of the "analyze" action.

emcli show_patch_plan -name="Oracle_PatchPlan_002" -info
[mars@mars-linux Oracle_PatchPlan_002]$



[mars@mars-linux Oracle_PatchPlan_002]$ emcli show_patch_plan -name="Oracle_PatchPlan_002" -info
<planDetails>
<plan_id>CDF7219F4251677526E7A0976AE17F3C</plan_id>
<name>Oracle_PatchPlan_002</name>
<type>PATCH</type>
<description/>
<conflict_check_date>Thu Dec 13 21:21:37 CST 2018</conflict_check_date>
<conflict_check_date_ms>1544757697000</conflict_check_date_ms>
<is_deployable>1</is_deployable>
<plan_status>CONFLICTS</plan_status>
<review_status>CONFLICT_FREE</review_status>
<created_date>Thu Dec 13 21:18:34 CST 2018</created_date>
<created_date_ms>1544757514000</created_date_ms>
<created_by>empatchadmin</created_by>
<last_updated_date>Thu Dec 13 21:18:34 CST 2018</last_updated_date>
<last_updated_date_ms>1544757514000</last_updated_date_ms>
<last_updated_by>empatchadmin</last_updated_by>
<grant_priv>yes</grant_priv>
<user_plan_privilege>FULL</user_plan_privilege>
<see_all_targets>N</see_all_targets>
<homogeneousGroupLabel>Database Instance 11.2.0.4.180417 (Linux x86-64) </homogeneousGroupLabel>
<executeGuid/>
<executeUrl/>
</planDetails>
[mars@mars-linux Oracle_PatchPlan_002]$

[mars@mars-linux Oracle_PatchPlan_002]$ emcli show_patch_plan -name="Oracle_PatchPlan_002" -analysisResults
<analysisResults>
<validation>
<homeGroup host_name="ap01marscloud.galaxy.com" oracle_home="/PROD/oracle/product/11204" org_id="0">
<conflictSetList/>
<backportRequestList/>
<messageList>
<message message_id="100-01" resolution_text="Set the normal Oracle Home credentials in the &quot;Credentials&quot; section of &quot;Deployment Options&quot; page." severity="ERROR" text="Normal Oracle Home credentials are not set.">
<patchList/>
</message>
<message message_id="100-01" resolution_text="Set the privileged Oracle Home credentials in the &quot;Credentials&quot; section of &quot;Deployment Options&quot; page." severity="ERROR" text="Privileged Oracle Home credentials are not set.">
<patchList/>
</message>
</messageList>
</homeGroup>
</validation>
<addedPatchList/>
<ignoredPatchList/>
</analysisResults>
[mars@mars-linux Oracle_PatchPlan_002]$



Create credentials — this has to be automated , did this from the UI





Fix that needs to be tested.

Login into server and create a ssh key ( ssh-keygen -t rsa , accept the defaults )

Login into EM and create a named credentials with type as SSHKEY (this taOracle can also be automated)



Set the preferred credentials by running the following command

emcli to find the target name



[mars@mars-linux ~]$ emcli get_targets -targets="%PROD%:%"
Status Status Target Type Target Name
ID
-9 N/A oracle_home PRODhome_1_ap01marscloud
[mars@mars-linux ~]$

mars@mars-linux ~]$ emcli set_preferred_credential -set_name="OHCreds" -target_name="PRODhome_1_ap01marscloud" -target_type="oracle_home" -credential_name="SSHKEY_ORPROD_ap01marscloud"

Successfully set preferred credentials for target PRODhome_1_ap01marscloud:oracle_home.
[mars@mars-linux ~]$





[mars@mars-linux Oracle_PatchPlan_002]$ emcli submit_patch_plan -name="Oracle_PatchPlan_002" -action=analyze
The "analyze" action was successfully submitted on the "Oracle_PatchPlan_002" patch plan at 12/14/18 3:21 AM. Run the following command to check the latest status of the "analyze" action.

emcli show_patch_plan -name="Oracle_PatchPlan_002" -info
[mars@mars-linux Oracle_PatchPlan_002]$





[mars@mars-linux Oracle_PatchPlan_002]$ emcli show_patch_plan -name="Oracle_PatchPlan_002" -analysisResults
<analysisResults>
<validation>
<homeGroup host_name="ap01marscloud.galaxy.com" oracle_home="/PROD/oracle/product/11204" org_id="0">
<conflictSetList>
<conflictSet issue_guid="2C60DDE176C25A2BFB7B9DEA1AF96C61" request_status="NOT_REQUESTED">
<patchList>
<patch>
<request_id>0</request_id>
<patch_upi>0</patch_upi>
<patch_id>11744544</patch_id>
<patch_name>11744544</patch_name>
<abstract>SET NEWNAME FOR DATABASE DOES NOT APPLY TO BLOCK CHANGE TRACKING FILE</abstract>
<platform_id>226</platform_id>
<platform>Linux x86-64</platform>
<release_id>801120418041702</release_id>
<release>11.2.0.4.180417</release>
<long_release>Oracle 11.2.0.4.180417</long_release>
<from>ADD_FROM_UNKNOWN</from>
</patch>
<patch>
<request_id>0</request_id>
<patch_upi>0</patch_upi>
<patch_id>27734982</patch_id>
<patch_name>27734982</patch_name>
<abstract>DATABASE PATCH SET UPDATE 11.2.0.4.180717</abstract>
<platform_id>226</platform_id>
<platform>Linux x86-64</platform>
<release_id>80112040</release_id>
<release>11.2.0.4.0</release>
<long_release>Oracle 11.2.0.4.0</long_release>
<from>ADD_FROM_UNKNOWN</from>
</patch>
</patchList>
<resolutionPatchList/>
<resolutionMessageList/>
</conflictSet>
</conflictSetList>
<backportRequestList/>
<messageList/>
</homeGroup>
</validation>
<addedPatchList/>
<ignoredPatchList/>
</analysisResults>
[mars@mars-linux Oracle_PatchPlan_002]$



Sample Multiple Patches Plan



[mars@mars-linux Oracle_PatchPlan_003]$ cat Oracle_PatchPlan_003.plan
name=Oracle_PatchPlan_003
description=Oracle_PatchPlan_003
deployment_date=
planPrivilegeList=empatchadmin
patch.0.patch_id=21091518
patch.0.release_id=80112040
patch.0.platform_id=226
patch.0.language_id=0
patch.0.target_name=PROD_ap01marscloud
patch.0.target_type=oracle_database

patch.1.patch_id=22338374
patch.1.release_id=80112040
patch.1.platform_id=226
patch.1.language_id=0
patch.1.target_name=PROD_ap01marscloud
patch.1.target_type=oracle_database

patch.2.patch_id=25128602
patch.2.release_id=80112040
patch.2.platform_id=226
patch.2.language_id=0
patch.2.target_name=PROD_ap01marscloud
patch.2.target_type=oracle_database

patch.3.patch_id=25678413
patch.3.release_id=80112040
patch.3.platform_id=226
patch.3.language_id=0
patch.3.target_name=PROD_ap01marscloud
patch.3.target_type=oracle_database

deploymentOptions.AdvancedOPatchOptions=null
deploymentOptions.StageLocation=%emd_emstagedir%
deploymentOptions.StagePatches=true
deploymentOptions.isStageLocationShared=false
deploymentOptions.notify.enabled=false
deploymentOptions.performAruAnalysis=true
deploymentOptions.DISPATCHER_LOC=%emd_emstagedir%
deploymentOptions.cloneAndPatch.selected=true
deploymentOptions.cloneAndPatch.element.0.host=ap01marscloud.galaxy.com
deploymentOptions.cloneAndPatch.element.0.source.oh=/PROD/oracle/product/11204
deploymentOptions.cloneAndPatch.element.0.destination.oh=/PROD/oracle/product/11204_1544778399754
deploymentOptions.cloneAndPatch.element.0.destination.name=
deploymentOptions.cloneAndPatch.element.0.destination.base=/PROD/oracle/product
deploymentOptions.cloneAndPatch.element.0.destination.migrateOnly=false
deploymentOptions.deploymentProcedure=CLONE_PATCH_SIDB:oracle:true
deploymentOptions.isDispatcherEnabled=true
deploymentOptions.isDispatcherLocShared=false
[mars@mars-linux Oracle_PatchPlan_002]$


Popular Posts