Saturday, February 27, 2016

How to Upgrade Oracle Database 11.2.0.1 to 11.2.0.4 ?

Upgrade Oracle Database 11g
=================================================
===============


Database upgrade important part of DBA life . So when doing upgrade database we make note some important point :-

1. Verify all the prerequisite h/w  and s/w  for target version .
2. Use out of place upgrade method (recommended by oracle  ) 
3. Take backup of existing database which going to upgrade and  keep backup  if possible on another     server (mount point  like /bkp)
   use RMAN (Recovery manager) to take full  backup of database 





 Step 1:
============

Download Software from Oracle site.

Oracle Database (includes Oracle Database and Oracle RAC)
Note: you must download both zip files to install Oracle Database.
p13390677_112040_platform_1of7.zip
p13390677_112040_platform_2of7.zip
Oracle Grid Infrastructure (includes Oracle ASM, Oracle Clusterware, and Oracle Restart)p13390677_112040_platform_3of7.zip
Oracle Database Clientp13390677_112040_platform_4of7.zip
Oracle Gatewaysp13390677_112040_platform_5of7.zip
Oracle Examplesp13390677_112040_platform_6of7.zip
Deinstallp13390677_112040_platform_7of7.zip


We need for Database:


p13390677_112040_platform_1of7.zipp13390677_112040_platform_2of7.zip


After unzip  the downloaded software :-

unzip  p13390677_112040_platform_1of7.zip
unzip p13390677_112040_platform_2of7.zip




Step 2:
==================

Click on runInstaller and install software  with new oracle home 





Step 3:
=================
After  software install  run pre-check before upgrade on running database using new oracle home  run the prerequisite script


SQL> @/u01/app/oracle/product/11.2.0.4/db_1/rdbms/admin/utlu112i.sql



SQL> !pwd
/u01/app/oracle/product/11.2.0.4/db_1/rdbms/admin

SQL> @/u01/app/oracle/product/11.2.0.4/db_1/rdbms/admin/utlu112i.sql
Oracle Database 11.2 Pre-Upgrade Information Tool 02-27-2016 19:03:18
Script Version: 11.2.0.4.0 Build: 001
.
**********************************************************************
Database:
**********************************************************************
--> name:          FINAL
--> version:       11.2.0.1.0
--> compatible:    11.2.0.0.0
--> blocksize:     8192
--> platform:      Linux x86 64-bit
--> timezone file: V11
.
**********************************************************************
Tablespaces: [make adjustments in the current environment]
**********************************************************************
--> SYSTEM tablespace is adequate for the upgrade.
.... minimum required size: 878 MB
--> SYSAUX tablespace is adequate for the upgrade.
.... minimum required size: 497 MB
--> UNDOTBS1 tablespace is adequate for the upgrade.
.... minimum required size: 400 MB
--> TEMP tablespace is adequate for the upgrade.
.... minimum required size: 60 MB
.
**********************************************************************
Flashback: OFF
**********************************************************************
**********************************************************************
Update Parameters: [Update Oracle Database 11.2 init.ora or spfile]
Note: Pre-upgrade tool was run on a lower version 64-bit database.
**********************************************************************
--> If Target Oracle is 32-Bit, refer here for Update Parameters:
-- No update parameter changes are required.
.

--> If Target Oracle is 64-Bit, refer here for Update Parameters:
-- No update parameter changes are required.
.
**********************************************************************
Renamed Parameters: [Update Oracle Database 11.2 init.ora or spfile]
**********************************************************************
-- No renamed parameters found. No changes are required.
.
**********************************************************************
Obsolete/Deprecated Parameters: [Update Oracle Database 11.2 init.ora or spfile]
**********************************************************************
-- No obsolete parameters found. No changes are required
.

