Translate

Sunday, December 29, 2013

SPM Fixing (SPM:- SQL PLAN MANAGEMENT).

1) Identify the problematic query.

In my example say.
afcd3rktapas1

It is taking lots of buffer gets when optimizer_features_enabled='11.2.0.3'

select sql_id,DISK_READS,BUFFER_GETS,executions from v$sql where sql_id='afcd3rktapas1';

SQL_ID DISK_READ BUFFER_GETS EXECUTIONS
------ --------- ----------- ----------
afcd3rktapas1 364958 67544379 0

Sqltext.
---------
UPDATE C SET T = (SELECT
NVL(SUM(C.G(NVL(E.T,0.00),G
.A,'INR','NR',:B4 )),0.00) FROM E,G,C A
WHERE G.A = E.A AND A.A = G.A AND
G.BA != '16050001' AND A.A =
C.A AND A.S = C.S AND
A.L = C.L AND A.L =
C.L AND A.S = G.S AND A.L
= :B2 AND A.L = :B1 AND A.SET_ID = :B3 AND
TO_DATE(E.E) <= TO_DATE(:B4 ) AND TO_DATE(E.END_E)>=
TO_DATE(:B4 ) AND (G.S = 'O' OR G.S='O')) WHERE
SET_ID = :B3 AND L = :B2 AND L = :B1

Take the bind variable of the query.

NAME                             POSITION DATATYPE_STRING VALUE_STRING
------------------------------ ---------- --------------- ------------------------------
:B4                                     1 DATE
:B2                                     2 VARCHAR2(32)    XXXXX
:B1                                     3 DATE            12/26/2013 00:00:00
:B3                                     4 VARCHAR2(32)    0190
:B4                                     5 DATE            12/24/2013 00:00:00
:B4                                     6 DATE            12/24/2013 00:00:00
:B3                                     7 VARCHAR2(32)    0190
:B2                                     8 VARCHAR2(32)    XXXXX
:B1                                     9 DATE            12/26/2013 00:00:00

2) Find the best possible plan for the same query,
   In my example I have change optimizer_features_enabled='10.2.0.4';

Sql> alter session set optimizer_features_enabled='10.2.0.4';

Sql> variable cnt number; /* it will execute the query without effecting the data of table,
                             and will create the plan by returning 0 row */

/* DECLARE THE DIND VARIABLE NOTE: CHANGE THE DATE FIELD TO VARCHAR */
variable B4 VARCHAR2(32)
variable B2 VARCHAR2(32)
variable B1 VARCHAR2(32)
variable B3 VARCHAR2(32)

/* EXECUTE THE VARIABLE */

exec :B1:='12/26/2013'
exec :B2:='2388'
exec :B3:='2388'
exec :B4:='12/26/2013'

Sql> UPDATE /*good_plan*/ C SET T = (SELECT
NVL(SUM(C.G(NVL(E.T,0.00),G
.A,'INR','NR',:B4 )),0.00) FROM E,G,C A
WHERE G.A = E.A AND A.A = G.A AND
G.BA != '16050001' AND A.A =
C.A AND A.S = C.S AND
A.L = C.L AND A.L =
C.L AND A.S = G.S AND A.L
= :B2 AND A.L = :B1 AND A.SET_ID = :B3 AND
TO_DATE(E.E) <= TO_DATE(:B4 ) AND TO_DATE(E.END_E)>=
TO_DATE(:B4 ) AND (G.S = 'O' OR G.S='O')) WHERE
SET_ID = :B3 AND L = :B2 AND L = :B1;

0 rows updated.

Sql> select sql_id,DISK_READS,BUFFER_GETS,executions,plan_hash_value from v$sql where sql_text like '%/*good_plan*/%';

SQL_ID DISK_READ BUFFER_GETS EXECUTIONS PLAN_HASH_VALUE
------ --------- ----------- ---------- ---------------
dcba3rxapyfs1 949 346 0 4567846893

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Steps for fixing the plan.
--------------------------
1) variable cnt number;
exec :cnt:=dbms_spm.load_plans_from_cursor_cache(sql_id=>'&sql_id');
enter bad query ----> it will load the value of plan of bad query in SPM
afcd3rktapas1

2) select sql_handle, sql_text, plan_name, enabled from dba_sql_plan_baselines;

