Saturday 10 February 2018

Upgrade EBS Database 11.2.0.2 to 12.1.0.2 Steps by Steps..

Install the Oracle 12c Software : -

Using Silent Mode -
======================

./runInstaller -ignoreSysPrereqs -ignorePrereq -force -showProgress -silent -responseFile /oracle_home/PATCH2015/ORACLE_12C/database/install.rsp

Responce file :-
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=Hostname
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/oracle_home/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/oracle_home/app1/orahome
ORACLE_BASE=/oracle_home/app1
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=oinstall
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.BACKUPDBA_GROUP=oinstall
oracle.install.db.DGDBA_GROUP=oinstall
oracle.install.db.KMDBA_GROUP=oinstall
oracle.install.db.isRACOneInstall=false
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES


After Install Start CD  -  p21419221_121020_AIX64-5L_9of10.zip
============================

./runInstaller -ignoreSysPrereqs -ignorePrereq -force -showProgress -silent -responseFile Respons file location..

oracle.install.responseFileVersion=/oracle/install/rspfmt_demosinstall_response_schema_v12.1.0
ORACLE_HOSTNAME=youhostname
UNIX_GROUP_NAME=dba
INVENTORY_LOCATION=/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/home/db/orahome12c
ORACLE_BASE=/oracle/database/base


***************** Do the prerequisits of OLD Database **********************

################################## Check The INVALID objects ##################################
########################################################################################################

SELECT DISTINCT object_name, object_type, owner  FROM dba_objects  WHERE  status='INVALID';

–If any invalid objects
@?/rdbms/admin/utlrp.sql

OR

select count(*) from dba_objects where status='INVALID';
exec utl_recomp.recomp_parallel('8');
select count(*) from dba_objects where status='INVALID';

################################## Staus of DB Components ################################################
########################################################################################################

select substr(COMP_ID, 1,10) compid,substr(COMP_NAME,1,24) compname, STATUS,VERSION from DBA_REGISTRY;

################################## DUPLICATE objects Detail ################################################
########################################################################################################

–Always check for DUPLICATE objects in SYS/SYSTEM

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' and OBJECT_NAME not in ('AQ$_SCHEDULES_PRIMARY','AQ$_SCHEDULES','DBMS_REPCAT_AUTH');

 or

column object_name format a30
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';

–Fix DUPLICATE objects in SYS/SYSTEM BEFORE upgrade
–• Note:1030426.6 How to Clean Up Duplicate Objects Owned by SYS
How to Clean Up Duplicate Objects Owned by SYS and SYSTEM Schema (Doc ID 1030426.6)
–and SYSTEM Schema


##################### VERY IMPORTANT TO RUN THIS SCRIPT!(preupgrd.sql) #################################
########################################################################################################

@$ORACLE_HOME/rdbms/admin/preupgrd.sql

   * Log into the system as the owner of the Oracle Database 12c Release 1 (12.1) Oracle Home directory.
    * Copy the Pre-Upgrade Information Tool script preupgrd.sql and utluppkg.sql from the Oracle Database 12c Release 1 (12.1) $ORACLE_HOME/rdbms/admin directory to  the $ORACLE_HOME/rdbms/admin directory of the source Oracle Home.

  Step 2:

     * Run the new Pre-Upgrade Information Tool. For example, if you copied preupgrd.sql to the /admin directory of the source Oracle Home:
SQL> @$ORACLE_HOME/rdbms/admin/preupgrd.sql

preupgrade.log, preupgrade_fixups.sql and postupgrade_fixups.sql files are created in $ORACLE_HOME/cfgtoollogs/$ORACLE_SID/preupgrade/, which is under the source database ORACLE_HOME to be upgraded.




Ensure that no files need media recovery and that no files are in backup mode.


SELECT * FROM v$recover_file;
SELECT * FROM v$backup WHERE status != 'NOT ACTIVE';

########################################################################################################
################################## Distributed Transactions  Check ################################################
########################################################################################################

Resolve outstanding distributed transactions prior to the upgrade.
SQL> select * from dba_2pc_pending;


If this returns rows you should do the following:
SQL> SELECT local_tran_id
     FROM dba_2pc_pending;

