Sunday, January 30, 2022

SQL to check if a R12.2 patch is applied

In EBS R12.2,  ad_bugs does not tell if an EBS patch is applied or not due to the implications of online patching and its "abort" feature. 

1. The simple way to check if a parch (33207251, for example) was applied or not in R12.2 (if node info is not important in a multi-node instance):

SQL> SELECT ad_patch.is_patch_applied('R12',-1,33207251) FROM dual;

AD_PATCH.IS_PATCH_APPLIED('R12',-1,33207251)
----------------
EXPLICIT

2. More accurate way to check patching status:

Query (modified from a query in Doc ID 443761.1) for finding out more details on patching (if it was applied by ADOP). In a multi-nodes environment, it does not tell which node, but the timestamp gives you some clue.

SQL> SELECT DISTINCT a.bug_number, e.patch_name, to_char(c.end_date, 'DD-MON-RRRR HH24:MI:SS') End_date, e.patch_type, d.patch_abstract
FROM
ad_bugs a, ad_patch_run_bugs b, ad_patch_runs c, ad_patch_drivers d , ad_applied_patches e
WHERE
a.bug_id = b.bug_id AND
b.patch_run_id = c.patch_run_id AND
c.patch_driver_id = d.patch_driver_id AND
d.applied_patch_id = e.applied_patch_id AND
a.bug_number = '33207251'
order by 1,3 ASC;

BUG_NUMBER  PATCH_NAME  END_DATE   PATCH_TYPE    PATCH_ABSTRACT
---------------  ------------  ----------------------------  ------------------------------------------------------
33207251  33487428  28-JAN-2022 09:14:10  ONE-OFF  ORACLE APPLICATIONS RELEASE 
                                                                                             12.2: CPU PATCH FOR JAN 2022
33207251  33487428  29-JAN-2022 08:20:21  ONE-OFF  ORACLE APPLICATIONS RELEASE
                                                                                             12.2: CPU PATCH FOR JAN 2022

NOTES: If a patch is part of another big patch, such a CPU patch, it might not show up in table ad_applied_patches or ad_adop_session_patches. For instance, patch 33207251 was applied successfully as part of Jan 2022 CPU patch 33487428, but it does not show up in queries:
SQL> select * from ad_applied_patches where patch_name in ('33207251', '33487428');
SQL> select * from ad_adop_session_patches where bug_number in ('33207251', '33487428');

3. Below query could be a good one to tell if a patch was applied successfully or not on node level. But, for a cloned instance, it lists only patches that were applied after clone.

SQL> SELECT adb.bug_number, aas.name appl_top_name, adb.creation_date, adb.language,
decode(ad_patch.is_patch_applied('R12',aas.appl_top_id,adb.bug_number,adb.language),'EXPLICIT','APPLIED','NOT_APPLIED','NOT APPLIED') status
FROM ad_bugs adb,
(select distinct appltop_id appl_top_id, node_name name from ad_adop_sessions 
           where node_name in (select node_name from ADOP_VALID_NODES) ) aas
where adb.bug_number in (
'33168664',
'33207251', 
'33487428',
'26521736'
) order by creation_date desc, adb.bug_number,aas.name,adb.language;

