Monday, May 24, 2010

Setup Oracle 10g Data Guard for Apps 11i


$ tail -1 $TNS_ADMIN/tnsnames.ora
IFILE=/u01/oracle/R12/db/tech_st/10.2.0/network/admin/PROD_cttest1/PROD_cttest1_ifile.ora[oracle@cttest1

$ cat /u01/oracle/R12/db/tech_st/10.2.0/network/admin/PROD_cttest1/PROD_cttest1_ifile.ora
PROD_PRIM=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=tcp)
(HOST=cttest1.idc.oracle.com)
(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=PROD))
)
PROD_STBY=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=tcp)
(HOST=rrishav-idc1.idc.oracle.com)
(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=PROD))
)

$ cd $ORACLE_HOME/dbs
$ orapwd file=orapw password=

$ tail -1 initPROD.ora
IFILE=/u01/oracle/R12/db/tech_st/10.2.0/dbs/PROD_cttest1_ifile.ora

$ cat /u01/oracle/R12/db/tech_st/10.2.0/dbs/PROD_cttest1_ifile.ora
db_unique_name=PROD_PRIM
log_archive_config='dg_config=(PROD_PRIM,PROD_STBY)'
log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST MANDATORY'
db_recovery_file_dest_size = 107374182400
db_recovery_file_dest = '/u01/oracle/R12/db/apps_st/archivelog'
log_archive_dest_2='service=PROD_STBY valid_for=(online_logfiles,primary_role) db_unique_name=PROD_STBY LGWR ASYNC=20480 OPTIONAL REOPEN=15 NET_TIMEOUT=30'
log_archive_dest_state_2 = defer
fal_server='PROD_STBY'
fal_client='PROD_PRIM'
standby_archive_dest='LOCATION=USE_DB_RECOVERY_FILE_DEST'
standby_file_management=AUTO
parallel_execution_message_size=8192


SQL> select GROUP#, MEMBER from v$logfile;

GROUP# MEMBER
---------- --------------------------------------------------
2 /u01/oracle/R12/db/apps_st/data/log02a.dbf
2 /u01/oracle/R12/db/apps_st/data/log02b.dbf
1 /u01/oracle/R12/db/apps_st/data/log01a.dbf
1 /u01/oracle/R12/db/apps_st/data/log01b.dbf

SQL> select GROUP#, THREAD#, members, sum(bytes)/1024/1024 from v$log group by GROUP#, THREAD#, members;

GROUP# THREAD# MEMBERS SUM(BYTES)/1024/1024
---------- ---------- ---------- --------------------
2 1 2 1000
1 1 2 1000


alter database add standby logfile
thread 1 group 3 (
'/u01/oracle/R12/db/apps_st/data/stb_log03a.dbf',
'/u01/oracle/R12/db/apps_st/data/stb_log03b.dbf')
size 1000M;

alter database add standby logfile
thread 1 group 4 (
'/u01/oracle/R12/db/apps_st/data/stb_log04a.dbf',
'/u01/oracle/R12/db/apps_st/data/stb_log04b.dbf')
size 1000M;

alter database add standby logfile
thread 1 group 5 (
'/u01/oracle/R12/db/apps_st/data/stb_log05a.dbf',
'/u01/oracle/R12/db/apps_st/data/stb_log05b.dbf')
size 1000M;

SQL> select GROUP#, type, MEMBER from v$logfile;

GROUP# TYPE MEMBER
---------- ------- --------------------------------------------------
2 ONLINE /u01/oracle/R12/db/apps_st/data/log02a.dbf
2 ONLINE /u01/oracle/R12/db/apps_st/data/log02b.dbf
1 ONLINE /u01/oracle/R12/db/apps_st/data/log01a.dbf
1 ONLINE /u01/oracle/R12/db/apps_st/data/log01b.dbf
3 STANDBY /u01/oracle/R12/db/apps_st/data/stb_log03a.dbf
3 STANDBY /u01/oracle/R12/db/apps_st/data/stb_log03b.dbf
4 STANDBY /u01/oracle/R12/db/apps_st/data/stb_log04a.dbf
4 STANDBY /u01/oracle/R12/db/apps_st/data/stb_log04b.dbf
5 STANDBY /u01/oracle/R12/db/apps_st/data/stb_log05a.dbf
5 STANDBY /u01/oracle/R12/db/apps_st/data/stb_log05b.dbf