If exist the disable

SQL> EXECUTE dbms_transaction.purge_lost_db_entry('');
SQL> COMMIT;

or

SQL >rollback force 'local_tran_id' ;
SQL> COMMIT;

########################################################################################################
################################## Standby Database  Check ################################################
########################################################################################################

To check if a standby database exists, issue the following query:

SELECT SUBSTR(value,INSTR(value,'=',INSTR(UPPER(value),'SERVICE'))+1)
FROM v$parameter
WHERE name LIKE 'log_archive_dest%' AND UPPER(value) LIKE 'SERVICE%';


If this query returns a row, then sync the standby database with the primary database.
1. Make sure all the logs are transported to the standby server after a final log switch
in the primary.
2. Start the recovery of the standby database with the NODELAY option.

######################################################################################    ##################
################################## Disbale All Jobs ################################################
########################################################################################################

Disable all batch and cron jobs.

About jobs initiated with Oracle the packages DBMS_JOB, DBMS_SCHEDULER can be used

select * from DBA_SCHEDULER_JOBS;
select * from  DBA_JOBS;

[edit]Enable / Disable a job

BEGIN 
  DBMS_SCHEDULER.ENABLE('myjob');
END;
/
BEGIN 
  DBMS_SCHEDULER.DISABLE('myjob');
END;
/

########################################################################################################
################################## Sys n System Default Tablespace ################################################
########################################################################################################

Ensure the users SYS and SYSTEM have 'SYSTEM' as their default tablespace.
You must have sufficient space in the tablespace or be set to extents unlimited.

SQL> SELECT username, default_tablespace FROM dba_users  WHERE username in ('SYS','SYSTEM');


If DEFAULT_TABLESPACE is anything other than SYSTEM tablespace, modify the default tablespace to SYSTEM by using the below command.

SQL> ALTER user SYS default tablespace SYSTEM;
SQL> ALTER user SYSTEM default tablespace SYSTEM;


########################################################################################################
################################## Aud$ Tablespace Check ################################################
########################################################################################################

Ensure that if the aud$ table exists that it is in the SYS schema and in the SYSTEM tablespace.

SQL> SELECT owner,tablespace_name
     FROM dba_tables
     WHERE table_name='AUD$';

########################################################################################################
############################# Check whether database has any externally authenticated SSL users ##################################
########################################################################################################

SQL> SELECT name FROM sys.user$
     WHERE ext_username IS NOT NULL
     AND password = 'GLOBAL';


########################################################################################################
################################## Purging of Recyclebin n Aud$ ################################################
########################################################################################################

Purge the Recyclebin as well as Truncate the Aud$ table after backup( Note:- &&& Use the Doc Final Audit Purging Script)...

purge DBA_RECYCLEBIN;
Truncate table aud$;


########################################################################################################
################################## Remove Enterprise Manager  Database Control repository ################################################
########################################################################################################
%%%%%%%%%%%%%%% this is not needed %%%%%%%%%%%%%%%%%%%%%%%%%%%

Enterprise Manager Database Control is superseded in 12c by Oracle Enterprise Manager Express .

     Therefore no repository is needed anymore .

     Remove  Enterprise Manager  Database Control  repository MANUALLY using the following command

     Note : You will get the emremove.sql script in the Oracle 12c home .

    Copy the emremove.sql script from the 12c $ORACLE_HOME/rdbms/admin to the source $ORACLE_HOME/rdbms/admin and then execute on the source database prior to upgrade.

$emctl stop dbcontrol

SQL> @?/rdbms/admin/emremove.sql

  If the EM repository is not removed up front ,it will be automatically removed during the catuppst.sql post-upgrade phase.

########################################################################################################
################################## Run olspreupgrade.sql ################################################
########################################################################################################
%%%%%%%%%%%%%%% this is not needed %%%%%%%%%%%%%%%%%%%%%%%%%%%

If  OLS(Lable Security) and/or DV ( Database Vault) was already in the  database prior to the upgrade then execute the following steps on Source database prior to upgrade
Note : You will get the olspreupgrade.sql script in the Oracle 12c home .
Copy the olspreupgrde.sql script from the 12c $ORACLE_HOME/rdbms/admin to the source $ORACLE_HOME/rdbms/admin and then execute on the source database prior to upgrade.
SQL> @?/rdbms/admin/olspreupgrade.sql

   - It prepares the move of AUD$ table from SYSTEM to SYS.

   - It processes the audit records to minimize downtime.

   - It moves records to an Interim temporary table.