**********************************************************************
Components: [The following database components will be upgraded or installed]
**********************************************************************
--> Oracle Catalog Views         [upgrade]  VALID
--> Oracle Packages and Types    [upgrade]  VALID
--> JServer JAVA Virtual Machine [upgrade]  VALID
--> Oracle XDK for Java          [upgrade]  VALID
--> Oracle Workspace Manager     [upgrade]  VALID
--> OLAP Analytic Workspace      [upgrade]  VALID
--> OLAP Catalog                 [upgrade]  VALID
--> Oracle Text                  [upgrade]  VALID
--> Oracle XML Database          [upgrade]  VALID
--> Oracle Java Packages         [upgrade]  VALID
--> Oracle interMedia            [upgrade]  VALID
--> Spatial                      [upgrade]  VALID
--> Expression Filter            [upgrade]  VALID
--> Rule Manager                 [upgrade]  VALID
--> Oracle Application Express   [upgrade]  VALID
... APEX will only be upgraded if the version of APEX in
... the target Oracle home is higher than the current one.
--> Oracle OLAP API              [upgrade]  VALID
.
**********************************************************************
Miscellaneous Warnings
**********************************************************************
WARNING: --> Database is using a timezone file older than version 14.
.... After the release migration, it is recommended that DBMS_DST package
.... be used to upgrade the 11.2.0.1.0 database timezone version
.... to the latest version which comes with the new release.
WARNING: --> Your recycle bin is turned on and currently contains no objects.
.... Because it is REQUIRED that the recycle bin be empty prior to upgrading
.... and your recycle bin is turned on, you may need to execute the command:
        PURGE DBA_RECYCLEBIN
.... prior to executing your upgrade to confirm the recycle bin is empty.
WARNING: --> Database contains schemas with objects dependent on DBMS_LDAP package.
.... Refer to the 11g Upgrade Guide for instructions to configure Network ACLs.
.... USER APEX_030200 has dependent objects.
.
**********************************************************************
Recommendations
**********************************************************************
Oracle recommends gathering dictionary statistics prior to
upgrading the database.
To gather dictionary statistics execute the following command
while connected as SYSDBA:

    EXECUTE dbms_stats.gather_dictionary_stats;

**********************************************************************
Oracle recommends reviewing any defined events prior to upgrading.

To view existing non-default events execute the following commands
while connected AS SYSDBA:
  Events:
    SELECT (translate(value,chr(13)||chr(10),' ')) FROM sys.v$parameter2
      WHERE  UPPER(name) ='EVENT' AND  isdefault='FALSE'

  Trace Events:
    SELECT (translate(value,chr(13)||chr(10),' ')) from sys.v$parameter2
      WHERE UPPER(name) = '_TRACE_EVENTS' AND isdefault='FALSE'

Changes will need to be made in the init.ora or spfile.

**********************************************************************
SQL>

In  above output all component all valid state and check all recommendation by this script

Check db must be running using spfile



-------------------------
Set the display 

export DISPLAY=yourip :0.0
then run xclock its show popup 

Run the ./runinstaller  from command prompt



We skip this step click on netxt


We not provide support email id then show the error ignore this error click on yes


select Skip software and click on next


For upgrade select install database software only then click on next


As per  environment we select type of database 
In my case stand alone single instance database so we select single instance database installation then click on next 



select the language as  per requirement in my case is English then click on next



Choose  which database edition need to install in my case choose Enterprise Edition
then click on next



Define the Oracle Base and Software directory here we careful  when give directory locations
then click on next

we use new home here
/u01/app/oracle/product/11.2.0/db_1/



Select group then click on next


check prerequisite must be check all package are install and meet software requirement
then click on next


In my case swap alert i am ignore all here but  must be validate in environment
Then click on next


Check all parameter which you give before  parameter you define validate then click next


Here software is almost install then popup  on execute Root Script

We login from root user and run script show on popup
after successful  run root.sh click on ok .


then click on close


This stage software installation done we start upgrade database 

Start Upgrade database
====================


We set some env. variable 
set ORACLE_HOME new oracle oracle home which we install 
set display
$export DISPLAY=yourip:0.0
check umask value should be 022
cd u01/app/oracle/product/11.2.0/db_1//bin

and run ./dbua
check =>umask 022
check =>xclock
Execute dbua from new oracle home


click on next

Here we select which database need to be upgrade then click on next