EXPLANATION: 
Oracle  Doc ID 1963046.1 give a query to find if a patch was applied or not:
SQL> SELECT adb.bug_number,ad_patch.is_patch_applied('R12', \'$appl_top_id\', adb.bug_number)
FROM ad_bugs adb
WHERE adb.bug_number in ('\$patch_no\');

expected results:
       EXPLICIT = applied
       NOT APPLIED = not applied / aborted

The problem is table APPLSYS.AD_APPL_TOPS has too many obsolete data (Doc ID 2075234.1). Especially for cloned instance, it may be useless in finding APPL_TOP_ID. I find table AD_ADOP_SESSIONS has accurate APPL_TOP_ID info.  Below is an example to confirm patching 33168664 failed on 2nd node.

SQL> select distinct appltop_id, node_name, node_type from ad_adop_sessions 
           where node_name in (select node_name from ADOP_VALID_NODES);

APPLTOP_ID NODE_NAME  NODE_TYPE
----------------- -------------------- ----------
               2088  appNode1d      slave
               1088  appNode2d      master

SQL> SELECT adb.bug_number,ad_patch.is_patch_applied('R12', 1088, adb.bug_number) status
           FROM ad_bugs adb WHERE adb.bug_number in ('33168664');

BUG_NUMBER  STATUS
--------------------- -----------
33168664     EXPLICIT

SQL> SELECT adb.bug_number,ad_patch.is_patch_applied('R12', 2088, adb.bug_number) status
           FROM ad_bugs adb WHERE adb.bug_number in ('33168664');

BUG_NUMBER  STATUS
--------------------- -----------
33168664     NOT_APPLIED

Additional NOTES:

A). Doc ID 443761.1 (How To Check If a Certain Patch Was Applied to Oracle E-Business Suite Instance) also gives a way to check which patches were applied in each ADOP_SESSION_ID (patching cycle).  But, I found ad_adop_session_patches is NOT very reliable.

set pagesize 200;
set linesize 160;
column adop_session_id format 999999999999;
column bug_number format a15;
column status format a15;
column applied_file_system_base format a23;
column patch_file_system_base format a23;
column adpatch_options format a15;
column node_name format a15;
column end_date format a15;
column exec_time format a15;
column clone_status format a15;
SQL> select ADOP_SESSION_ID, BUG_NUMBER, APPLIED_FILE_SYSTEM_BASE, PATCH_FILE_SYSTEM_BASE, ADPATCH_OPTIONS, NODE_NAME, 
END_DATE,  ROUND((end_date - start_date) * 24*60,2) exec_time, CLONE_STATUS,
       DECODE(status,'N','Applied on other nodes',
                     'R','Running',
                     'H','Failed (Hard)',
                     'F','Failed (Jobs Skipped)',
                     'S','Success (worked after skipping the failed)',
                     'Y','Success',
                     'C','Clone Complete') status
from ad_adop_session_patches
order by end_date desc;

B). Snapshot update: If you are sure a patch is applied but it is not showing as applied via the above steps, then update the snapshot manually with the steps below:
1) Start adadmin after source the RUN FS env.
2) Select "2. Maintain Applications Files menu" in "AD Administration Main Menu".
3) In "Maintain Applications Files", select "4. Maintain snapshot information".
4) Select "2. Update current view snapshot" in the "Maintain Snapshot Information".
5) Select "1. Update Complete APPL_TOP" in the "Maintain Current View Snapshot Information".

C). To determine the RUN files system:
SQL> SELECT EXTRACTVALUE(XMLType(text),'//oa_context_file_loc')
 appl_top, status
  FROM fnd_oam_context_files
 WHERE name NOT IN ('TEMPLATE','METADATA','config.txt')
  AND CTX_TYPE='A'
 AND (status IS NULL OR UPPER(status) IN ('S','F'))
  AND EXTRACTVALUE(XMLType(text),'//file_edition_type') = 'run';

To determine the PATCH files system:
SQL> SELECT EXTRACTVALUE(XMLType(text),'//oa_context_file_loc')
 appl_top, status
  FROM fnd_oam_context_files
 WHERE name NOT IN ('TEMPLATE','METADATA','config.txt')
  AND CTX_TYPE='A'
 AND (status IS NULL OR UPPER(status) IN ('S','F'))
  AND EXTRACTVALUE(XMLType(text),'//file_edition_type') = 'patch';

Friday, January 21, 2022

Change Apps password in R12.2

Two steps to change APPS password in R12.2: FNDCPASS and WLS Admin Console.

1) Stop Apps services
2) $ FNDCPASS apps/old_appsPWS 0 Y system/'systemPWD' SYSTEM APPLSYS new_AppsPWD
3) AutoConfig
4) start WLS Admin services
./adadminsrvctl.sh start

5) Manually update the password in WLS Admin Console for starting oacore, etc.
See Doc ID 1674462.1 (R12.2: Steps to Change the APPS, APPLSYS, and APPS_NE Password Using FNDCPASS or AFPASSWD)
a. Log in to WLS Administration Console.
    http://[node_name.domain.com]:s_wls_adminport/console
b. Click Lock & Edit in Change Center.
c. In the Domain Structure tree, expand Services, then select Data Sources.
d. On the "Summary of JDBC Data Sources" page, select EBSDataSource.
e. On the "Settings for EBSDataSource" page, select the Connection Pool tab.
f. Enter the new password in the "Password" field.
g. Enter the new password in the "Confirm Password" field.
h. Click Save.
i. Click Activate Changes in Change Center.
6) Start all Apps services