=> run preclone on dbTier
=> scp the dbTier techstack
=> run preclone on appsTier
=> scp the appsTier

1. Connect to the primary database and, if desired, the recovery catalog database. For example, enter:

% rman TARGET SYS/oracle@trgt CATALOG rman/cat@catdb
backup database plus archivelog all;

2. Create the standby control file.

COPY CURRENT CONTROLFILE FOR STANDBY TO '/u01/oracle/R12/db/apps_st/archivelog/sby_control01.ctl';
SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT'; # so backup is consistent and recoverable

Copy "/u01/oracle/R12/db/apps_st/archivelog" to target.

3. Follow these steps to restore and recover the standby datafiles:
1. Ensure the end recovery time is greater than or equal to the
checkpoint SCN of the standby control file and
that a log file containing the checkpoint SCN is available for recovery.
2. If desired, issue a SET command to specify the end time, SCN,
or log sequence number for incomplete recovery.
3. If automatic channels are not configured, then manually allocate at least one auxiliary channel.
4. Specify the NOFILENAMECHECK parameter in the DUPLICATE command, and use the DORECOVER option.

For example, enter the following at the RMAN prompt to use a configured channel to create the standby database:

# If desired, issue a LIST command to determine the SCN of the standby control file.
# The SCN to which you recover must be greater than or equal to the standby control
# file SCN.
LIST BACKUP OF CONTROLFILE;
LIST COPY OF CONTROLFILE;

RUN
{
# If desired, issue a SET command to terminate recovery at a specified point.
# SET UNTIL SCN 143508;
DUPLICATE TARGET DATABASE FOR STANDBY
NOFILENAMECHECK
DORECOVER;
}

RMAN uses all incremental backups, archived redo log file backups, and archived redo log files to perform incomplete recovery. The standby database is left mounted.

4. Create Standby Redo Logs on the new standby database

5. Start Managed Database Recovery:
- On the standby database,
select DATABASE_ROLE from v$database;

The result should be as follows:
DATABASE_ROLE
----------------
PHYSICAL STANDBY

- On the production database enable the previously deferred remote destination
alter system set log_archive_dest_state_2=enable SID='*';

- recover managed standby database using current logfile disconnect;

==============
ON PRODUCTION
==============
SQL> select PROCESS, PID, STATUS, GROUP#, SEQUENCE# from v$managed_standby;

PROCESS PID STATUS GROUP# SEQUENCE#
--------- ---------- ------------ -------- ----------
ARCH 28013 CLOSING N/A 12
ARCH 28015 CLOSING 1 10
LNS 24932 WRITING 2 13 ----> log is sent to RFS

==============
ON STANDBY
==============
SQL> select PROCESS, PID, STATUS, GROUP#, SEQUENCE# from v$managed_standby;

PROCESS PID STATUS GROUP# SEQUENCE#
--------- ---------- ------------ -------- ----------
ARCH 18263 CLOSING 4 12
ARCH 18265 CONNECTED N/A 0
RFS 18315 IDLE N/A 0
MRP0 18270 APPLYING_LOG N/A 13
RFS 18311 IDLE 2 13

OracleApps11i: Database Upgrade from 9i to 10gR2

Downloads
- Database 10.2.0.1
- Database Companion CD 10.2.0.1
- Database 10.2.0.2 patch set# 4547817
- Korean Lexer Patch 5005469
- TXK AutoConfig Template Rollup Patch M (4709948) or Higher
- 11.5.10 INTEROP PATCH FOR 10GR2 (4653225) ---> This patch should be applied to
an 11.5.10.2 environment before upgrading to 10gR2.

