Applying PSU results “patching Following executables are active”

while patching oracle 12c database on Linux OS environment, i faced the below error while applying the patch using Opatch utility (although the database is shutdown):

 

Verifying environment and performing prerequisite checks…

Prerequisite check “CheckActiveFilesAndExecutables” failed.

The details are:

Following executables are active :

/oracl/db11/product/12.1.0.2/lib/libclntsh.so.12.1

UtilSession failed: Prerequisite check “CheckActiveFilesAndExecutables” failed.

 

solution:

find the process that is locking the file system using the fuser command

fuser -u /oracl/db11/product/12.1.0.2/lib/libclntsh.so.12.1

and then kill it using kill -9 command

Applying Patches on Oracle 12c Guide

This is an overview procedure on how to apply Oracle Patches (PSU) on Oracle 12cR1 databases (12.1.0.2). Its very important that you read the official documentation (readme.html) that is being provided with the patch being released in case oracle is listing new requirements.

********* STEPS for Applying PSU on 12c in Unix environment:

1.first collect preliminary database information and spool it in a file.

make a directory and call it before_patch: mkdir before_patch

cd before_patch

sqlplus ‘/as sysdba’

set pages 300
set lines 250
col owner for a17;
col object_name for a35;
col object_type for a20;
col action for a15;
col comments for a40;
col comp_name for a40;
col version for a15;

spool before_patch.log
SELECT NAME FROM V$DATABASE;
SELECT * from V$VERSION;
SELECT ACTION,VERSION,COMMENTS FROM SYS.REGISTRY$HISTORY;
SELECT * from dba_registry_sqlpatch;
SELECT COMP_NAME,VERSION,STATUS FROM DBA_REGISTRY;
select count(*) from dba_objects where status = ‘INVALID’;
select owner, count(*) from dba_objects where status <>’VALID’ group by owner order by 1;
Select owner, object_type, object_name
from dba_objects where status <>’VALID’ order by 1,2,3;
spool off

2. edit your Oracle inventory and make sure its pointing to the right location

3.shutdown listener and shutdown the database.

you can check the database listener name in your server by executing the unix command: ps -ef |  gep inh

or going directly to $ORACLE_HOME/network/admin and executing the command: lsnrctl stop listener_db1

4. in 12c the patches are being setup depending if you have JAVA component in your database or not.

For 12.1.0.2 if there is no JAVA component
go to the location of the patch:

cd ../20834354/20299023
then execute the OPatch utiltiy
OPatch/opatch apply -invPtrLoc /etc/oraInst.loc

For 12.1.0.2 if JAVA component exists
cd ../20834354/20415564
Opatch/12.1.0.1.7/OPatch/opatch apply -invPtrLoc /etc/oraInst.loc

*** the output will be similar to this:

Do you want to proceed? [y|n]
Y
Email address/User Name:
Press enter

You have not provided an email address for notification of security issues.
Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]:
Yes

Is the local system ready for patching? [y|n]
Y

5. Run Bundle

##### To run the bundle for 12.1.0.2 FOR NON-JAVA
sqlplus ‘/as sysdba’
STARTUP
exit
cd $ORACLE_HOME/OPatch
./datapatch -verbose
—–Please make sure you receive the following message “Patch 20299023 apply: SUCCESS
sqlplus ‘/as sysdba’
col PRODUCT for a60;
col VERSION for a10;
col STATUS for a15;
col description for a60;
col action_time for a30;
set lines 133
select patch_id, version, status, description, action_time from dba_registry_sqlpatch order by 1;

##### To run the bundle for 12.1.0.2 FOR JAVA
sqlplus ‘/as sysdba’
STARTUP UPGRADE
QUIT
cd $ORACLE_HOME/OPatch
./datapatch –verbose
sql
shutdown immediate
STARTUP

6. Post Patching
cd
mkdir after_patch
cd after_patch
sql
sqlplus ‘/as sysdba’
col action for a15;
col comments for a40;
col comp_name for a40;
col version for a15;
set pages 300
set lines 300

spool after_patch.log
select name from v$database;
select * from v$version;
select ACTION,VERSION,COMMENTS from sys.registry$history;
select COMP_NAME,VERSION,STATUS from dba_registry;
select * from dba_registry_sqlpatch;
select count(*) from dba_objects where status = ‘INVALID’;
select owner, count(*) from dba_objects where status <>’VALID’ group by owner order by 1;
Select owner, object_type, object_name
from dba_objects where status <>’VALID’ order by 1,2,3;
spool off

how to find installed patches in Oracle Database 12c

In oracle database 12c release, you can use the package DBMS_QOPATCH to find information about patches currently applied in your database.

 

this package can only be executed by “sys” user account.

 

examples of the package sub-functions used:

DBMS_QOPATCH.GET_OPATCH_DATA (
patchnum IN VARCHAR2);
RETURN XMLYPE;

*.* returns information about Patch ID, patch creation time.

DBMS_QOPATCH.GET_OPATCH_INSTALL_INFO
RETURNS XMLTYPE;

*.* information about th patch and oracle inventory location.

DBMS_QOPATCH.GET_OPATCH_LSINVENTORY
RETURN XMLYPE;

*.* returns full patch inventory in XML format

 

Also, you can use the query:

SQL> select dbms_qopatch.get_opatch_lsinventory() from dual;

 

Reference: http://docs.oracle.com/cd/E16655_01/appdev.121/e17602/d_qopatch.htm#ARPLS74923