Notes: Doc ID 2360475.1 states APPS password is not saved in any files but stored in database.

Tuesday, January 18, 2022

Change Weblogic password in R12.2

Many posts on changing Weblogic password. Below steps worked for me.

1. Stop all EBS services
2. Start Admin Server on Primary node
$ $ADMIN_SCRIPTS_HOME/adadminsrvctl.sh start
3. Run below line to change Weblogic password.
WARNING: It does not prompt to confirm the new password. The safest way is to enter it by copy/paste. If you type it wrong, it will be a disaster because Oracle does not supply a way to decrypt passwords.
 
$ perl $FND_TOP/patch/115/bin/txkUpdateEBSDomain.pl -action=updateAdminPassword

Program: txkUpdateEBSDomain.pl started at Tue ... ...

AdminServer will be re started after changing WebLogic Admin Password
All Mid Tier services should be SHUTDOWN before changing WebLogic Admin Password
Confirm if all Mid Tier services are in SHUTDOWN state. Enter "Yes" to proceed or anything else to exit: Yes

Enter the full path of Applications Context File [DEFAULT - $CONTEXT_FILE]:
Enter the WLS Admin Password:
Enter the new WLS Admin Password:
Enter the APPS user password:
... ...
*************** IMPORTANT ****************
WebLogic Admin Password is changed.
Restart all application tier services using control scripts.
********************************************
----------------------------------------
Inside generateMimeMappingsPropFile()...
----------------------------------------
$FMW_HOME/user_projects/domains/EBS_domain/config/mimemappings.properties already exists, updating it.
--------------------------------------
Inside updateMimeMappingsPropFile()...
--------------------------------------
-------------------------------------
Inside resetExistingMimeMappings()...
-------------------------------------
Overwriting the value for the parameter: png
Overwriting the value for the parameter: xml
Overwriting the value for the parameter: js
Overwriting the value for the parameter: svg
Overwriting the value for the parameter: swf
Reset of mime mappings completed.
---------------------------
Inside addMimeMappings()...
---------------------------
Adding of mime mappings completed.
Taking backup of existing mimemappings.properties.
Copying the file
----------------
SOURCE : $FMW_HOME/user_projects/domains/EBS_domain/config/mimemappings.properties
TARGET : $FMW_HOME/user_projects/domains/EBS_domain/config/mimemappings.properties_bkp
Copying temporary file as mimemappings.properties.
Copying the file
----------------
SOURCE : $FMW_HOME/user_projects/domains/EBS_domain/config/mimemappings.properties_temp
TARGET : $FMW_HOME/user_projects/domains/EBS_domain/config/mimemappings.properties
$FMW_HOME/user_projects/domains/EBS_domain/config/mimemappings.properties updated successfully.
Program: txkUpdateEBSDomain.pl completed at Tue ... ...

4. Log onto Weblogic Console and EM as weblogic using the new password.
5. Start all EBS services

Different Weblogic version may have different way to change the password. Version info (for details, see Doc ID 1051959.1 How To Find the Full WebLogic Server Version and Full Patch Level):

$ cd $FMW_HOME/user_projects/domains/EBS_domain_${TWO_TASK}/servers/AdminServer/logs
$ grep WebLogic AdminServer.log
... ...
<WebLogic Server "AdminServer" version:
WebLogic Server 10.3.6.0.210119 PSU Patch for BUG32052267 Mon Nov 23 07:28:31 UTC 2020
WebLogic Server Temporary Patch for BUG13964737 Fri Dec 20 11:32:08 IST 2013
WebLogic Server Temporary Patch for BUG20474010 Sun Mar 01 17:22:18 IST 2015
WebLogic Server Temporary Patch for ${CRS} Mon Jul 30 16:45:20 EDT 2012
WebLogic Server Temporary Patch for ${CRS} Mon Jul 30 16:45:20 EDT 2012
WebLogic Server 10.3.6.0  Tue Nov 15 08:52:36 PST 2011 1441050  Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.>   ... ...

REFERENCES:

How to Change /Reset /Retrieve the WebLogic Server Administrator Password - All Versions (Doc ID 1082299.1)
How to Decrypt WLS Passwords using WLST? ( Doc ID 2732961.1 )