Activities
1. Create 10.2.0 OracleHome directory

[oracle@myserver 10gR2]$ cd $ORACLE_HOME/..
[oracle@myserver proddb]$ mkdir 10.2.0

2. Install 10.2.0 software to ORACLE_HOME 10.2.0

[oracle@myserver proddb]$ echo $DISPLAY $ORACLE_SID $ORACLE_HOME
10.176.115.216:0.0 PROD /oracle/proddb/9.2.0
[oracle@myserver proddb]$ export ORACLE_HOME=/oracle/proddb/10.2.0
[oracle@myserver proddb]$ cd /oracle/softwares/10gR2/database/
[oracle@myserver database]$ ./runInstaller

3. Install 10.2.0 Companion CD Products
Oracle® Database Companion CD Installation Guide
10g Release 2 (10.2) for Linux x86
Part Number B15664-02
Section 3.5 - Installing Oracle Database 10g Products

[oracle@myserver 10.2.0]$ cd /oracle/softwares/10gR2/companion
[oracle@myserver companion]$ ./runInstaller

4. If this is the first installation of Oracle products on this system, then Oracle Universal Installer displays the Specify Inventory Directory and Credentials screen. Specify the following information, and then click Next:
* Enter the full path of the inventory directory:
Verify that the path is similar to the following, where oracle_base is the value you specified for the ORACLE_BASE environment variable: oracle_base/oraInventory
* Specify operating system group name.

5. Apply 10.2.0.2 patch set (Note 316900.1 ---> Note 368732.1)
Patchset 4547817 - 10.2.0.2 PATCH SET FOR ORACLE DATABASE SERVER

[oracle@myserver proddb]$ export ORACLE_HOME=/oracle/proddb/10.2.0
[oracle@myserver Disk1]$ echo $DISPLAY $ORACLE_HOME
10.176.115.216:0.0 /oracle/proddb/10.2.0
[oracle@myserver Disk1]$ pwd
/oracle/softwares/10gR2/patch10202/Disk1
[oracle@myserver Disk1]$ ./runInstaller

6. NLS Settings: Create 10g $ORACLE_HOME/nls/data/9idata directory.

[oracle@myserver 10.2.0]$ cd /oracle/proddb/10.2.0/nls/data/old/
[oracle@myserver old]$ ls -l cr9idata.pl
-rw-r----- 1 oracle dba 10849 Jun 9 2004 cr9idata.pl

[oracle@myserver old]$ perl cr9idata.pl
Creating directory //oracle/proddb/10.2.0/nls/data/9idata ...
Copying files to //oracle/proddb/10.2.0/nls/data/9idata...
glob failed (child exited with status 127) at cr9idata.pl line 148.
glob failed (child exited with status 127) at cr9idata.pl line 162.
Copy finished.
Please reset environment variable ORA_NLS10 to //oracle/proddb/10.2.0/nls/data/9idata!
[oracle@myserver old]$ export ORA_NLS10=/oracle/proddb/10.2.0/nls/data/9idata