Check here warning then click on next


Here select appropriate value and degree of parallelism  as per env. here we take 1

if you upgrade time zone tick on timezone  dbua also recommend to take backup if need then ypu specify backup location then click on next




Here choose do not move database files as Part of upgrade

if you move file system to ASM so choose as per requirement
then click on next








check  report after upgrade report all components are show successful .

then you login the database from new ORACLE_HOME

check the /etc/oratab file

change .profile in unix/aix .bash_profile in linux set new oracle home location


Enjoy!!!

ORA-23515: materialized views and/or their indices exist in the tablespace


Make list of  MATERIALIZED  view:
===================================


select 'drop materialized view  '|| a.owner||'.'|| a.object_name || ';' from dba_objects a ,dba_segments b where a.OWNER=b.OWNER and b.TABLESPACE_NAME='MGMT_TABLESPACE'  and object_type='MATERIALIZED VIEW';
drop materialized view SYSMAN.MGMT$ARU_PATCH_RECOM_MD;

ORA-24005: Inappropriate utilities used to perform DDL on AQ table

SQL> drop table SYSMAN.MGMT_LOADER_QTABLE cascade constraints;
                  *
ERROR at line 1:
ORA-24005: Inappropriate utilities used to perform DDL on AQ table SYSMAN.MGMT_LOADER_QTABLE





execute DBMS_AQADM.DROP_QUEUE_TABLE (queue_table => 'SYSMAN.MGMT_NOTIFY_INPUT_QTABLE', force => true);

select 'execute DBMS_AQADM.DROP_QUEUE_TABLE (queue_table => ' ||owner||'.'||table_name||' , force => true) ;' from dba_LOBS WHERE TABLESPACE_NAME='MGMT_TABLESPACE';

Deleted Central Inventory : Re - Create Inventory in Oracle 11gr2

Login As Oracle user

su - oracle

[oracle@test~]$
[oracle@test~]$
[oracle@test~]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/db_1
[oracle@test~]$ echo $ORACLE_SID
TEST
[oracle@test~]$ echo $ORACLE_BASE
/u01/app/oracle
[oracle@test~]$



[oracle@test bin]$
[oracle@test bin]$ pwd
/u01/app/oracle/product/11.2.0/db_1/oui/bin
[oracle@test bin]$
[oracle@test bin]$ ls
addLangs.sh  attachHome.sh  filesList.bat         filesList.sh  resource      runInstaller     runSSHSetup.sh
addNode.sh   detachHome.sh  filesList.properties  lsnodes       runConfig.sh  runInstaller.sh
[oracle@test bin]$
[oracle@test bin]$
[oracle@test bin]$
[oracle@test app]$ ls
Make  oraInventory  oraInventory_old
[oracle@test app]$ ls
oracle    oraInventory_old
[oracle@test app]$
[oracle@test app]$
[oracle@test app]$

=======Attach Oracle Home=================

[oracle@test bin]$ ./runInstaller -silent -attachHome -invPtrLoc /etc/oraInst.loc oracle_home="/u01/app/oracle/product/11.2.0/db_1" ORACLE_HOME_NAME="OraDb11g_home1"
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 2999 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-02-27_11-46-02AM. Please wait ...[oracle@test bin]$ The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'AttachHome' was successful.

[oracle@test bin]$
[oracle@test bin]$
[oracle@test bin]$


====================Attach Grid Home=======================

Login as grid user

su - grid


[grid@e@test ~] cd /u01/app/11.2.0/grid/oui/bin/

[grid@e@test bin ~]$ ./runInstaller -silent -attachHome -invPtrLoc /etc/oraInst.loc oracle_home="/u01/app/oracle/11.2.0/grid" ORACLE_HOME_NAME="Ora11g_gridinfrahome1" 
Starting Oracle Universal Installer…
Checking swap space: must be greater than 500 MB.   Actual 2999 MB    Passed 
The inventory pointer is located at /etc/oraInst.loc 
The inventory is located at /u01/app/oraInventory 
‘AttachHome’ was successful.