See  Requirements for Upgrading Databases That Use Oracle Label Security and Oracle Database Vault for complete information


########################################################################################################
############# Drop Oracle 12c  Release 1 supplied users and roles ,if exist in the source database #########
Note :- Its not required in our case as we are upgrading from 12.1.0.1
########################################################################################################
%%%%%%%%%%%%%%% this is not needed %%%%%%%%%%%%%%%%%%%%%%%%%%%

There are new Oracle users and roles in Oracle 12.1.  If there exist in the source database users or roles with the same names, then they must be dropped before upgrading the database.

Run the preupgrade tool to check for the existence of any users or roles in the source database that use the same names.

Note: If there is a pre-existing user in the database with same name as the 12.1 oracle-supplied users or roles, then move the data of that user to a different schema before dropping the pre-existing user.

Make sure to drop these pre-existing users and/or roles before doing the upgrade.  Else, the upgrade will terminate will with "ORA-01722: invalid number"  error.

########################################################################################################
################## Review and Remove any unnecessary hidden/underscore parameters ######################
########################################################################################################

Please review and remove any unnecessary hidden/underscore parameters prior to upgrading. It is strongly recommended that these be removed before upgrade

unless your application vendors and/or Oracle Support state differently.Changes will need to be made in the init.ora or spfile.
To view existing hidden parameters execute the following command while connected AS SYSDBA:


SQL> SELECT name, value from SYS.V$PARAMETER WHERE name LIKE '\_%' ESCAPE '\' order by name;


########################################################################################################
################## Check the XDB ACLs has start_date and end_date ACE attributes ######################
########################################################################################################

Before upgrading the database to 12c, please run the below query as SYS:

SQL> select aclid, start_date, end_date from xds_ace where start_date is not null; 

If the query returns any row, then please follow Note 1958876.1 Upgrade to 12.1 fails with ORA-01830 date format picture ends before converting entire input string ORA-06512: at "SYS.XS_OBJECT_MIGRATION"  to avoid failure in XDB's upgrade.

########################################################################################################
###### Check the Mitigation patch has been applied on the source Oracle home ######################
NOTE : This step is ONLY applicable if you have applied  Mitigation Patch  on the source database
########################################################################################################
%%%%%%%%%%%%%%% this is not needed %%%%%%%%%%%%%%%%%%%%%%%%%%%
Check the Mitigation patch has been applied on the source Oracle home ,it disables the Java development in the Database which cause error during upgrade

NOTE : This step is ONLY applicable if you have applied  Mitigation Patch  on the source database

Please "enable" the Java development in source database .
Connect to the database as a SYSDBA user
  SQL> exec dbms_java_dev.enable;

And then upgrade the database.

Please refer Note 1985725.1 Database Upgrade failed with Errors “ORA-02290: check constraint (SYS.JAVA_DEV_DISABLED) violated” & “ORA-04045: SYS.DBMS_ISCHED”

########################################################################################################
################################## Shutdown the DB,Listener n OEM ################################################
########################################################################################################

Stop Listener
shutdown immediate
stop oracle agent if running OEM
exit

################################## Unset Variables ################################################
########################################################################################################

-Undefine all the defined oracle parameters.
In my case i undefined the below parameters:
unset ORACLE_BASE
unset ORACLE_SID
unset ORA_NLS10
unset TNS_ADMIN
unset ORACLE_HOME
unset ORA_CRS_HOME
unset CRS_HOME

########################################################################################################
################################## Export New Oracle Home ################################################
########################################################################################################

— Make sure oracle_home is new home

echo $ORACLE_BASE
echo $ORACLE_SID
echo $ORA_NLS10
echo $TNS_ADMIN
echo $ORACLE_HOME
echo $ORA_CRS_HOME
echo $CRS_HOME


–START USING NEW ORACLE HOME
export ORACLE_HOME=/u01/app/oracle/11.2.0.4
in bash_profile set it to new oracle home. logout and log back in again