SQL_HANDLE                     SQL_TEXT PLAN_NAME                      ENA
------------------------------ ------------------------------------------------- ------------------------------ ---
SQL_ae48a49af377a3d6           UPDATE C SET T = (SELECTNVL(SUM(C.G(NVL(E.T,0.00) SQL_PLAN_awk54mbtrg8yqc03d1b54 YES

3) exec :cnt:=dbms_spm.alter_sql_plan_baseline( -
                sql_handle=>'&handle', -
                plan_name=>'&plan_name', -
                attribute_name=>'enabled', -
                attribute_value=>'NO');> > > >
Enter value for handle: SQL_ae48a49af377a3d6
Enter value for plan_name: SQL_PLAN_awk54mbtrg8yqc03d1b54

select sql_handle, sql_text, plan_name, enabled from dba_sql_plan_baselines;

SQL_HANDLE                     SQL_TEXT PLAN_NAME                      ENA
------------------------------ ------------------------------------------------- ------------------------------ ---
SQL_ae48a49af377a3d6           UPDATE C SET T = (SELECTNVL(SUM(C.G(NVL(E.T,0.00) SQL_PLAN_awk54mbtrg8yqc03d1b54 NO

4) exec :cnt:=dbms_spm.load_plans_from_cursor_cache(sql_id=>'&sql_id',plan_hash_value=>&plan_hash,sql_handle=>'&sql_handle');
Enter value for sql_id: dcba3rxapyfs1 /good/
Enter value for plan_hash: 4567846893 /good/
Enter value for sql_handle: SQL_ae48a49af377a3d6 /old/

select sql_handle, sql_text, plan_name, enabled from dba_sql_plan_baselines;

SQL_HANDLE                     SQL_TEXT PLAN_NAME                      ENA
------------------------------ ------------------------------------------------- ------------------------------ ---
SQL_ae48a49af377a3d6           UPDATE C SET T = (SELECTNVL(SUM(C.G(NVL(E.T,0.00) SQL_PLAN_ccd5w9pkt1u713969ca76 YES
SQL_ae48a49af377a3d6           UPDATE C SET T = (SELECTNVL(SUM(C.G(NVL(E.T,0.00) SQL_PLAN_awk54mbtrg8yqc03d1b54 NO


====================================================================================

Conclusion.
Now after doing this when you check the buffer gets for the same query after executing it,you will get a huge change.

Monday, September 9, 2013

Steps for Importing and Exporting statistics from one database to other database.

Steps for Importing and Exporting statistics from one database to other database.
=================================================================================

1) exec dbms_stats.create_stat_table(ownname=>'OWNER_NAME',stattab=>'MY_STAT_TABLE');

   example: exec dbms_stats.create_stat_table(ownname=>'SYS'stattab=>'MY_STAT');

2) exec dbms_stats.export_schema_stats(ownname=>'ENTER_THE_OWNER_NAME',
   stattab=>'ENTER_THE_TABLE_NAME_CREATED_ABOVE',statown=>'ENTER_OWNER_OF_MY_STAT_TABLE');

   example: dbms_stats.export_schema_stats(ownname=>'SCOTT',stattab=>'MY_STAT',STATOWN=>'SYS')

3) export the table created with statistics data contained. (as a .dmp file)

4) Transfer the data to another database where statistics is to be imported.

5) import the (.dmp file) to the datbase.

6) exec dbms_stats.import_schema_stats(ownname=>'Enter_the_own_name_statistics_gathered_schema',
   stattab=>'ENTER_THE_TABLE_NAME_CREATED_ABOVE',statown=>'Enter_the_owner_name_of_the_table_containing_data_of_statistics',force=>true);

   example: exec dbms_stats.import_schema_stats(ownname=>'SCOTT',stattab=>'MY_STAT',statown=>'SYS',force=>true);

Wednesday, September 4, 2013

Purging a SQL plan from shared pool. "Purging a Single cursor from shared pool"

This Document is applicable for Oracle 11g Release 2.
======================================

Identify the problemetic sql_id.

Find the Address and hash_value of the sql_id

In my example sql_id is 'arxk2v5bw36mp'

col OWNER format a10
col NAMESPACE format a10
col TYPE format a10

select d.OWNER,d.NAMESPACE,d.TYPE,d.SHARABLE_MEM,d.KEPT,d.FULL_HASH_VALUE,
s.sql_id,s.address,s.hash_value
from v$db_object_cache d,v$sqlarea s
where d.name=s.SQL_TEXT
and s.sql_id='&sql_id'

OWNER      NAMESPACE  TYPE       SHARABLE_MEM KEP FULL_HASH_VALUE                  SQL_ID        ADDRESS          HASH_VALUE
---------- ---------- ---------- ------------ --- -------------------------------- ------------- ---------------- ----------
           SQL AREA   CURSOR            12616 NO  7541aaf7b87e0b3babf642d957c19a75 arxk2v5bw36mp C0000006B0B15310 1472305781
           SQL AREA   CURSOR                0 NO  7541aaf7b87e0b3babf642d957c19a75 arxk2v5bw36mp C0000006B0B15310 1472305781
           SQL AREA   CURSOR             4720 NO  7541aaf7b87e0b3babf642d957c19a75 arxk2v5bw36mp C0000006B0B15310 1472305781


Flush the SQL olan form library cache.
========================================
exec dbms_shared_pool.purge('C0000006B0B15310,1472305781','C',65);

select d.OWNER,d.NAMESPACE,d.TYPE,d.SHARABLE_MEM,d.KEPT,d.FULL_HASH_VALUE,
s.sql_id,s.address,s.hash_value
from v$db_object_cache d,v$sqlarea s
where d.name=s.SQL_TEXT
and s.sql_id='&sql_id'

Output.

SQL> exec dbms_shared_pool.purge('C0000006B0B15310,1472305781','C',65);

PL/SQL procedure successfully completed.

SQL> /
Enter value for sql_id: arxk2v5bw36mp
old   5: and s.sql_id='&sql_id'
new   5: and s.sql_id='arxk2v5bw36mp'

no rows selected

Note: In above example 65 means the whole object from shared pool will be purged.
      i.e plan of query will be purged from library cache. And C means object "sql statement" that is not    a package/procedure/function/trigger/sequence.

Friday, June 28, 2013

Oracle Database 12c installation Step by Step with screen shots on OEL6 64 bits.

Steps for Installation of Oracle 12c on OEL 6 Platform.

By: Tapas Kumar Karmakar.
Oracle DBA.
A. Prerequisites.

1. Install OEL6 on server.
"Oracle Linux
All Oracle Unbreakable Enterprise Kernel versions for Oracle Linux 5 and 6 starting with 2.6.32-100.28.9 (released March 16, 2011)."
2. For Kernel Parameters for OEL6
Please visit: http://www.ksplice.com/uptrack/supported-kernels
3. Download Oracle Software from oracle website.
4. If you want to install Oracle from windows system you must have installed any software that provide graphical interface for unix system in windows platform I have user Xming server.
5. Checking RAM size
grep MemTotal /proc/meminfo (Minimum: 1 GB of RAM).
6. Checking Swap size
grep SwapTotal /proc/meminfo
Swap Space Requirement for Linux
RAM Swap Space
Between 1 GB and 2 GB 1.5 times the size of the RAM
Between 2 GB and 16 GB Equal to the size of the RAM
More than 16 GB 16 GB
7. Checking temp directory.(1 GB of space in the /tmp directory.)
df -h /tmp
8. Checking the Software Requirements
To determine the distribution and version of Linux installed
# cat /etc/oracle-release
# cat /etc/redhat-release

# lsb_release –id
9. Checking system articture.
system architecture
Disk Space Requirements on Linux x86-64
Installation Type Disk Space for Software Files
Enterprise Edition 6.4 GB
Standard Edition 6.1 GB
Standard Edition One 6.1 GB
10. x86-64 Supported Linux 6 Operating System Requirements
Checking kernel articture;
uname -r
Oracle Linux 6 with the Unbreakable Enterprise kernel: 2.6.39-200.24.1.el6uek.x86_64 or later.
11. Packages for Oracle Linux 6 and Red Hat Enterprise Linux 6
The following packages (or later versions) must be installed:
for checking command
rpm -qa|grep package name
binutils-2.20.51.0.2-5.11.el6 (x86_64)
compat-libcap1-1.10-1 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (x86_64)
compat-libstdc++-33-3.2.3-69.el6 (i686)
gcc-4.4.4-13.el6 (x86_64)
gcc-c++-4.4.4-13.el6 (x86_64)
glibc-2.12-1.7.el6 (i686)
glibc-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (x86_64)
glibc-devel-2.12-1.7.el6 (i686)
ksh
libgcc-4.4.4-13.el6 (i686)
libgcc-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (x86_64)
libstdc++-4.4.4-13.el6 (i686)
libstdc++-devel-4.4.4-13.el6 (x86_64)
libstdc++-devel-4.4.4-13.el6 (i686)
libaio-0.3.107-10.el6 (x86_64)
libaio-0.3.107-10.el6 (i686)
libaio-devel-0.3.107-10.el6 (x86_64)
libaio-devel-0.3.107-10.el6 (i686)
libXext-1.1 (x86_64)
libXext-1.1 (i686)
libXtst-1.0.99.2 (x86_64)
libXtst-1.0.99.2 (i686)
libX11-1.3 (x86_64)
libX11-1.3 (i686)
libXau-1.0.5 (x86_64)
libXau-1.0.5 (i686)
libxcb-1.5 (x86_64)
libxcb-1.5 (i686)
libXi-1.3 (x86_64)
libXi-1.3 (i686)
make-3.81-19.el6
sysstat-9.0.4-11.el6 (x86_64)

12. Minimum UnixODBC Driver Manager for Oracle and Red Hat Linux 6 on x86-64
unixODBC-2.2.14-11.el6 (64-bit) or later
unixODBC-devel-2.2.14-11.el6 (64-bit) or later

13. Setup putty.
For particilar session Putty SSH X11 setup must be like this.
14. Start Xming Server.
Click on next->next until finish.
B. Preparation of server Oracle 12c installation.
1. Create Oracle Base directory.
/u01/app/oracle
2. Create Oracle Inventory Directory
/u01/app/oraInventory
# mkdir -p /u01/app/oracle
# chown -R oracle:oinstall /u01/app/oracle
# chmod -R 775 /u01/app/oracle
3. Creating the OSDBA Group for Database Installations
/usr/sbin/groupadd -g 54322 dba
4. Creating an OSOPER Group for Database Installations
/usr/sbin/groupadd -g 54323 oper
5. Creating the OSBACKUPDBA Group for Database Installations
/usr/sbin/groupadd -g 54324 backupdba
6. Creating the OSDGDBA Group for Database Installations
/usr/sbin/groupadd -g 54325 dgdba
7. Creating the OSKMDBA Group for Database Installations
/usr/sbin/groupadd -g 54326 kmdba
8. Creating the OSDBA Group for Oracle Automatic Storage Management
/usr/sbin/groupadd -g 54327 asmdba
9. Creating the OSOPER Group for Oracle Automatic Storage Management
/usr/sbin/groupadd -g 54328 asmoper
10. Creating the OSASM Group for Oracle Automatic Storage Management
/usr/sbin/groupadd -g 54329 asmadmin
11. To create an oracle user, enter a command similar to the following
/usr/sbin/useradd -u 54321 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba oracle
12. Set the password of the oracle user
passwd oracle

13. Modifying an Existing Oracle Software Owner User
/usr/sbin/usermod -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,oper oracle
 14. Checking Resource Limits for Oracle Software Installation Users
Installation Owner Resource Limit Recommended Ranges
Resource Shell Limit Resource Soft Limit Hard Limit
Open file descriptors nofile at least 1024 at least 65536
Number of processes available
to a single user nproc at least 2047 at least 16384
Size of the stack segment
of the process stack at least 10240 KB at least 10240 KB,
and at most 32768 KB

15. Check the soft and hard limits for the file descriptor setting.
$ ulimit -Sn
1024
$ ulimit -Hn
65536
Check the soft and hard limits for the number of processes available to a user.
$ ulimit -Su
2047
$ ulimit -Hu
16384
Check the soft and hard limits for the number of processes available to a user.
$ ulimit -Su
2047
$ ulimit -Hu
16384
Check the soft limit for the stack setting.
$ ulimit -Ss
10240
$ ulimit -Hs
32768

Repeat this procedure for each Oracle software installation owner.
If necessary, update the resource limits in the /etc/security/limits.conf configuration file for the installation owner
C. Starts Installation Oracle 12c Database.
Step 1. Check Display. Type in $ prompt xclock.
Export Home path
Export ORACLE_BASE=/u01/app/oracle
Export ORACLE_HOME=/u01/app/oracle/product/12.0.0/dbhome_1
 Step 2. Select the path where oracle software is kept and then run
./runInstaller
 Step 3. System details screen will appear.
Step 4. Configure security update screen will appear. Click on next after unselect security updates.
If you select this option you will get security updates from oracle website.
 Click on yes.
 Step 5. Select skip software updates If you don’t want updates and click on next.
Step 6. Select Installation option screen will appear.
I have selected Install database software only.

 Step 7. Select language and click next.
Step 8. Select the database edition.
Step 9. Specify the installation location.
 Step 10. Specify the inventory location.
 Step 11. Specify the operating system groups.
 Step 12. Performing pre-requisites checks.
 Step 13. If any check failed screen appears then like this.
 Step 14. Click on fix again.
 Step 15. Execute fixup script will appear copy script file location and run it with root user.
Run the script generated after clicking on fixup through root user.

Step 16. After that click on ok all pre-check will succeed.

 Step 17. Summary screen will appear. Click on Install.
 Step 18. Installation starts.
 Installation at 83%.
 Step 19. Run the root script with root user.

 Step 20. And finally Oracle Database 12c installation completes.

======================================================================== Thanks, 
Regards,

Tapas Kumar Karmakar.

Friday, May 31, 2013

Analysis on "hidden parameter optimizer_skip_scan_enabled"

optimizer_skip_scan_enabled = false.
I have done a little bit observation on this parameter and find some
think different with and without this parameter.

Steps:

1) Create a table.
2) Create composite index on table.
3) Runned query with two different values of
optimizer_skip_scan_enabled. As true and false.

Observation.

1) If we take optimizer_skip_scan_enabled as false.
   Then query is taking Index_range_scan as a result of which it is
consuming huge number of rows for giving the output.
2) And if we take optimizer_skip_scan_enabled as true.
   Then query is taking Index_skip_scan and output is coming by
traversing only 1 row.

Analysis:
Hidden parameter _optimizer_skip_scan_enabled Explanation.
==========================================================

alter session set "_optimizer_skip_scan_enabled"=false;

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  9hk2mp74npcn8, child number 0
-------------------------------------
select /* abc */ S,U,T,E,W,TODAY_DATE 
from test where EMP_ID='22608' and EXE_NAME='XYZ' and H='AB000Z'

Plan hash value: 3441529208

------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |                  |       |       |     1 (100)|          |
|*  1 |  TABLE ACCESS BY INDEX ROWID| TEST             |     1 |    46 |     1   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | IDX_TEST_H       |   152 |       |     1   (0)| 00:00:01 |
------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter(("EMP_ID"='22608' AND "EXE_NAME"='XYZ'))
   2 - access("H"='AB000Z')


22 rows selected.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

alter session set "_optimizer_skip_scan_enabled"=true;

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  awvqwbdn4zy12, child number 0
-------------------------------------
select /* def */ S,U,T,E,W,TODAY_DATE 
from test where EMP_ID='22608' and EXE_NAME='XYZ' and H='AB000Z'
Plan hash value: 2342613384

-------------------------------------------------------------------------------------------------
| Id  | Operation                   | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |                   |       |       |     1 (100)|          |
|*  1 |  TABLE ACCESS BY INDEX ROWID| TEST              |     1 |    46 |     1   (0)| 00:00:01 |
|*  2 |   INDEX SKIP SCAN           | IDX_TEST_L |     1 |       |     1   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("HOME_SOL_ID"='AB000Z')
   2 - access("EMP_ID"='22608' AND "EXE_NAME"='XYZ')
       filter(("EMP_ID"='22608' AND "EXE_NAME"='XYZ'))

=====================================================================================

index_details
==================
SQL> select index_name,column_name,column_position from dba_ind_columns where table_name='TEST';

INDEX_NAME                     COLUMN_NAM COLUMN_POSITION
------------------------------                         ---------- ---------------
IDX_TEST_L               R_ID                  1
IDX_TEST_L               EMP_ID                2
IDX_TEST_L               EXE_NAME              3
IDX_TEST_LO           S_ID                  1
IDX_TEST_LO           EMP_ID                2
IDX_TEST_HS               H_ID                  1
                               

table details
==================
SQL> desc test
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 S                                         VARCHAR2(15)
 U                                         VARCHAR2(15)
 T                                         VARCHAR2(2)
 E                                         VARCHAR2(10)
 W                                         VARCHAR2(8)
 EXE_NAME                                  VARCHAR2(25)

Thursday, May 23, 2013

ORACLE DATABASE UPGRADE PLAN FROM VERSION 10.2.0.4 TO 11.2.0.2 ON HP-UX V3.

ORACLE DATABASE UPGRADE PLAN FROM VERSION 10.2.0.4 TO 11.2.0.2 ON HP-UX V3.
==============================================





Oracle Database Upgrade plan.
Prepared by: Tapas Kumar Karmakar.
Designation: Oracle DBA.
Base Version: 10.2.0.4
Upgraded Version:  11.2.0.2
Metalink ID: 837570.1 and 560336.1




Table of Contents





                           
This document includes the steps for upgrading database from oracle 10g to 11g on HP-UX V3 platform.
For creating this document guide lines has been taken from Oracle Metalink ID: 837570.1,,560336.1  and Oracle DBA: Suvajit Maity & Sunil Ghate.
It includes the Pre-requisites, Steps for manual upgrade of database from 10g to 11g R2 and also the rollback plan.


The main objective of this plan is to provide a detailed plan for manual up gradation of Oracle database. This is a base document which can be followed in any HP-UX V3 server, where database migration is required from Oracle 10.2.0.4 to Oracle 11.2.0.2.


Sr No
Activity
1
At least 1GB free space in /tmp directory.


2
Approx 7.5 GB space for Oracle 11g binaries


3
Operating System requirements

Verify that the system meets the minimum patch bundle requirements using the  following command:
/usr/sbin/swlist -l bundle |grep QPK

Compiler requirements Pro*C/C++, OracleCall Interface, Oracle C++ Call Interface, and Oracle XML Developer’s Kit (XDK) with Oracle Database 11g Release 2 (11.2):
A.06.20 (HP C/aC++ Swlist Bundle - C.11.31.04) - Sep 2008



Patch Requirement

PHCO_41479 11.31 Disk Owner Patch
PHKL_38038 VM patch - hot patching/Core file creation directory
PHKL_38938 11.31 SCSI cumulative I/O patch
PHKL_40941 Scheduler patch: post wait hang
PHSS_36354 11.31 assembler patch
PHSS_37042 11.31 hppac (packed decimal)
PHSS_37959 Libcl patch for alternate stack issue fix (QXCR1000818011)
PHSS_39094 11.31 linker + fdp cumulative patch
PHSS_39100 11.31 Math Library Cumulative Patch
PHSS_39102 11.31 Integrity Unwind Library
PHSS_38141 11.31 aC++ Runtime
PHSS_39824 - 11.31 HP C/aC++ Compiler (A.06.23) patch                                                                                                                               PHSS_41674
PHSS_41683















4
Kernal parameter settings
Note: If current kernal parameter is greater than or equal to given values then there is no need to change the parameter values.Kindly inform this to UNIX Team. (Kernel Parameter are the Minimum Level Will be Subject to change according to Setup)

Parameter Recommended Formula or Value

ksi_alloc_max 32768

executable_stack 0

max_thread_proc 1024

maxdsiz 1073741824 (1 GB)

maxdsiz_64bit 2147483648 (2 GB)

maxssiz 134217728 (128 MB)

maxssiz_64bit 1073741824 (1 GB)

maxuprc 3686

msgmni 4096

msgtql 4096

ncsize 35840

maxfiles_lim 63488

maxfiles 1024

nflocks 4096

ninode 34816

nkthread 7184

nproc 4096

semmni 4096

semmns 8192

semmnu 4092

semvmx 32767

shmmax 1073741824

shmmni 4096

shmseg 512

tcp_smallest_anon_port 9000

tcp_largest_anon_port 65500

udp_smallest_anon_port 9000

udp_largest_anon_port 65500


Sr. No.
Steps
Actions
command
Remarks
1
OS Pre-Requisite
Complete all the Pre-Requisite before preceding the activity. (Refer Pre-Requisite Work Sheet)


2
Oracle Pre-Requisite
Login as oracle user
sudo su - oracle



Create Oracle 11g home directory in existing oracle file system. E.g. /oracle
cd /oracle
mkdir ora11g



Change the ownership of ora11g directory
chown oracle:dba ora11g

3
Installed Oracle 11g Binaries
Use oracle 11g home directory path to installed oracle binaries.
export ORACLE_HOME=/oracle/ora11g
Use Xmanager to installed oracle binaries.
4
Stop log shipping
login into the Primary database and defer log_archive_dest_state_2 parameter.
sql> alter system set log_archive_dest_state_2=defer scope=both;

5
Cancel Recovery at standby database.
login into the standby database and cancel the recovery.
sql> alter database recover managed standby database cancel;

6
Check INVALID  components/objects.
Ensure that all database components/objects are VALID  in the source database  prior to starting the upgrade.
sql> select OWNER,OBJECT_NAME,OBJECT_TYPE,STATUS from dba_objects where STATUS='INVALID';



If found invalid objects kindly run utlrp.sql script located at $ORACLE_HOME/rdbms/admin
sql> @?/rdbms/admin/utlrp.sql

7
Check the duplicate objects in SYS and SYSTEM schema
Ensure that you do not have duplicate objects in the SYS and SYSTEM schema.
Note: The following objects are permissible duplicate objects:
OBJECT_NAME                                    OBJECT_TYPE
AQ$_SCHEDULES                                 TABLE
AQ$_SCHEDULES_PRIMARY                INDEX
DBMS_REPCAT_AUTH                         PACKAGE
DBMS_REPCAT_AUTH                         PACKAGE BODY
column object_name format a30
sql> select object_name, object_type  from dba_objects where object_name||object_type in (select object_name||object_type  from dba_objects where owner = 'SYS') and owner = 'SYSTEM';

8
Generate script to drop duplicate objects.
Generate script to drop duplicate objects other than permissible duplicate objects.
Refer DROP_Duplicate_Obj worksheet to generate script.



Kindly run the script dropsys.sql with system user.
conn system/<password>
sql>@dropsys.sql

9
Record DB Link information if any.



Generate Dblink Script, in case the database has to be downgraded again.
spool dblink.sql
SELECT 'CREATE '||DECODE(U.NAME,'PUBLIC','public ')||'DATABASE LINK '||CHR(10)
||DECODE(U.NAME,'PUBLIC',Null, 'SYS','',U.NAME||'.')|| L.NAME||chr(10)
||'CONNECT TO ' || L.USERID || ' IDENTIFIED BY "'||L.PASSWORD||'" USING
'''||L.HOST||''''||chr(10)||';' TEXT
FROM SYS.LINK$ L, SYS.USER$ U WHERE L.OWNER# = U.USER#;
spool off

10
Cold Backup
Perform cold backup of database as well as oracle 10g binaries (DC/DR)
export ORACLE_HOME=<10g oracle_home>
sqlplus "/as sysdba"
shut immediate;

11
Run Pre-Upgrade step
Startup the database with old oracle home i.e. oracle10g  and run the Upgrade steps.
export ORACLE_HOME=<10g oracle_home>
sqlplus "/as sysdba"
startup
spool Before_Upgrd.sql
sql>@/oracle/ora11g/rdbms/admin/utlu112i.sql
spool off

12
Check Schemas with Stale Statistics
check_stale_stats.sql script will be primarily used during database upgrade before starting the actual upgrade. Execution of this script will report stale statistics if any. It reports on schemas which are part of DBA_REGISTRY as these are the ones which are upgraded. If it finds any stale statistics it will give the recommended commands to remove those stale statistics.
Run the script as sys user take the spool for the same.
Script kept at : /oracle/check_stale_stats.sql
sqlplus "/as sysdba"
spool chk_stale_stat.log
sql> @/oracle/check_stale_stats.sql
spool off

13
Collect Optimizer Statistics
collect Optimizer Statistics by running the command as sys user
sqlplus "/as sysdba"
sql> EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;

14
Check datafiles status
Ensure that no files need media recovery and that no files are in backup mode.
sql>SELECT * FROM v$recover_file;
sql>SELECT * FROM v$backup WHERE status != 'NOT ACTIVE';
Note: This should return no rows.

15
Create pfile from spfile
Create pfile from spfile and stored in New Oracle Home (11g)
sqlplus "/as sysdba"
sql> create pfile='<NEW_ORACLE_HOME/dbs/init<oracle_sid>.ora' from spfile;

16
Remove Parameters from pfile.
Remove the USER_DUMP_DEST, BACKGROUND_DUMP_DEST parameters and set DIAGNOSTIC_DEST='/oracle/11g/app' parameter from parameter file.
cd /oracle/ora11g/dbs
vi init<oracle_sid>.ora
Note: Remove deprecated parameters and set new parameters.

17
Shutdown database and listener

sqlplus "/as sysdba"
sql> shut immediate
exit
$ lsnrctl stop <Listener_Name>

18
set the enviornment
Set the enviorment which points to 11g binaries.
export ORACLE_HOME=/oracle/ora11g
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE=/oracle

19
Startup database in upgrade mode
Start the database in upgrade mode
sqlplus "/ as sysdba"
sql> startup UPGRADE;

20
Run Upgrade script

Spool upgrade.log
sql>@?/rdbms/admin/catupgrd.sql
spool off
Check for errors if any
21
Shutdown database

sql>shut immediate

22
Startup database

sql>startup

23
Run object validation script
After upgrade If any invalid objects found, run "utlrp" script.
sql>@?/rdbms/admin/utlrp.sql

24
Run post upgrade script

sql>@?/rdbms/admin/utlu112s.sql



Refresh AWR views

sql>@?/rdbms/admin/catuppst.sql

25
Copy tns and listener files.
Start the listener
copy the old tnsnames.ora and listener.ora from old oracle_home to oracle 11g oracle_home
cp tnsnames.ora /oracle/ora11g
cp listener.ora /oracle/ora11g

lsnrctl start LISTENER

26
Database components
Check whether all the componants are upgraded to 11g
sql>select COMP_NAME,VERSION from dba_registry;

27
User profile
Change in user profile of oracle
Make changes in .prfile file add entries specific to oracle 11g.
export ORACLE_HOME=/oracle/ora11g
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE=/oracle




Check Stale object script and output.
-- - - - - - - - - - - - - - - - - - - - - - - - - Script begins here - - - - - - - - - - - - - - - - - - - - - - - - - -
--  NAME:  CHECK_STALE_STATS.SQL
--   Execute as SYS as sysdba
-- ----------------------------------------------------------------------------------------------------------------
-- AUTHOR: 
--    Raja Ganesh - Oracle Support Services - DataServer Group
--    Copyright 2008, Oracle Corporation     
-- -----------------------------------------------------------------------------------------------------------------
-- PURPOSE:
-- This script is an automated way to deal with stale statistics
-- operations that are required to be done as part of manual
-- upgrade OR when reported by DBUA.
--
-- This script will work in both Windows and Unix platforms from database
-- version 9.2 or higher.
-- ------------------------------------------------------------------------------------------------------------------
-- DISCLAIMER:
--    This script is provided for educational purposes only. It is NOT 
--    supported by Oracle World Wide Technical Support.
--    The script has been tested and appears to work as intended.
--    You should always run new scripts on a test instance initially.
-- -------------------------------------------------------------------------------------------------------------------
SET FEEDBACK OFF
SET LINESIZE 250
SET SERVEROUTPUT ON

DECLARE
-- Variables declared
P_OTAB DBMS_STATS.OBJECTTAB;
MCOUNT NUMBER := 0;
P_VERSION VARCHAR2(10);
-- Cursor defined
CURSOR c1
IS
SELECT distinct schema
FROM dba_registry
ORDER by 1;

-- Beginning of the anonymous block
BEGIN
-- Verifying version from v$instance
SELECT version INTO p_version FROM v$instance;
DBMS_OUTPUT.PUT_LINE(chr(13));
-- Defining Loop 1 for listing schema which have stale stats
FOR x in c1
LOOP
DBMS_STATS.GATHER_SCHEMA_STATS(OWNNAME=>x.schema,OPTIONS=>'LIST STALE',OBJLIST=>p_otab);

-- Defining Loop 2 to find number of objects containing stale stats
FOR i in 1 .. p_otab.count
LOOP
IF p_otab(i).objname NOT LIKE 'SYS_%'
AND p_otab(i).objname NOT IN ('CLU$','COL_USAGE$','FET$','INDPART$',
'MON_MODS$','TABPART$','HISTGRM$',
'MON_MODS_ALL$',
'HIST_HEAD$','IN $','TAB$',
'WRI$_OPTSTAT_OPR','PUIU$DATA',
'XDB$NLOCKS_CHILD_NAME_IDX',
'XDB$NLOCKS_PARENT_OID_IDX',
'XDB$NLOCKS_RAWTOKEN_IDX', 'XDB$SCHEMA_URL',
'XDBHI_IDX', 'XDB_PK_H_LINK')
THEN
-- Incrementing count for  each object found with statle stats
mcount := mcount + 1;
END IF;
-- End of Loop 2
END LOOP;

-- Displays no stale statistics, if coun  is 0
IF mcount!=0
THEN
-- Displays Schema with stale stats if count is greater than 0
DBMS_OUTPUT.PUT_LINE(chr(13));
DBMS_OUTPUT.PUT_LINE('-------------------------------------------------------------------------------------------------------');
DBMS_OUTPUT.PUT_LINE('-- '|| x.schema || ' schema contains stale statistics use the following to gather the statistics '||'--');
DBMS_OUTPUT.PUT_LINE('-------------------------------------------------------------------------------------------------------');
                                               
-- Displays Command to be executed if schema with stale statistics is found depending on the version.
IF SUBSTR(p_version,1,5) in ('8.1.7','9.0.1','9.2.0')
THEN
DBMS_OUTPUT.PUT_LINE(chr(13));
DBMS_OUTPUT.PUT_LINE('EXEC DBMS_STATS.GATHER_SCHEMA_STATS('''||x.schema||''',OPTIONS=>'''||'GATHER STALE'||''',
ESTIMATE_PERCENT  => DBMS_STATS.AUTO_SAMPLE_SIZE, METHOD_OPT => '''||'FOR ALL COLUMNS SIZE AUTO'||''', CASCADE => TRUE);');
ELSIF SUBSTR(p_version,1,6) in ('10.1.0','10.2.0','11.1.0','11.2.0')
THEN
DBMS_OUTPUT.PUT_LINE(chr(13));
DBMS_OUTPUT.PUT_LINE('EXEC DBMS_STATS.GATHER_DICTIONARY_STATS('''||x.schema||''',OPTIONS=>'''||'GATHER STALE'||''',
ESTIMATE_PERCENT  => DBMS_STATS.AUTO_SAMPLE_SIZE, METHOD_OPT => '''||'FOR ALL COLUMNS SIZE AUTO'||''', CASCADE => TRUE);');
ELSE
DBMS_OUTPUT.PUT_LINE(chr(13));
DBMS_OUTPUT.PUT_LINE('Version is '||p_version);
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE('-- There are no stale statistics in '|| x.schema || ' schema.');
DBMS_OUTPUT.PUT_LINE(chr(13));
END IF;
-- Reset count to 0.
mcount := 0;
-- End of Loop 1
END LOOP;
END;
/

SET FEEDBACK ON

-- - - - - - - - - - - - - - - - - - - - - - - - - Script ends here - - - - - - - - - - - - - - - - - - - - - - - - - -

SCRIPT OUTPUT:

SQL> @check_schema_stale_stats.sql

-- There are no stale statistics in CTXSYS schema.

-- There are no stale statistics in DMSYS schema.

-- There are no stale statistics in EXFSYS schema.

-- There are no stale statistics in MDSYS schema.

-- There are no stale statistics in OLAPSYS schema.

-- There are no stale statistics in ORDSYS schema.

-------------------------------------------------------------------------------------------------------
-- SYS schema contains stale statistics use the following to gather the statistics --
-------------------------------------------------------------------------------------------------------
EXEC DBMS_STATS.GATHER_DICTIONARY_STATS('SYS',OPTIONS=>'GATHER', ESTIMATE_PERCENT => DBMS_STATS.AUTO_SAMPLE_SIZE,
METHOD_OPT => 'FOR ALL COLUMNS SIZE AUTO', CASCADE => TRUE);

-- There are no stale statistics in SYSMAN schema.

-- There are no stale statistics in WMSYS schema.

-- There are no stale statistics in XDB schema.




Steps for identifying duplicate objects ,with related error and remedy for fixing those errors.
set pause off
set heading off
set pagesize 0
set feedback off
set verify off
spool dropsys.sql
select 'DROP ' || object_type || ' SYSTEM.' || object_name || ';'
from dba_objects
where object_name||object_type in
   (select object_name||object_type 
    from dba_objects
    where owner = 'SYS')
and owner = 'SYSTEM';
spool off
exit
Note: You may receive one or more of the following errors:
ORA-2266 (unique/primary keys in table referenced by enabled foreign keys):  If you encounter this error then some of the tables you are dropping have constraints that prevent the table from being dropped. To fix this problem you will have to manually drop the objects in a different order than the script does.
     
ORA-2429 (cannot drop index used for enforcement of unique/primary key): This is similar to the ORA-2266 error except that it points to an index. You will have to manually disable the constraint associated with the index and then drop the index.

ORA-1418 (specified index does not exist):
 This occurs because the table that the index was created on  has already been dropped  which also drops the index. When the script tries to drop the index it is no longer there  and thus the ORA-1418 error. You can safely ignore this error.





Note: Upgrade DR database after getting confirmation from customer about successful upgrade of primary database.

Sr. No.
Steps
Actions
command
Remarks
1
OS Pre-Requisite
Complete all the Pre-Requisite before proceeding the activity. (Refer Pre-Requisite Work Sheet)


2
Oracle Pre-Requisite
Login as oracle user
sudo su - oracle



Create Oracle 11g home directory in existing oracle file system. E.g. /oracle
cd /oracle
mkdir ora11g



Change the ownership of ora11g directory
chown oracle:dba ora11g

3
Installed Oracle 11g Binaries
Use oracle 11g home directory path to installed oracle binaries.
export ORACLE_HOME=/oracle/ora11g
Use Xmanager to installed oracle binaries.

Stop Listener services

lsnrctl stop LISTENER


Stop database

shutdown immediate;


Set enviornment varaibles


export ORACLE_HOME=<location of Oracle 11.2>
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE=<Oracle_Base set during installation>


Configure listener & start listener

change oracle home entry in listner.ora
lsnrctl start LISTENER


Start database
Open database in mount mode
sql>startup mount


Start recovery

sql>alter database recover managed standby database disconect from session;





Sr. No.
Steps
Actions
command
Remarks
1
Stop Listener services of 11g

lsnrctl stop LISTENER

2
Stop 11g database

shutdown immediate;

3
Set environment variables of 10g


export ORACLE_HOME=<location of Oracle 10g>
export PATH=$ORACLE_HOME/bin:$PATH

4
Restore backup



5
Start 10g listener

lsnrctl start LISTENER

6
Start database
Open database in read write mode
sql>startup





Note: This plan is already tested in HP_UX V3 and Linux platform and working fine without any issue. 






           --------------------------------------------------------End Of Activity-----------------------------------------------------------