Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday, June 8, 2017

Login storm to the database caused to exhausted "library cache".

There were massive contention in the shared pool, in form of wait events alerted as "library cache locks".Sufficient resource were available for instance to work.
Issue was caused by an incorrect password configuration on the application server/Discoverere.

Observation:
Shared pool were totally exhausted, caused by "library cache lock".
View V$EVENT_NAME  showed that the wait event was accompanied by the additional information found in the columns parameter1 through parameter3,
which turned out to be helpful further on:
select  name, wait_class,parameter1,parameter2,parameter3
from v$event_name
where wait_class = 'Concurrency'
and name = 'library cache lock';

  NAME            WAIT_CLASS PARAMETER1    PARAMETER2   PARAMETER3
library cache lock Concurrency handle address lock address 100*mode+namespace

Was unable to login  as below as well:

[oracle@~]$ sqlplus apps/*****

SQL*Plus: Release 11.2.0.3.0 Production on Sun May 10 10:41:14 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Error accessing PRODUCT_USER_PROFILE
Warning:  Product user profile information not loaded!
You may need to run PUPBLD.SQL as SYSTEM
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ ~]$

On drilldown found that the issue  was due to a built-in delay between failed login attempts in Oracle 11g.

"The 'library cache lock' wait is seen due to the fact that the account status gets updated due to incorrect login.
To prevent password guessing attack, there's a sleep() in the code when incorrect login attempts exceed count of 3.
And because of this sleep() you see a wait on library cache, as the process is yet to release the lock."

11.1.0.7, patch 7715339 was released to remove this delay.
11.2.X, the DBA must set an event to remove the delay, as follows:

alter system set events '28401 trace name context forever, level 1';

According to Oracle, the purpose of the built-sleep is to make it harder to succeed in a "password guessing attack", particularly in cases where FAILED_LOGIN_ATTEMPTS is set to UNLIMITED. Oracle Development is pointing out that disabling the sleep-function is not recommended. A better solution is to set the FAILED_LOGIN_ATTEMPTS to a reasonable value. When the number of failed login attempts for a session hits the limit, the account will be locked. Subsequent logon attempts with incorrect password will then be rejected  immediately without any contention in the library cache.

 Bug 15882590 : 'LIBRARY CACHE LOCK' DURING WRONG PASSWORD LOGON 

Grid PSU Execution:

When we invoke opatchauto, opatch will patch both the GI stack and the database software stack. Since we do not have a database running,patch will skip the database software stack and only apply the PSU to the GI Home. Before we invoke the opatchauto command,let’s create the ocm.rsp response file by executing the OCM Installation Response Generator (emocmrsp).

As per oracle Doc id: 1591616.1:

Till the above doc id, while we applying PSU or one off patches, we used to pass -ocmrf parameter.  After installing latest opatch p6880880_122010_.zip (12.2.0.1.5 release and later), unable to create ocm.rsp,when checked, OPatch/ocm/bin, It was empty and binary emocmrsp was missing.

OPatch/ocm/bin>ls -lrt
total 0

As OCM is no longer packaged with OPatch, the -ocmrf is no longer needed in the command line.
as latest opatch doesn’t contain OCM , the option “-ocmrf” is unnecessary if latest opatch is being used.

When using OPatch version 12.2.0.1.5 or later, No need of ocm.rsp file for Grid Patching i.e following Opatch Option -ocmrf not needed.

AUTO Patching:
AUTO patching option is the  enhancement from Oracle in the recent times which automates the entire patching procedure smoothly and more importantly without much DBA intervene.

Auto patching doesn’t go well when multiple Oracle homes exists with different software owners.
If you have multiple versions of Oracle databases running.
During the course of patching, if any of the files fail to copy/rollback the backup copy due to file busy with flag on the OS (for example, Error in writing to file'/u00/app/11.2.0.2/grid/bin/adctrl' (Text file busy)) the patch will be automatically rolled back and subsequently cluster and all services will be restarted.
In the above circumstances, one may choose going with the AUTO patch separately for GI and then to the RDBMS homes.

###

OPatchauto automatically patch the typical Grid Infrastructure (GI) and RAC home directories with minimal intervention.

The main advantage of opatchauto utility was automatically down the CRS and database services and restart the services after apply patching.

In general, when we invoke opatchauto will patch both the GI stack and the database software stack. Since we have mentioned the -oh it will apply the PSU to the specified home.

To apply a patch using opatchauto,we need to run as a root user.

Steps in details as below:

Set the GI home environment and verify it.
echo $ORACLE_HOME
echo $ORACLE_SID

Check opatch version in GI home:
opatchauto version

opatch lsinventory

opatch lsinventory -detail -oh $ORACLE_HOME

opatch lsinventory -detail -oh /u05/app/12.1.0.2/grid

Check conflicts:
NOTE: opatchauto is running in ANALYZE mode. There will be no change to your system.
sudo $GRID_HOME/OPatch/opatchauto apply $Patch_location/25434003 -analyze

As root user:
/u05/app/12.1.0.2/grid/OPatch/opatchauto apply /int/fs/B/roll_patch/28349311 -analyze -oh /u05/app/12.1.0.2/grid

APPLYING PATCH:
It’s needed a response file to use opatchauto hence create the response file and apply the patch in GI HOME,User oracle with proper env values set:
cd $GRID_HOME/OPatch/ocm/bin
$ ls -ltr
dummy
emocmrsp
$ ./emocmrsp
$ ls -ltr
dummy
emocmrsp
ocm.rsp <= RESPONSE FILE CREATED

INSTALL:
stops instance+listener+ASM+ (if it deppends of $ORACLE_HOME )

sudo $GRID_HOME/OPatch/opatchauto apply $Patch_location/25434003 -ocmrf $RESPONSE_FILE_PATH/ocm.rsp –oh $GRID_HOME

opatchauto for GID_HOME:

/u05/app/12.1.0.2/grid/OPatch/opatchauto apply /int/fs/B/roll_patch/28349313 -oh /u05/app/12.1.0.2/grid

opatchauto for ORACLE_HOME:

/u05/app/oracle/product/12.1.0.2/db_2/OPatch/opatchauto apply /int/fs/B/roll_patch/27468958 -oh/u05/app/oracle/product/12.1.0.2/db_2

Datapatch is the new tool that enables automation of post-patch SQL actions for RDBMS patches. In 12c we don’t use carbundle psu apply, all this will be done using datapatch. OPatchAuto calls datapatch to complete post patch actions upon installation of the binary patch and restart of the database.

select BUNDLE_SERIES,PATCH_UID,PATCH_ID,
VERSION,ACTION,STATUS,ACTION_TIME ,DESCRIPTION
from dba_registry_sqlpatch;

Post-patch:
Start services

Below direct command will aslo help in same purpose.

As Root User execute  command
$ORACLE_HOME/OPatch/ocm/bin/emocmrsp -no_banner -output $ORACLE_HOME/ocm.rsp
$ORACLE_HOME/OPatch/opatch auto <patch loc.> -oh $ORACLE_HOME -ocmrf $ORACLE_HOME/ocm.rsp
https://updates.oracle.com/Orion/Services/download?type=readme&aru=20990697

DEINSTALL PATCH:
Stop all services
opatchauto rollback Patch_location/25434003 –oh $GRID_HOME

Difference between CPU and PSU:

CPU stands for critical patch update & PSU for patch set update.

Critical Patch Update (CPU) is overall release of security fixes each quarter rather than the cumulative database security patch for the quarter.

CPU are built on patch set version e.g 10.2.0.3 where as PSU are built on base of prevoius version e.g. 10.2.0.3.1.

Patch Set Updates (PSU) are the same cumulative patches that include both the security fixes and priority fixes.  The key with PSUs is they are minor version upgrades (e.g., 11.2.0.1.1 to 11.2.0.1.2).  Once a PSU is applied, only PSUs can be applied in future quarters until the database is upgraded to a new base version.

PSU can always be applied over any CPU.

CPU is subset of PSU(PSU contain CPU)

To check Applied PSU patched you need to run :
opatch lsinventory -bugs_fixed | grep -i 'DATABASE PSU'

 and if you need to check CPU :
 Select * from registry$history;

Apply Patch PSU:


CHECK CONFLICTS

[oracle@hostname 26027154]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./

Stop instance and associated listener (if it’s rdbms dependant)
$ORACLE_HOME/Opatch/opatch apply

1. cd $ORACLE_HOME/rdbms/admin
2. sqlplus /nolog
3. SQL> CONNECT / AS SYSDBA
4. SQL> startup
5. SQL> @catbundle psu apply
6. SQL>@?/rdbms/admin/utlrp.sql
Check the following log files in $ORACLE_HOME/cfgtoollogs/catbundle or $ORACLE_BASE/cfgtoollogs/catbundle for any errors:
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log


OJVM COMPONENT:
Shutdown all services (Recommend  stop OMS agent too)
$ORACLE_HOME/Opatch/opatch apply

1. cd $ORACLE_HOME/sqlpatch/25434033
2. sqlplus /nolog
3. SQL> CONNECT / AS SYSDBA
4. SQL> STARTUP UPGRADE
5. SQL> @postinstall.sql
6. SQL> shutdown
7. SQL> startup
8. SQL> @?/rdbms/admin/utlrp.sql





Wednesday, June 7, 2017

User details by user name

set lines 200
col instance format a10
col process format a15
col program/module format a35
col spid format a10
col osuser format a10
col dbuser format a10
col appsuser format a30
COL SID format a10

select distinct i.instance_name "instance",
to_char(s.sid, '99999') "sid", to_char(s.serial#, '99999') "ser#", s.process "process",
nvl(s.program,s.module) "program/module", s.status "status", to_char(p.pid, '999') "pid",
p.spid "spid", s.osuser "osuser", s.username "dbuser", fu.user_name "appsuser" from gv$session s,
gv$process p, gv$instance i, applsys.fnd_logins fl, applsys.fnd_user fu where s.paddr = p.addr and i.inst_id = s.inst_id
and p.spid = fl.process_spid (+) and p.pid = fl.pid (+) and fl.user_id = fu.user_id (+) and fu.user_name like '%&1%'
-- apps users
--order by fu.user_name
order by 1,2;


All form related session :

col CLIENT_IDENTIFIER format a10
col MODULE format a25
col MACHINE format a10

select sid, serial#, logon_time, client_identifier, module, status, machine, seconds_in_wait
from gv$session
where program like 'frmweb%'
order by logon_time;