***** Soln: Manually copy .nlb(s) *****
[oracle@myserver 9idata]$ cp /oracle/proddb/10.2.0/nls/data/old/*.nlb $ORACLE_HOME/nls/data/9idata


Downtime Starts (20hrs.)
7. Shutdown middle-tier services and db listener. (5min)

[oracle@myserver ~]$ . /oracle/prodappl/APPSORA.env
[oracle@myserver ~]$ cd $COMMON_TOP/admin/scripts/PROD_aoltest8
[oracle@myserver PROD_aoltest8]$ sh adstpall.sh apps/apps
[oracle@myserver PROD_aoltest8]$ . /oracle/proddb/9.2.0/PROD_aoltest8.env

[oracle@myserver PROD_aoltest8]$ cd $ORACLE_HOME/appsutil/scripts/PROD_aoltest8
[oracle@myserver PROD_aoltest8]$ sh addlnctl.sh stop PROD



8. Unset TNS_ADMIN and If event="38004 trace name context forever, level 1" is defined in either the init.ora initialization parameter file or the spfile.ora server parameter file, remove it. (5min)

[oracle@myserver 9idata]$ unset TNS_ADMIN

9. Copy 10g ORACLE_HOME/rdbms/admin/utlu102i.sql to any dir outside ORACLE_HOME (5min)
[oracle@myserver 9idata]$ cd $ORACLE_HOME/rdbms/admin
[oracle@myserver admin]$ cp utlu102i.sql /oracle/tempdir

10. Log in to the system as the owner of the Oracle home directory of the database to be upgraded. Run utlu102i.sql (Oracle Database 10.2 Upgrade Information Utility) as SYSDBA (15min)
SQL> spool 10gUpgFrm9i.lst

SQL> @utlu102i.sql

Review the spool file and modify changes (15min)-

10.1. "initPROD.ora"

#Parameters added for 10g upgrade
streams_pool_size=50331648
large_pool_size=8388608
session_max_open_files=20

11. Upgrade the database -

11.1. Upgrade using Database Upgrade Assistant (dbua)
Call dbua from 10g ORACLE_HOME

[oracle@myserver proddata]$ cd $ORACLE_HOME/bin
[oracle@myserver proddata]$ nohup ./dbua &
or,
nohup ./dbua -dbName PROD -oracleHome /oracle/proddb/9.2.0 -sourceDBVersion 9.2.0.6.0 &

11.2.Manual Upgrade <#><#><#> RELIABLE <#><#><#>
11.2.1. Create SYSAUX tablespace and run 10g ORACLE_HOME/rdbms/admin/catupgrd.sql (90min for PROD)
[oracle@myserver admin]$ export PATH=/oracle/proddb/10.2.0/bin:$PATH

*************************************
*** [oracle@myserver bin]$ sqlplus
*** Error 5 initializing SQL*Plus
*** NLS initialization error
***
*** Soln. unset ORA_NLS10
*************************************

[oracle@myserver mesg]$ cd $ORACLE_HOME/rdbms/admin
[oracle@myserver admin]$ sqlplus /nolog
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup upgrade
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.
Total System Global Area 566231040 bytes
Fixed Size 1261984 bytes
Variable Size 385879648 bytes
Database Buffers 167772160 bytes
Redo Buffers 11317248 bytes

Database mounted.

Database opened.

SQL> CREATE TABLESPACE sysaux DATAFILE '/oracle/proddata/sysaux01.dbf'

SIZE 500M REUSE
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO
ONLINE;
########### Start Upgrade ###########

SQL> SPOOL upgrade.log
SQL> @catupgrd.sql
SQL> spool off

11.2.2. Check Upgrade Status.(5min)

SQL> @utlu102s.sql
Oracle Database 10.2 Upgrade Status Utility 04-09-2007 12:10:35
Component Status Version HH:MM:SS
Oracle Database Server VALID 10.2.0.2.0 00:36:07
JServer JAVA Virtual Machine VALID 10.2.0.2.0 00:05:16
Oracle XDK VALID 10.2.0.2.0 00:03:37
Oracle Database Java Packages VALID 10.2.0.2.0 00:00:19
Oracle Text VALID 10.2.0.2.0 00:01:02
Oracle XML Database VALID 10.2.0.2.0 00:01:01
Oracle Real Application Clusters INVALID 10.2.0.2.0 00:00:01
Oracle Data Mining VALID 10.2.0.2.0 00:00:17
OLAP Analytic Workspace VALID 10.2.0.2.0 00:00:16
OLAP Catalog VALID 10.2.0.2.0 00:01:00
Oracle OLAP API VALID 10.2.0.2.0 00:00:29
Oracle interMedia INVALID 10.2.0.2.0 00:03:48
Spatial VALID 10.2.0.2.0 00:03:42

Total Upgrade Time: 01:04:43

PL/SQL procedure successfully completed.

In case any installed component comes as INVALID, run $ORACLE_HOME/rdbms/admin/utlrp.sql to validate.

11.2.3. Shut down and restart the instance to reinitialize the system parameters for normal operation.(10min)

SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP

11.2.4. Run utlrp.sql to recompile any remaining stored PL/SQL and Java code.(from 2007-04-09 12:30:42 to 2007-04-09 21:22:10)

SQL> @utlrp.sql
# Check number of invalid objects remaining
SELECT count(*) FROM dba_objects WHERE status='INVALID';

12. Change init.ora as per Note 216205.1 (20min)
Refer Appendix A for altered/new/removed parameters.

13. Enabling System Managed Undo (Note 216205.1) *** Skipped, as 9iR2 is already on SMU ***

14. Verify that Oracle Data Mining and OLAP are installed in your database.
select comp_id
from dba_registry
where comp_id='ODM' or comp_id='AMD';

If ODM is not returned, install SQL> @$ORACLE_HOME/rdbms/admin/dminst.sql SYSAUX TEMP
If AMD is not returned, install SQL> @$ORACLE_HOME/olap/admin/olap.sql SYSAUX TEMP

########### Post Upgrade ###########

15. Fix Korean lexers (patch 5005469)

SQL> @$ORACLE_HOME/ctx/sample/script/drkorean.sql

16. Setup and start listener.

[oracle@myserver admin]$ cd /oracle/proddb/9.2.0/network/admin/
[oracle@myserver admin]$ cp -r PROD_aoltest8 $ORACLE_HOME/network/admin/
[oracle@myserver admin]$ cd $ORACLE_HOME/network/admin/PROD_aoltest8

Modify the listener.ora and sqlnet.ora files.

[oracle@myserver PROD_aoltest8]$ export TNS_ADMIN=/oracle/proddb/10.2.0/network/admin/PROD_aoltest8

Start Listener and create soft link 9.2.0 for 10.2.0 ORACLE_HOME -
[oracle@myserver PROD_aoltest8]$ lsnrctl start PROD

17. Copy $APPL_TOP/admin/adgrants.sql from admin node to db server node and run.

[oracle@myserver PROD_aoltest8]$ cd /oracle/prodappl/admin/

[oracle@myserver admin]$ sqlplus "/ as sysdba" @adgrants.sql APPLSYS



18. Copy $AD_TOP/patch/115/sql/adctxprv.sql from admin node to db server node and run: Grant "create procedure" privilege to CTXSYS.
[oracle@myserver admin]$ cd /oracle/prodappl/ad/11.5.0/patch/115/sql/
[oracle@myserver sql]$ sqlplus apps/ @adctxprv.sql CTXSYS


19. Implement AutoConfig on dbTier

[oracle@myserver ~]$ . /oracle/prodappl/APPSORA.env
[oracle@myserver admin]$ cd $AD_TOP/bin
[oracle@myserver bin]$ perl admkappsutil.pl
[oracle@myserver bin]$ cp /oracle/prodappl/admin/out/appsutil.zip /oracle/proddb/10.2.0/

On dbTier (10.2.0) -
[oracle@myserver sql]$ cd $ORACLE_HOME
[oracle@myserver 10.2.0]$ ls -l appsutil.zip
-rw-r--r-- 1 oracle dba 2777725 Apr 10 10:19 appsutil.zip
[oracle@myserver 10.2.0]$ unzip -o appsutil.zip
[oracle@myserver appsutil]$ cd appsutil/bin/
[oracle@myserver bin]$ perl adbldxml.pl tier=db appsuser=APPS appspasswd=APPS

Error# 1:
JRE_TOP not found at its desired location /oracle/proddb/10.2.0/jre/1.1.8
Restart adbldxml.pl with value for jtop as an necessary arguement
Fix# 1:
[oracle@myserver bin]$ perl adbldxml.pl tier=db \
appsuser=APPS appspasswd=APPS jtop=/oracle/proddb/10.2.0/jre/1.4.2

Error# 2:
FOLLOWING ERROR OCCURED :
3 >= 3
StackTrace:
java.lang.ArrayIndexOutOfBoundsException: 3 >= 3
at java.util.Vector.setElementAt(Unknown Source)
Fix# 2:
Apply TXK RUP M (4709948) or higher. Regenerate appsutil.zip and retest.
************************************************************************************



Run AutoConfig -

[oracle@myserver bin]$ sh $ORACLE_HOME/appsutil/bin/adconfig.sh contextfile=/oracle/proddb/10.2.0/appsutil/PROD_aoltest8.xml appspass=apps

Error# 3:
Error 5 initializing SQL*Plus
NLS initialization error
... ... ...
[PROFILE PHASE]
afdbprf.sh INSTE8_PRF 1
[APPLY PHASE]
adcrobj.sh INSTE8_APPLY 1
Fix# 3:
Note 362203.1 - Step# 11: run the $ORACLE_HOME/nls/data/old/cr9idata.pl
After creating the directory, make sure that the ORA_NLS10 environment
variable is set to the full path of the 9idata directory
whenever you enable the 10g Oracle home.

20. Copy $APPL_TOP/admin/adstats.sql from admin node to db server node and run in RESTRICTed mode.

SQL> conn / as sysdba
SQL> shutdown immediate
SQL> startup restrict
SQL> @/oracle/prodappl/admin/adstats.sql
SQL> shutdown normal
SQL> startup

21. Run "Recreate Grants and Synonyms" from adadmin.

22. Run AutoConfig on appsTier (optional) and start services.

Downtime Ends


Appendix A. New/Altered/Removed Parameters for 10g upgrade
compatible=10.2.0 #10g Upgrade
#db_cache_size=167772160 #10g Upgrade
#enqueue_resources=32000 #10g Upgrade
#java_pool_size=67108864 #10g Upgrade
#large_pool_size=16777216 #10g Upgrade
#max_enabled_roles=100 #10g Upgrade
nls_length_semantics=BYTE #10g Upgrade
olap_page_pool_size=4194304 #10g Upgrade
open_cursors=600 #10g Upgrade
#optimizer_features_enable=9.2.0 #10g Upgrade
#optimizer_max_permutations=2000 #10g Upgrade
pga_aggregate_target=1073741824 #10g Upgrade (1GB)
#query_rewrite_enabled=true #10g Upgrade
#row_locking=always #10g Upgrade
session_cached_cursors=500 #10g Upgrade
shared_pool_reserved_size=41943040 #10g Upgrade (40MB)
shared_pool_size=419430400 #10g Upgrade (400MB)
#sql_trace=FALSE #10g Upgrade (deprecated parameter)
undo_management=AUTO #10g Upgrade
#undo_retention=1800 #10g Upgrade
#undo_suppress_errors=FALSE #10g Upgrade
undo_tablespace=APPS_UNDOTS1 #10g Upgrade
workarea_size_policy=AUTO #10g Upgrade
##### New Parameters #####
sga_target=1073741824 #10g Upgrade (1GB)
_kks_use_mutex_pin=TRUE #10g Upgrade (Enables use of more efficient mutex mechanism for implementing library cache pins
plsql_optimize_level=2 #10g Upgrade
plsql_code_type=native #10g Upgrade
plsql_native_library_dir=/oracle/proddb/10.2.0/plsql/plsql_nativelib #10g Upgrade
plsql_native_library_subdir_count=149 #10g Upgrade
_b_tree_bitmap_plans=FALSE #10g Upgrade (CBO)
optimizer_secure_view_merging=FALSE #10g Upgrade (CBO)