orapwd file=orapw$SID password=oracle entries=40

vi /etc/oratab
/u01/app/oracle/11.2.0.4

vi /u01/app/oracle/admin/${ORACLE_SID}/pfile/upgrade_11.2.0.4.pfile

sqlplus "sys/nopass as sysdba"
create spfile from pfile = ‘/u01/app/oracle/admin/${ORACLE_SID}/pfile/upgrade_11.2.0.4.pfile';

–Make sure there is enough archive log space


########################################################################################################
##################### Startup Upgrade n Cat Upgrade(Upgrading Database to 12cR1) ########################
########################################################################################################
instead $ORACLE_HOME user full path


$ cd $ORACLE_HOME/rdbms/admin
$ sqlplus "/ as sysdba"
SQL> startup UPGRADE
SQL> exit

–THIS IS THE UPGRADE
–Takes about 30 minutes to run
show parameter cluster

$ORACLE_HOME/perl/bin/perl /oracle_home12c/db/orahome12c/rdbms/admin/catctl.pl -n  6 -l /oracle_home12c/db/orahome12c/rdbms/admin catupgrd.sql

$ORACLE_HOME/rdbms/admin/perl catctl.pl -n  6 -l $ORACLE_HOME/rdbms/admin catupgrd.sql
/oracle_home12c/db/orahome12c/rdbms/admin

–UPGRADE FOR THE MOST PART COMPLETE

————Wait for Script to Complete————

########################################################################################################
################################## Run the SQL's in Ordered ################################################
########################################################################################################

un the Post-Upgrade Status Tool $ORACLE_HOME/rdbms/admin/utlu121s.sql which provides a summary of the upgrade at the end of the spool log.
It displays the status of the database components in the upgraded database and the time required to complete each component upgrade.
Any errors that occur during the upgrade are listed with each component and must be addressed.


— This order
$ sqlplus "/as sysdba"
SQL> STARTUP
SQL> @utlu121s.sql

Important: The catuppst.sql script is run as part of the upgrade process unless the upgrade returns errors during the process. Check the log file for "BEGIN catuppst.sql" to verify that catuppst.sql ran during the upgrade process. If catuppst.sql has not run, then proceed to run catuppst.sql as shown in this step. Warning messages are also displayed when running catctl.pl indicating that catuppst.sql was not run during the upgrade.

Run catuppst.sql, located in the $ORACLE_HOME/rdbms/admin directory, to perform upgrade actions that do not require the database to be in UPGRADE mode.
SQL> @catuppst.sql

This script can be run concurrently with utlrp.sql.
Run utlrp.sql to recompile any remaining stored PL/SQL and Java code in another session.
SQL> @utlrp.sql

########################################################################################################
################### Identify Invalid Objects With the utluiobj Script #############################
########################################################################################################


Before the upgrade ,the list of invalid SYS/SYSTEM objects is written to registry$sys_inv_objs and non-SYS/SYSTEM objects was written to registry$nonsys_inv_objs by the Pre-Upgrade Information Tool

After the upgrade, run utluiobj.sql from $ORACLE_HOME/rdbms/admin/ to identify/compare any new invalid objects due to the upgrade.

@?/rdbms/admin/utluiobj.sql

########################################################################################################
################################## IN Case of PSU Patch ################################################
########################################################################################################


@?/rdbms/admin/catbundle.sql psu apply


########################################################################################################
################################## Startup All the Nodes ################################################
########################################################################################################

sqlplus "sys/nopass as sysdba"
create spfile from pfile = ‘/u01/app/oracle/admin/${ORACLE_SID}/pfile/upgrade_11.2.0.4.pfile';
startup




########################################################################################################
#### See the InValid Objects #########################################################################

select object_name from dba_objects where status != 'VALID';

## Gather the Stats #########################################################################################

EXEC DBMS_STATS.GATHER_SCHEMA_STATS (‘SYS’);
EXEC DBMS_STATS.GATHER_DICTIONARY_STATS;
EXEC DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

##### Upgrade the Catalog (Optional)
rman catalog username/password@rman_db
upgrade catalog;

No comments:

Post a Comment