Oracle Technologies Blog

By ASKM

Archive for the ‘Data Guard’ Category

Data Guard Administration – Weekend Online Training

Posted by Srikrishna Murthy Annam on November 27, 2013

Please visit our site http://askMLabs.com for more details

Direct Link For Free Demo Registration :  Free Demo

Oracle Database 11gR2 Data Guard Administration
Free Demo on 01-DEC-2013 From 10am to 11am.
Online Classes , 4 Weeks , Batch starts from 07-DEC-2013
Classes Every Week SAT and SUN From 5pm to 9pm IST
For Free Registrations Visit : http://askMLabs.com, info@askmlabs.com
24/7 Lab Access From Anywhere In The World

Data Guard Demo

Advertisements

Posted in Data Guard | Tagged: , , , , , | Leave a Comment »

Online Trainings On Oracle Database 11g

Posted by Srikrishna Murthy Annam on September 13, 2013

We are starting new trainings on oracle database 11g. Please review our site http://askmlabs.com or attend our free demo to know more details.
1) Oracle Database 11g Administration ( with 12c new features )
2) Oracle Database 11gR2 Grid with ASM and RAC Administration
3) Oracle Database 11gR2 DataGuard Administration

All these trainings including lab sessions are handled by Srikrishna Murthy Annam.

askmlabs-online-trainings1

Thanks

SRI

 

Posted in 11gR2 RAC, ASM, Data Guard, ORACLE Tech, RAC | 3 Comments »

Renaming A Datafile In A Physical Standby Environment

Posted by Srikrishna Murthy Annam on February 20, 2012

In this article we will see how to rename a datafile in a physical standby setup. Most structural changes made to a primary database are automatically propagated through redo data to a physical standby database. Some structural and configuration changes at primary database requires manual intervention at a physical standby database.

When you rename one or more datafiles in the primary database, the change is not propagated to the standby database. Therefore, if you want to rename the same datafiles on the standby database, you must manually make the equivalent modifications on the standby database because the modifications are not performed automatically, even if the STANDBY_FILE_MANAGEMENT initialization parameter is set to AUTO.

1. Verify primary and standby databases and also change the initialization parameter STANDBY_FILE_MANAGEMENT from AUTO to MANUAL.

On Primary :

SQL> select name,db_unique_name,database_role,switchover_status from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
——— —————————— —————- ——————–
ORCL      orcl                           PRIMARY          TO STANDBY

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/
Oldest online log sequence     524
Next log sequence to archive   526
Current log sequence           526
SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
—————- ——————–
PRIMARY          TO STANDBY

SQL> sho parameter STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
———————————— ———– ——————————
standby_file_management              string      AUTO
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=MANUAL;

System altered.

SQL> sho parameter STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
———————————— ———– ——————————
standby_file_management              string      MANUAL

On Standby :

SQL> select name,db_unique_name,database_role,switchover_status from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
——— —————————— —————- ——————–
ORCL      sbyorcl                        PHYSICAL STANDBY NOT ALLOWED

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/sbyorcl/
Oldest online log sequence     524
Next log sequence to archive   0
Current log sequence           526
SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
—————- ——————–
PHYSICAL STANDBY NOT ALLOWED

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE# APPLIED
———- ———
517 YES
518 YES
519 YES
520 YES
521 YES
522 YES
523 YES
524 YES
525 IN-MEMORY

9 rows selected.

SQL> sho parameter STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
———————————— ———– ——————————
standby_file_management              string      AUTO
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=MANUAL;

System altered.

SQL> sho parameter STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
———————————— ———– ——————————
standby_file_management              string      MANUAL
SQL>

2. Verify the tablespace to which the datafile belongs and make it offline. This step is performed on primary database.

SQL> select file_name from dba_data_files where tablespace_name=’EXAMPLE’;

FILE_NAME
——————————————————————————–
/home/oracle/app/oracle/oradata/orcl/example01.dbf

SQL> alter tablespace example offline;

Tablespace altered.

3. Rename the datafile to new location and bring tablespace back online. This step is performed on primary database.

[oracle@dgaskmpri01 OPatch]$ mv /home/oracle/app/oracle/oradata/orcl/example01.dbf  /tmp/askm/example01_temp.dbf
[oracle@dgaskmpri01 OPatch]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 22 05:47:17 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter tablespace example rename datafile ‘/home/oracle/app/oracle/oradata/orcl/example01.dbf’ to ‘/tmp/askm/example01_temp.dbf’;

Tablespace altered.

SQL> alter tablespace example online;

Tablespace altered.

SQL> select file_name from dba_data_files where tablespace_name=’EXAMPLE’;

FILE_NAME
——————————————————————————–
/tmp/askm/example01_temp.dbf

SQL>

4. Verify the same  tablespace on standby database.

SQL> select ts#,name from v$tablespace where name=’EXAMPLE’;

TS# NAME
———- ——————————
6 EXAMPLE

SQL> select name from v$datafile where ts#=6;

NAME
——————————————————————————–
/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf

SQL>

5. Stop recovery on standby database and shut it down.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Database altered.

SQL> shut immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL>

6. Rename the datafile on standby database.

[oracle@dgaskmsby01 askm]$ mv /home/oracle/app/oracle/oradata/sbyorcl/example01.dbf /tmp/askm/example01_temp.dbf
[oracle@dgaskmsby01 askm]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 22 05:53:49 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             343935672 bytes
Database Buffers          104857600 bytes
Redo Buffers                6008832 bytes
Database mounted.
SQL> alter database rename file ‘/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf’ to ‘/tmp/askm/example01_temp.dbf’;

Database altered.

SQL> select name from v$datafile where ts#=6;

NAME
——————————————————————————–
/tmp/askm/example01_temp.dbf

7. Keep standby database in recovery mode.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Database altered.

8. Set initialization parameter STANDBY_FILE_MANAGEMENT value back to AUTO.

On Primary :

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

System altered.

On Standby :

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

System altered.

Reference :

Renaming a Datafile in the Primary Database

MOS ID : 733796.1

Hope It Helps

SRI

Posted in Data Guard | Tagged: , , | Leave a Comment »

Using expdp To Export From Physical Standby Database

Posted by Srikrishna Murthy Annam on February 16, 2012

In this article, we will discuss the steps to use expdp on physical standby database. There may be some situations where you don’t want your production database loaded with the expdp operation. The other option you have in a standby setup is that you can use your standby database for export operations. But in a physical standby database, the database is in recovery mode and if we want to open the database for expdp operation, we can open the physical standby database in read only mode. Expdp operation needs to create and maintain a master table which needs requires the physical standby database opened in read write mode.

So we have an option in expdp to export standby database. We can use expdp parameter NETWORK_LINK from any non standby database to export database.

  1. Verify primary and Standby Databases
  2. Cancel recovery and Open standby database in Read only Mode
  3. Create a physical directory on primary server to keep export dump files
  4. Create DB Link, Oracle Directory and test it.
  5. Execute expdp on primary server.

1. Verify primary and Standby Databases :

On Primary :

SQL> select name,db_unique_name,database_role,switchover_status from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
——— —————————— —————- ——————–
ORCL      orcl                           PRIMARY          TO STANDBY

SQL> arcvhive log list
SP2-0734: unknown command beginning “arcvhive l…” – rest of line ignored.
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/
Oldest online log sequence     522
Next log sequence to archive   524
Current log sequence           524
SQL>

On Standby :

SQL> select name,user,database_role,switchover_status from v$database;

NAME      USER                           DATABASE_ROLE    SWITCHOVER_STATUS
——— —————————— —————- ——————–
ORCL      SYS                            PHYSICAL STANDBY NOT ALLOWED

SQL> select name,db_unique_name,database_role,switchover_status from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
——— —————————— —————- ——————–
ORCL      sbyorcl                        PHYSICAL STANDBY NOT ALLOWED

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/sbyorcl/
Oldest online log sequence     522
Next log sequence to archive   0
Current log sequence           524
SQL>

2. Cancel recovery and Open standby database in Read only Mode :

SQL> select instance_name, status from v$instance;

INSTANCE_NAME    STATUS
—————- ————
sbyorcl          MOUNTED

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database open read only;

Database altered.

SQL> select instance_name, status from v$instance;

INSTANCE_NAME    STATUS
—————- ————
sbyorcl          OPEN

SQL> select open_mode from v$database;

OPEN_MODE
——————–
READ ONLY

SQL>

3. Create a physical directory on primary server to keep export dump files :

[oracle@dgaskmpri01 ~]$ mkdir /tmp/askm
[oracle@dgaskmpri01 ~]$ chmod 777 /tmp/askm
[oracle@dgaskmpri01 ~]$

4. Create DB Link, Oracle Directory and test it :

[oracle@dgaskmpri01 ~]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 22 04:25:18 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> conn system/xxxxx
Connected.
SQL> create database link db_sbyorcl connect to system identified by oracle using ‘sbyorcl’;

Database link created.

SQL> select db_unique_name from v$database;

DB_UNIQUE_NAME
——————————
orcl

SQL> select db_unique_name from v$database@db_sbyorcl;

DB_UNIQUE_NAME
——————————
sbyorcl

SQL> create directory sby_dump_dir as ‘/tmp/askm’;

Directory created.

SQL>

5. Execute expdp on primary server :

[oracle@dgaskmpri01 askm]$ expdp system/oracle full=y directory=sby_dump_dir network_link=db_sbyorcl dumpfile=sby_db.dmp logfile=sby_db.log

Export: Release 11.2.0.2.0 – Production on Tue Nov 22 04:50:05 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting “SYSTEM”.”SYS_EXPORT_FULL_01″:  system/******** full=y directory=sby_dump_dir network_link=db_sbyorcl dumpfile=sby_db.dmp logfile=sby_db.log
Estimate in progress using BLOCKS method…
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 183.1 MB
Processing object type DATABASE_EXPORT/TABLESPACE

…..
…..
….

ORA-06512: at line 1
ORA-06512: at “SYS.DBMS_METADATA”, line 7564
ORA-39127: unexpected error from call to export_string :=SYS.DBMS_CUBE_EXP.SCHEMA_INFO_EXP(‘OE’,0,1,’11.02.00.00.00′,newblock)
ORA-04045: errors during recompilation/revalidation of SYS.DBMS_CUBE_EXP
ORA-16000: database open for read-only access
ORA-06508: PL/SQL: could not find program unit being called: “SYS.DBMS_CUBE_EXP”
ORA-06512: at line 1
ORA-06512: at “SYS.DBMS_METADATA”, line 7564
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
ORA-39126: Worker unexpected fatal error in KUPW$WORKER.UNLOAD_METADATA [PROCACT_SCHEMA:”OE”]
ORA-08181: specified number is not a valid system change number
ORA-06512: at “SYS.DBMS_METADATA”, line 5466

ORA-06512: at “SYS.DBMS_SYS_ERROR”, line 95
ORA-06512: at “SYS.KUPW$WORKER”, line 8358

—– PL/SQL Call Stack —–
object      line  object
handle    number  name
0x34f7b2c0     19208  package body SYS.KUPW$WORKER
0x34f7b2c0      8385  package body SYS.KUPW$WORKER
0x34f7b2c0      2935  package body SYS.KUPW$WORKER
0x34f7b2c0      9054  package body SYS.KUPW$WORKER
0x34f7b2c0      1688  package body SYS.KUPW$WORKER
0x34d28650         2  anonymous block

Job “SYSTEM”.”SYS_EXPORT_FULL_01″ stopped due to fatal error at 04:55:56

[oracle@dgaskmpri01 askm]$ expdp system/oracle attach=SYS_EXPORT_FULL_01

Export: Release 11.2.0.2.0 – Production on Tue Nov 22 05:03:32 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Job: SYS_EXPORT_FULL_01
Owner: SYSTEM
Operation: EXPORT
Creator Privs: TRUE
GUID: B2533E2386512016E040A8C022010D27
Start Time: Tuesday, 22 November, 2011 5:03:43
Mode: FULL
Instance: orcl
Max Parallelism: 1
EXPORT Job Parameters:
Parameter Name      Parameter Value:
CLIENT_COMMAND        system/******** full=y directory=sby_dump_dir network_link=db_sbyorcl dumpfile=sby_db.dmp logfile=sby_db.log
State: IDLING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: /tmp/askm/sby_db.dmp
bytes written: 950,272

Worker 1 Status:
Process Name: DW00
State: UNDEFINED
Object Schema: OE
Object Type: DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Completed Objects: 36
Worker Parallelism: 1

Export> kill_job
Are you sure you wish to stop this job ([yes]/no): yes

[oracle@dgaskmpri01 askm]$ clear
[oracle@dgaskmpri01 askm]$

I got error while exporting the database. This is identified as bug in 10g and 11gR1. As per the oracle documentation, it is rectified in 11gR2, but I am still getting this issue on 11gR2. I need to further investigate it. Comments and Feedbacks are accepted pls Smile

Reference:

How to use Data Pump Export (expdp) to export from Physical Standby Database [ID 1356592.1]

Thanks

SRI

Posted in Data Guard | Tagged: , , , | Leave a Comment »

Creating Snapshot Standby Database

Posted by Srikrishna Murthy Annam on January 17, 2012

In this article we will see the detailed steps to create a snapshot standby database. Snapshot standby database is new in database 11g and we will create snapshot standby database from physical standby database. This snapshot standby database is fully updatable database and it is opened for read write operation. When the snapshot database is created from physical standby database, redo logs are still  transferred to standby site but are not applied.

The practical use of snapshot standby database is in the situation where if you want to clone a production database for testing something, you can convert physical standby database to snapshot standby database which is as close as to the production database wrt data, do required testing on the snapshot standby database and convert it back to physical standby database. When you convert the snapshot standby database back to the physical standby database, all the modifications done to snapshot database will be lost and it is synchronized with the primary database by applying all the pending redo logs transferred but not applied on the standby database.

I assume that I have a physical standby database setup and data guard broker is configured to manage standby database.

  1. Convert Physical Standby Database To Snapshot Database
  2. Verify Snapshot Standby Database
  3. Do Some Testing In Snapshot Database
  4. Convert Snapshot Database Back To Physical Standby Database
  5. Verify the Modifications Done In Step 3.

1. Convert Physical Standby Database To Snapshot Database :

[oracle@dgaskmpri01 ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.2.0 – Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type “help” for information.
DGMGRL> connect sys/oracle
Connected.
DGMGRL> show configuration;

Configuration – askm_config

  Protection Mode: MaxPerformance
Databases:
orcl    – Primary database
sbyorcl – Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> show database sbyorcl;

Database – sbyorcl

  Role:            PHYSICAL STANDBY
  Intended State:  APPLY-ON
Transport Lag:   0 seconds
Apply Lag:       0 seconds
Real Time Query: OFF
Instance(s):
sbyorcl

Database Status:
SUCCESS

DGMGRL> convert database sbyorcl to snapshot standby;
Converting database “sbyorcl” to a Snapshot Standby database, please wait…
Database “sbyorcl” converted successfully
DGMGRL> show configuration;

Configuration – askm_config

  Protection Mode: MaxPerformance
Databases:
orcl    – Primary database
sbyorcl – Snapshot standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL>  show database sbyorcl;

Database – sbyorcl

  Role:            SNAPSHOT STANDBY
Intended State:  APPLY-OFF
Transport Lag:   0 seconds
Apply Lag:       3 minutes 43 seconds
Instance(s):
sbyorcl

Database Status:
SUCCESS

DGMGRL>

 

2. Verify Snapshot Standby Database :

[oracle@dgaskmsby01 ~]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Sun Nov 27 04:00:41 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select database_role from v$database;

DATABASE_ROLE
—————-
SNAPSHOT STANDBY

SQL> select open_mode from v$database;

OPEN_MODE
——————–
READ WRITE

SQL>

 

3. Do Some Testing In Snapshot Database :

     For testing on snapshot standby database, I will do the following modifications on the snapshot standby database and verify the same changes again after converting snapshot database back to physical standby database.

  • Drop any existing user
  • Create a new tablespace
  • Resize datafile size

[oracle@dgaskmsby01 ~]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Sun Nov 27 04:01:51 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select database_role from v$database;

DATABASE_ROLE
—————-
SNAPSHOT STANDBY

SQL> select open_mode from v$database;

OPEN_MODE
——————–
READ WRITE

SQL> drop user scott cascade;

User dropped.

SQL> select file_name,tablespace_name,bytes/1024/1024 from dba_data_files;

FILE_NAME
——————————————————————————–
TABLESPACE_NAME                BYTES/1024/1024
—————————— —————
/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf
USERS                                      210

/home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf
UNDOTBS1                                   143

/home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf
SYSAUX                                    1105

FILE_NAME
——————————————————————————–
TABLESPACE_NAME                BYTES/1024/1024
—————————— —————
/home/oracle/app/oracle/oradata/sbyorcl/system01.dbf
SYSTEM                                     806

/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf
EXAMPLE                                     82

/home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf
APEX_1246426611663638                        2

FILE_NAME
——————————————————————————–
TABLESPACE_NAME                BYTES/1024/1024
—————————— —————
/home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf
APEX_1265209995679366                        8

7 rows selected.

SQL> create tablespace test datafile ‘/home/oracle/app/oracle/oradata/sbyorcl/test01.dbf’ size 10m;

Tablespace created.

SQL> !ls -lrt /home/oracle/app/oracle/oradata/sbyorcl/test01.dbf
-rw-rw—- 1 oracle oracle 10493952 Nov 27 04:06 /home/oracle/app/oracle/oradata/sbyorcl/test01.dbf

SQL> alter database datafile ‘/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf’ resize 500m;

Database altered.

SQL> select file_name,tablespace_name,bytes/1024/1024 from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
——————————————————————————–
TABLESPACE_NAME                BYTES/1024/1024
—————————— —————
/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf
USERS                                      500

SQL>

 

4. Convert Snapshot Database Back To Physical Standby Database :

DGMGRL> show configuration;

Configuration – askm_config

  Protection Mode: MaxPerformance
Databases:
orcl    – Primary database
sbyorcl – Snapshot standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL>  show database sbyorcl;

Database – sbyorcl

  Role:            SNAPSHOT STANDBY
Intended State:  APPLY-OFF
Transport Lag:   0 seconds
Apply Lag:       3 minutes 43 seconds
Instance(s):
sbyorcl

Database Status:
SUCCESS

DGMGRL> convert database sbyorcl to physical standby;
Converting database “sbyorcl” to a Physical Standby database, please wait…
Operation requires shutdown of instance “sbyorcl” on database “sbyorcl”
Shutting down instance “sbyorcl”…
Database closed.
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance “sbyorcl” on database “sbyorcl”
Starting instance “sbyorcl”…
ORACLE instance started.
Database mounted.
Continuing to convert database “sbyorcl” …
Operation requires shutdown of instance “sbyorcl” on database “sbyorcl”
Shutting down instance “sbyorcl”…
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance “sbyorcl” on database “sbyorcl”
Starting instance “sbyorcl”…
ORACLE instance started.
Database mounted.
Database “sbyorcl” converted successfully
DGMGRL> show configuration;

Configuration – askm_config

  Protection Mode: MaxPerformance
Databases:
orcl    – Primary database
sbyorcl – Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> show database sbyorcl;

Database – sbyorcl

  Role:            PHYSICAL STANDBY
  Intended State:  APPLY-ON
Transport Lag:   27 seconds
Apply Lag:       (unknown)
Real Time Query: OFF
Instance(s):
sbyorcl

Database Status:
SUCCESS

DGMGRL>

 

5. Verify the Modifications Done In Step (3) :

SQL> connect /as sysdba
Connected.
SQL> select database_role from v$database;

DATABASE_ROLE
—————-
PHYSICAL STANDBY

SQL> select open_mode from v$database;

OPEN_MODE
——————–
MOUNTED

SQL> alter database open;

Database altered.

SQL> select username from dba_users where username=’SCOTT’;

USERNAME
——————————
SCOTT

SQL> select tablespace_name from dba_tablespaces where tablespace_name=’TEST’;

no rows selected

SQL> !ls -lrt /home/oracle/app/oracle/oradata/sbyorcl/test01.dbf
ls: /home/oracle/app/oracle/oradata/sbyorcl/test01.dbf: No such file or directory

SQL> select file_name,tablespace_name,bytes/1024/1024 from dba_data_files where tablespace_name=’USERS’;

FILE_NAME
——————————————————————————–
TABLESPACE_NAME                BYTES/1024/1024
—————————— —————
/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf
USERS                                      210

SQL>

 

Please leave me your comments if you have any doubts.

 

Thanks

SRI

 

Posted in Data Guard | Tagged: , , , | Leave a Comment »

Applying PSU In A Data Guard Physical Standby Configuration

Posted by Srikrishna Murthy Annam on January 1, 2012

In this article, I will explain step by step instructions to apply PSU patch to a data guard environment. The latest available PSU patch to RDBMS is 11.2.0.2.4 Patch Set Update (PSU) ie Patch:12827726

  1. Disable Log Shipping From Primary To Standby
  2. Shutdown All The Standby Database Services
  3. Apply PSU patch to Standby Database
  4. Mount The Standby Database
  5. Stop Primary Database Services
  6. Apply PSU Patch To Primary Database
  7. Start Primary Database
  8. Re-Enable Log Shipping
  9. Put Standby Database In Recovery Mode
  10. Verify The PSU Patch Application.

1. Disable Log Shipping From Primary To Standby :

    Assuming that the data guard broker is configured and Disabling log shipping using DGMGRL.

    Verifying Data Guard Health Status:

    

[oracle@dgaskmpri01 ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.2.0 - Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> conn sys/oracle
Unrecognized command "conn", try "help"
DGMGRL>
DGMGRL>
DGMGRL> connect sys/oracle
Connected.
DGMGRL> show configuration

Configuration - askm_config

Protection Mode: MaxPerformance
 Databases:
 orcl - Primary database
 sbyorcl - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> switchover to 'sbyorcl';
Performing switchover NOW, please wait...
New primary database "sbyorcl" is opening...
Operation requires shutdown of instance "orcl" on database "orcl"
Shutting down instance "orcl"...
ORACLE instance shut down.
Operation requires startup of instance "orcl" on database "orcl"
Starting instance "orcl"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "sbyorcl"
DGMGRL> show configuration

Configuration - askm_config

Protection Mode: MaxPerformance
 Databases:
 sbyorcl - Primary database
 orcl - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> switchover to 'orcl';
Performing switchover NOW, please wait...
New primary database "orcl" is opening...
Operation requires shutdown of instance "sbyorcl" on database "sbyorcl"
Shutting down instance "sbyorcl"...
ORACLE instance shut down.
Operation requires startup of instance "sbyorcl" on database "sbyorcl"
Starting instance "sbyorcl"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "orcl"
DGMGRL>

    Disable Log Shipping :

DGMGRL> show database verbose orcl;

Database - orcl

Role: PRIMARY
 Intended State: TRANSPORT-ON
 Instance(s):
 orcl

Properties:
 DGConnectIdentifier = 'orcl'
 ObserverConnectIdentifier = ''
 LogXptMode = 'ASYNC'
 DelayMins = '0'
 Binding = 'optional'
 MaxFailure = '0'
 MaxConnections = '1'
 ReopenSecs = '300'
 NetTimeout = '30'
 RedoCompression = 'DISABLE'
 LogShipping = 'ON'
 PreferredApplyInstance = ''
 ApplyInstanceTimeout = '0'
 ApplyParallel = 'AUTO'
 StandbyFileManagement = 'AUTO'
 ArchiveLagTarget = '0'
 LogArchiveMaxProcesses = '30'
 LogArchiveMinSucceedDest = '1'
 DbFileNameConvert = 'sbyorcl, orcl'
 LogFileNameConvert = '/home/oracle/app/oracle/flash_recovery_area/sbyorcl/, /home/oracle/app/oracle/flash_recovery_area/orcl/'
 FastStartFailoverTarget = ''
 InconsistentProperties = '(monitor)'
 InconsistentLogXptProps = '(monitor)'
 SendQEntries = '(monitor)'
 LogXptStatus = '(monitor)'
 RecvQEntries = '(monitor)'
 SidName = 'orcl'
 StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dgaskmpri01.localdomain)(PORT=1525))(CONNECT_DATA=(SERVICE_NAME=orcl_DGMGRL.localdomain)(INSTANCE_NAME=orcl)(SERVER=DEDICATED)))'
 StandbyArchiveLocation = '/home/oracle/app/oracle/flash_recovery_area/orcl/'
 AlternateLocation = ''
 LogArchiveTrace = '0'
 LogArchiveFormat = '%t_%s_%r.arc'
 TopWaitEvents = '(monitor)'

Database Status:
SUCCESS

DGMGRL> edit database orcl set state='LOG-TRANSPORT-OFF';
Succeeded.
DGMGRL> show database verbose orcl;

Database - orcl

Role: PRIMARY
 Intended State: TRANSPORT-OFF
 Instance(s):
 orcl

Properties:
 DGConnectIdentifier = 'orcl'
 ObserverConnectIdentifier = ''
 LogXptMode = 'ASYNC'
 DelayMins = '0'
 Binding = 'optional'
 MaxFailure = '0'
 MaxConnections = '1'
 ReopenSecs = '300'
 NetTimeout = '30'
 RedoCompression = 'DISABLE'
 LogShipping = 'ON'
 PreferredApplyInstance = ''
 ApplyInstanceTimeout = '0'
 ApplyParallel = 'AUTO'
 StandbyFileManagement = 'AUTO'
 ArchiveLagTarget = '0'
 LogArchiveMaxProcesses = '30'
 LogArchiveMinSucceedDest = '1'
 DbFileNameConvert = 'sbyorcl, orcl'
 LogFileNameConvert = '/home/oracle/app/oracle/flash_recovery_area/sbyorcl/, /home/oracle/app/oracle/flash_recovery_area/orcl/'
 FastStartFailoverTarget = ''
 InconsistentProperties = '(monitor)'
 InconsistentLogXptProps = '(monitor)'
 SendQEntries = '(monitor)'
 LogXptStatus = '(monitor)'
 RecvQEntries = '(monitor)'
 SidName = 'orcl'
 StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dgaskmpri01.localdomain)(PORT=1525))(CONNECT_DATA=(SERVICE_NAME=orcl_DGMGRL.localdomain)(INSTANCE_NAME=orcl)(SERVER=DEDICATED)))'
 StandbyArchiveLocation = '/home/oracle/app/oracle/flash_recovery_area/orcl/'
 AlternateLocation = ''
 LogArchiveTrace = '0'
 LogArchiveFormat = '%t_%s_%r.arc'
 TopWaitEvents = '(monitor)'

Database Status:
SUCCESS

DGMGRL>

2. Shutdown All The Standby Database Services :

    Stop Listener :

 

[oracle@dgaskmsby01 ~]$ lsnrctl stop LISTENER_SBY

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 23-NOV-2011 04:02:19

Copyright (c) 1991, 2010, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1525)))
The command completed successfully
[oracle@dgaskmsby01 ~]$ lsnrctl status LISTENER_SBY

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 23-NOV-2011 04:02:29

Copyright (c) 1991, 2010, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1525)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
 Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dgaskmsby01.localdomain)(PORT=1525)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
 Linux Error: 111: Connection refused
[oracle@dgaskmsby01 ~]$

    Stop Recovery On Standby Server:

  

[oracle@dgaskmsby01 ~]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 04:02:39 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Database altered.
SQL>

    Shutdown Standby Server:

SQL> shut immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL>

3. Apply PSU patch to Standby Database :

    Verify opatch version :

      

[oracle@dgaskmsby01 dbhome_2]$ which opatch
/usr/bin/which: no opatch in (/usr/java/latest/bin:/usr/java/latest/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/app/oracle/product/11.2.0/dbhome_2/bin:/home/oracle/bin)
[oracle@dgaskmsby01 dbhome_2]$ export PATH=$PATH:$ORACLE_HOME/OPatch
[oracle@dgaskmsby01 dbhome_2]$ which opatch
~/app/oracle/product/11.2.0/dbhome_2/OPatch/opatch
[oracle@dgaskmsby01 dbhome_2]$ opatch -help

Oracle Interim Patch Installer version 11.2.0.1.9
Copyright (c) 2011, Oracle Corporation. All rights reserved.

 Usage: opatch [ -help ] [ -r[eport] ] [ command ]

command := apply
 lsinventory
 lspatches
 napply
 nrollback
 rollback
 query
 version
 prereq
 util

<global_arguments> := -help Displays the help message for the command.
 -report Print the actions without executing.

example:
 'opatch -help'
 'opatch -help -fmw'
 'opatch auto -help'
 'opatch apply -help'
 'opatch lsinventory -help'
 'opatch lspatches -help'
 'opatch napply -help'
 'opatch nrollback -help'
 'opatch rollback -help'
 'opatch prereq -help'
 'opatch util -help'
OPatch succeeded.
[oracle@dgaskmsby01 dbhome_2]$

    Check For One-Off Patch Conflicts :

      

[oracle@dgaskmsby01 12827726]$ pwd
/tmp/askm/12827726
[oracle@dgaskmsby01 12827726]$ cd ..
[oracle@dgaskmsby01 askm]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./12827726

Oracle Interim Patch Installer version 11.2.0.1.9
Copyright (c) 2011, Oracle Corporation. All rights reserved.

PREREQ session

Oracle Home : /home/oracle/app/oracle/product/11.2.0/dbhome_2
Central Inventory : /home/oracle/app/oraInventory
 from : /home/oracle/app/oracle/product/11.2.0/dbhome_2/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.2.0
Log file location : /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_04-18-51AM.log
Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.
[oracle@dgaskmsby01 askm]$

      Apply PSU Patch :

      

[oracle@dgaskmsby01 askm]$ cd 12827726/
[oracle@dgaskmsby01 12827726]$ opatch apply

Oracle Interim Patch Installer version 11.2.0.1.9
Copyright (c) 2011, Oracle Corporation. All rights reserved.

Oracle Home : /home/oracle/app/oracle/product/11.2.0/dbhome_2
Central Inventory : /home/oracle/app/oraInventory
 from : /home/oracle/app/oracle/product/11.2.0/dbhome_2/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.2.0
Log file location : /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_04-19-20AM.log

Applying interim patch '12827726' to OH '/home/oracle/app/oracle/product/11.2.0/dbhome_2'
Verifying environment and performing prerequisite checks...
All checks passed.
Provide your email address to be informed of security issues, install and
initiate Oracle Configuration Manager. Easier for you if you use your My
Oracle Support Email address/User Name.
Visit http://www.oracle.com/support/policies.html for details.
Email address/User Name:

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]: Y

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/home/oracle/app/oracle/product/11.2.0/dbhome_2')

Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...

Patching component oracle.rdbms.rsf, 11.2.0.2.0...

Patching component oracle.rdbms, 11.2.0.2.0...
Copying file to "/home/oracle/app/oracle/product/11.2.0/dbhome_2/psu/11.2.0.2.4/catpsu.sql"
Copying file to "/home/oracle/app/oracle/product/11.2.0/dbhome_2/psu/11.2.0.2.4/catpsu_rollback.sql"
Copying file to "/home/oracle/app/oracle/product/11.2.0/dbhome_2/cpu/scripts/patch_8837510.sql"
Copying file to "/home/oracle/app/oracle/product/11.2.0/dbhome_2/cpu/scripts/emdb_recomp_invalids.sql"

Patching component oracle.sysman.console.db, 11.2.0.2.0...

Patching component oracle.sysman.oms.core, 10.2.0.4.3...

Patching component oracle.ldap.rsf, 11.2.0.2.0...

Patching component oracle.rdbms.dv, 11.2.0.2.0...

Patching component oracle.rdbms.dbscripts, 11.2.0.2.0...

Patching component oracle.sysman.plugin.db.main.repository, 11.2.0.2.0...

Patching component oracle.rdbms.rman, 11.2.0.2.0...

Patching component oracle.sdo.locator, 11.2.0.2.0...
Patch 12827726 successfully applied
Log file location: /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_04-19-20AM.log

OPatch succeeded.
[oracle@dgaskmsby01 12827726]$ grep -i error /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_04-19-20AM.log
 [Back up for restore] : Back up 49 files for Oracle Home restore in case of patching error.
[Nov 23, 2011 4:27:28 AM] OUI-67049:Updating archive file "/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libnnz11.a" with "lib/libnnz11.a/ssl_hshk_priv_onerror.o"
[Nov 23, 2011 4:30:50 AM] Deleted the file "/home/oracle/app/oracle/product/11.2.0/dbhome_2/.patch_storage/12827726_Sep_21_2011_05_09_52/scratch/ssl_hshk_priv_onerror.o"
[oracle@dgaskmsby01 12827726]$

    NOTE: Don’t run the script “catbundle.sql”  as a part of applying PSU patch on standby database. We will run this script only on primary database and the redo logs will carry these changes to all the standby databases in the data guard configuration.

4. Mount The Standby Database :

     Start Standby Listener :

      

[oracle@dgaskmsby01 12827726]$ clear
[oracle@dgaskmsby01 12827726]$ lsnrctl start LISTENER_SBY

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 23-NOV-2011 04:51:18

Copyright (c) 1991, 2010, Oracle. All rights reserved.

Starting /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.2.0 - Production
System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/product/11.2.0/dbhome_2/log/diag/tnslsnr/dgaskmsby01/listener_sby/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1525)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dgaskmsby01.localdomain)(PORT=1525)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1525)))
STATUS of the LISTENER
------------------------
Alias LISTENER_SBY
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 23-NOV-2011 04:51:19
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/product/11.2.0/dbhome_2/log/diag/tnslsnr/dgaskmsby01/listener_sby/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1525)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dgaskmsby01.localdomain)(PORT=1525)))
Services Summary...
Service "sbyorcl_DGMGRL.localdomain" has 1 instance(s).
 Instance "sbyorcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@dgaskmsby01 12827726]$

      Mount Standby Database :

      

[oracle@dgaskmsby01 12827726]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 04:51:31 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 343935672 bytes
Database Buffers 104857600 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL>

      NOTE :  Don’t put the database in recover mode. We will start standby recovery mode after applying the PSU patch on primary database.

5. Stop Primary Database Services :

    Stop Primary Listener :

     

[oracle@dgaskmpri01 askm]$ lsnrctl stop LISTENER_PRI

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 23-NOV-2011 04:52:45

Copyright (c) 1991, 2010, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1525)))
The command completed successfully
[oracle@dgaskmpri01 askm]$

     Stop Primary Database :

     

[oracle@dgaskmpri01 askm]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 04:52:52 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

6. Apply PSU Patch To Primary Database :    

     Check OPatch Version :

     

[oracle@dgaskmpri01 dbhome_2]$ opatch -help

Oracle Interim Patch Installer version 11.2.0.1.9
Copyright (c) 2011, Oracle Corporation. All rights reserved.

Usage: opatch [ -help ] [ -r[eport] ] [ command ]

command := apply
 lsinventory
 lspatches
 napply
 nrollback
 rollback
 query
 version
 prereq
 util

<global_arguments> := -help Displays the help message for the command.
 -report Print the actions without executing.

example:
 'opatch -help'
 'opatch -help -fmw'
 'opatch auto -help'
 'opatch apply -help'
 'opatch lsinventory -help'
 'opatch lspatches -help'
 'opatch napply -help'
 'opatch nrollback -help'
 'opatch rollback -help'
 'opatch prereq -help'
 'opatch util -help'

OPatch succeeded.
[oracle@dgaskmpri01 dbhome_2]$

     Check For One-Off Patch Conflicts :

     

[oracle@dgaskmpri01 12827726]$ pwd
/tmp/askm/12827726
[oracle@dgaskmpri01 12827726]$ cd ..
[oracle@dgaskmpri01 askm]$ opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./12827726

Oracle Interim Patch Installer version 11.2.0.1.9
Copyright (c) 2011, Oracle Corporation. All rights reserved.

PREREQ session

Oracle Home : /home/oracle/app/oracle/product/11.2.0/dbhome_2
Central Inventory : /home/oracle/app/oraInventory
 from : /home/oracle/app/oracle/product/11.2.0/dbhome_2/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.2.0
Log file location : /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_04-54-27AM.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.
[oracle@dgaskmpri01 askm]$

     Apply PSU Patch :

     

[oracle@dgaskmpri01 askm]$ cd 12827726/
[oracle@dgaskmpri01 12827726]$ opatch apply

Oracle Interim Patch Installer version 11.2.0.1.9
Copyright (c) 2011, Oracle Corporation. All rights reserved.

Oracle Home : /home/oracle/app/oracle/product/11.2.0/dbhome_2
Central Inventory : /home/oracle/app/oraInventory
 from : /home/oracle/app/oracle/product/11.2.0/dbhome_2/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.2.0
Log file location : /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_04-56-28AM.log

Applying interim patch '12827726' to OH '/home/oracle/app/oracle/product/11.2.0/dbhome_2'
Verifying environment and performing prerequisite checks...
All checks passed.
Provide your email address to be informed of security issues, install and
initiate Oracle Configuration Manager. Easier for you if you use your My
Oracle Support Email address/User Name.
Visit http://www.oracle.com/support/policies.html for details.
Email address/User Name:

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]: Y

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/home/oracle/app/oracle/product/11.2.0/dbhome_2')

Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...

Patching component oracle.rdbms.rsf, 11.2.0.2.0...

Patching component oracle.rdbms, 11.2.0.2.0...
Copying file to "/home/oracle/app/oracle/product/11.2.0/dbhome_2/psu/11.2.0.2.4/catpsu.sql"
Copying file to "/home/oracle/app/oracle/product/11.2.0/dbhome_2/psu/11.2.0.2.4/catpsu_rollback.sql"
Copying file to "/home/oracle/app/oracle/product/11.2.0/dbhome_2/cpu/scripts/patch_8837510.sql"
Copying file to "/home/oracle/app/oracle/product/11.2.0/dbhome_2/cpu/scripts/emdb_recomp_invalids.sql"

Patching component oracle.sysman.console.db, 11.2.0.2.0...

Patching component oracle.sysman.oms.core, 10.2.0.4.3...

Patching component oracle.ldap.rsf, 11.2.0.2.0...

Patching component oracle.rdbms.dv, 11.2.0.2.0...

Patching component oracle.rdbms.dbscripts, 11.2.0.2.0...

Patching component oracle.sysman.plugin.db.main.repository, 11.2.0.2.0...

Patching component oracle.rdbms.rman, 11.2.0.2.0...

Patching component oracle.sdo.locator, 11.2.0.2.0...
Patch 12827726 successfully applied
Log file location: /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_04-56-28AM.log

OPatch succeeded.
[oracle@dgaskmpri01 12827726]$ grep -i error /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_04-56-28AM.log
 [Back up for restore] : Back up 49 files for Oracle Home restore in case of patching error.
[Nov 23, 2011 5:06:28 AM] OUI-67049:Updating archive file "/home/oracle/app/oracle/product/11.2.0/dbhome_2/lib/libnnz11.a" with "lib/libnnz11.a/ssl_hshk_priv_onerror.o"
[Nov 23, 2011 5:09:51 AM] Deleted the file "/home/oracle/app/oracle/product/11.2.0/dbhome_2/.patch_storage/12827726_Sep_21_2011_05_09_52/scratch/ssl_hshk_priv_onerror.o"
[oracle@dgaskmpri01 12827726]$

7. Start Primary Database :

     Start Primary Listener :

      

[oracle@dgaskmpri01 admin]$ lsnrctl start LISTENER_PRI

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 23-NOV-2011 05:33:53

Copyright (c) 1991, 2010, Oracle. All rights reserved.

Starting /home/oracle/app/oracle/product/11.2.0/dbhome_2/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.2.0 - Production
System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/product/11.2.0/dbhome_2/log/diag/tnslsnr/dgaskmpri01/listener_pri/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1525)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dgaskmpri01.localdomain)(PORT=1525)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1525)))
STATUS of the LISTENER
------------------------
Alias LISTENER_PRI
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 23-NOV-2011 05:33:53
Uptime 0 days 0 hr. 0 min. 1 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/product/11.2.0/dbhome_2/log/diag/tnslsnr/dgaskmpri01/listener_pri/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1525)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dgaskmpri01.localdomain)(PORT=1525)))
Services Summary...
Service "orcl_DGMGRL.localdomain" has 1 instance(s).
 Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@dgaskmpri01 admin]$

      Start Primary Database In Restrict Mode :

      

[oracle@dgaskmpri01 12827726]$ cd $ORACLE_HOME/rdbms/admin
[oracle@dgaskmpri01 admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 05:10:59 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup restrict
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 398461624 bytes
Database Buffers 50331648 bytes
Redo Buffers 6008832 bytes
Database mounted.
Database opened.
SQL>

      Run Post PSU Patch Script catbundle.sql :

      

SQL> @catbundle psu apply

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

Generating apply and rollback scripts...
Check the following file for errors:
/home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/catbundle/catbundle_PSU_ORCL_GENERATE_2011Nov23_05_12_04.log
Apply script: /home/oracle/app/oracle/product/11.2.0/dbhome_2/rdbms/admin/catbundle_PSU_ORCL_APPLY.sql
Rollback script: /home/oracle/app/oracle/product/11.2.0/dbhome_2/rdbms/admin/catbundle_PSU_ORCL_ROLLBACK.sql

PL/SQL procedure successfully completed.

Executing script file...

SQL> COLUMN spool_file NEW_VALUE spool_file NOPRINT
SQL> SELECT '/home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/catbundle/' || 'catbundle_PSU_' || name || '_APPLY_' || TO_CHAR(SYSDATE, 'YYYYMonDD_hh24_mi_ss', 'NLS_DATE_LANGUAGE=''AMERICAN''') || '.log' AS spool_file FROM v$database;

SQL> SPOOL &spool_file
SQL> exec dbms_registry.set_session_namespace('SERVER')

PL/SQL procedure successfully completed.

SQL> PROMPT Processing EM Repository...
Processing EM Repository...
SQL> ALTER SESSION SET current_schema = SYSMAN;

Session altered.

SQL> @?/sysman/admin/emdrep/sql/db/latest/policy/config_util_pkgdef.sql
SQL> Rem drv: <create type="pkgdefs"/>
SQL> Rem
SQL> Rem $Header: emdb/source/oracle/sysman/emdrep/sql/db/latest/policy
.....
....
.....
.......
......
 10 'PSU',
 11 'PSU 11.2.0.2.4');

1 row created.

SQL> COMMIT;

Commit complete.

SQL> SPOOL off
SQL> SET echo off
Check the following log file for errors:
/home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/catbundle/catbundle_PSU_ORCL_APPLY_2011Nov23_05_12_17.log
SQL>
SQL>

      Register Listener and Disable Restricted Mode :

      

SQL> alter system register;

System altered.

SQL> alter system disable restricted session;

System altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@dgaskmpri01 admin]$

8. Re-Enable Log Shipping :

     

[oracle@dgaskmpri01 admin]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.2.0 - Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle
Connected.
DGMGRL> edit database orcl set state='ONLINE';
Succeeded.
DGMGRL> show database verbose orcl;

Database - orcl

Role: PRIMARY
 Intended State: TRANSPORT-ON
 Instance(s):
 orcl

Properties:
 DGConnectIdentifier = 'orcl'
 ObserverConnectIdentifier = ''
 LogXptMode = 'ASYNC'
 DelayMins = '0'
 Binding = 'optional'
 MaxFailure = '0'
 MaxConnections = '1'
 ReopenSecs = '300'
 NetTimeout = '30'
 RedoCompression = 'DISABLE'
 LogShipping = 'ON'
 PreferredApplyInstance = ''
 ApplyInstanceTimeout = '0'
 ApplyParallel = 'AUTO'
 StandbyFileManagement = 'AUTO'
 ArchiveLagTarget = '0'
 LogArchiveMaxProcesses = '30'
 LogArchiveMinSucceedDest = '1'
 DbFileNameConvert = 'sbyorcl, orcl'
 LogFileNameConvert = '/home/oracle/app/oracle/flash_recovery_area/sbyorcl/, /home/oracle/app/oracle/flash_recovery_area/orcl/'
 FastStartFailoverTarget = ''
 InconsistentProperties = '(monitor)'
 InconsistentLogXptProps = '(monitor)'
 SendQEntries = '(monitor)'
 LogXptStatus = '(monitor)'
 RecvQEntries = '(monitor)'
 SidName = 'orcl'
 StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dgaskmpri01.localdomain)(PORT=1525))(CONNECT_DATA=(SERVICE_NAME=orcl_DGMGRL.localdomain)(INSTANCE_NAME=orcl)(SERVER=DEDICATED)))'
 StandbyArchiveLocation = '/home/oracle/app/oracle/flash_recovery_area/orcl/'
 AlternateLocation = ''
 LogArchiveTrace = '0'
 LogArchiveFormat = '%t_%s_%r.arc'
 TopWaitEvents = '(monitor)'

Database Status:
SUCCESS

DGMGRL>

9. Put Standby Database In Recovery Mode :

     

[oracle@dgaskmsby01 admin]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 05:38:27 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION
*
ERROR at line 1:
ORA-01153: an incompatible media recovery is active

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Database altered.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Database altered.

SQL>

10. Verify The PSU Patch Application:

     On Primary :

       

[oracle@dgaskmpri01 trace]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 05:39:39 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY TO STANDBY

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/app/oracle/flash_recovery_area/orcl/
Oldest online log sequence 28
Next log sequence to archive 30
Current log sequence 30
SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL>

SQL> col action_time for a30
SQL> col action for a25
SQL> col namespace for a10
SQL> col version for a10
SQL> col bundle_series for a5
SQL> col id for 9999999
SQL> set linesize 120
SQL> select ACTION_TIME,ACTION,NAMESPACE,VERSION,BUNDLE_SERIES,ID from registry$history;
ACTION_TIME ACTION NAMESPACE VERSION BUNDL ID
------------------------------ ------------------------- ---------- ---------- ----- --------
02-OCT-10 11.34.43.691423 AM VIEW INVALIDATE 8289601
02-OCT-10 11.34.44.547808 AM UPGRADE SERVER 11.2.0.2.0
02-OCT-10 11.35.33.441827 AM APPLY SERVER 11.2.0.2 PSU 0
23-NOV-11 05.13.44.279446 AM APPLY SERVER 11.2.0.2 PSU 4

SQL>

      On Standby :

      

[oracle@dgaskmsby01 admin]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.2.0 Production on Wed Nov 23 05:40:25 2011

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY NOT ALLOWED

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/app/oracle/flash_recovery_area/sbyorcl/
Oldest online log sequence 30
Next log sequence to archive 0
Current log sequence 32
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# APPLIED
---------- ---------
 1 YES
...
...
 29 YES
 30 YES

SEQUENCE# APPLIED
---------- ---------
 31 IN-MEMORY

45 rows selected.

SQL> select ACTION_TIME,ACTION,NAMESPACE,VERSION,BUNDLE_SERIES,ID from registry$history;
select ACTION_TIME,ACTION,NAMESPACE,VERSION,BUNDLE_SERIES,ID from registry$history
 *
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@dgaskmsby01 admin]$ clear
[oracle@dgaskmsby01 admin]$ opatch lsinventory

Oracle Interim Patch Installer version 11.2.0.1.9
Copyright (c) 2011, Oracle Corporation. All rights reserved.

Oracle Home : /home/oracle/app/oracle/product/11.2.0/dbhome_2
Central Inventory : /home/oracle/app/oraInventory
 from : /home/oracle/app/oracle/product/11.2.0/dbhome_2/oraInst.loc
OPatch version : 11.2.0.1.9
OUI version : 11.2.0.2.0
Log file location : /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/opatch2011-11-23_05-43-55AM.log

Lsinventory Output file location : /home/oracle/app/oracle/product/11.2.0/dbhome_2/cfgtoollogs/opatch/lsinv/lsinventory2011-11-23_05-43-55AM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1):

Oracle Database 11g 11.2.0.2.0
There are 1 products installed in this Oracle Home.

Interim patches (1) :

Patch 12827726 : applied on Wed Nov 23 04:29:17 PST 2011
Unique Patch ID: 14019830
 Created on 21 Sep 2011, 05:09:52 hrs PST8PDT
 Bugs fixed:
 10158965, 10031806, 12635537, 9746210, 9744252, 9956713, 10356513
 10204358, 10378005, 10170431, 11853815, 10222719, 12639177, 9591812
 10127360, 9443361, 10035737, 10384285, 12846268, 9873405, 12846269
 11069199, 12670165, 10245086, 10159846, 10205230, 10052141, 10039731
 11818335, 12371955, 10040921, 12366627, 10077191, 11827088, 11785938
 10219576, 10258337, 11707699, 10264680, 10094823, 10209232, 11695333
 9881076, 10278372, 10281887, 10621169, 10048701, 9078442, 11057263
 10157249, 9735237, 10317487, 10219583, 10636231, 10310299, 11065646
 10055063, 10368698, 12340939, 10079168, 10233732, 8223165, 10264696
 10142909, 9953542, 10052956, 10080579, 11699057, 12620422, 10285022
 10329146, 10332589, 11666137, 10110863, 9869401, 12828071, 10019218
 10229719, 9539440, 10373381, 11724984, 10239480, 10411618, 11670161
 9724970, 10399808, 10113990, 10312847, 11893621, 10084145, 10367188
 11800170, 11695285, 10285394, 10157402, 9651350, 10299224, 10151017
 11724916, 10190642, 12586486, 9564886, 12586487, 10129643, 12586488
 12586489, 10018789, 10248523, 9715581, 9770451, 11889177, 10425676
 9683047, 10180307, 10126094, 10396041, 10132870, 10094201, 10193846
 11664046, 10324294, 9414040, 12586490, 9819805, 12586491, 9795214
 12586492, 12586493, 12586494, 10142788, 12586495, 11830776, 9905049
 11674898, 10419984, 12586496, 11830777, 6892311, 11830778, 10358019
 12431716, 10422126, 10200404, 11651810, 10102506, 11067567, 12827726
 11733179, 10229886, 10040531, 10155605, 10326338, 10356782, 10082277
 10051315, 10218814, 9788588, 10278773, 12326246, 10622001, 11707302
 10230571, 9966609, 12419321, 12546006, 10137324, 9771278, 10013431
 10228151, 10324526, 11894889, 10238786, 10217802, 10061015, 9572787
 10332111, 10227288, 10623249, 10073683, 12639234, 11664719, 9735282
 9748749, 10022980, 10237773, 11800854, 12419331, 11674485, 10097711
 10187168, 6523037, 10648873, 10053725, 8685446

--------------------------------------------------------------------------------

OPatch succeeded.
[oracle@dgaskmsby01 admin]$

NOTE : The same procedure can be used for Patchsets/CPU patch application.

Reference:

How do you apply a Patchset,PSU or CPU in a Data Guard Physical Standby configuration [ID 278641.1]

Hope It Helps

SRI

 

Posted in Data Guard | Tagged: , , , , , , , | 1 Comment »

Creating Physical Standby Database With RMAN Duplicate From Active Database – Video

Posted by Srikrishna Murthy Annam on December 30, 2011

Prepared By SRI

 

Please also refer the article : https://learnwithme11g.wordpress.com/2011/12/30/creating-physical-standby-database-with-rman-duplicate-from-active-database/

Posted in Data Guard | Tagged: , , , , , , , , , , , , , | Leave a Comment »

Creating Physical Standby Database With RMAN Duplicate From Active Database

Posted by Srikrishna Murthy Annam on December 30, 2011

Setup:

 

Primary Site

Standby Site

Hostname

dgaskmpri01

dgaskmsby01

Database Name

orcl

orcl

Database Unique Name

orcl

sbyorcl

Net Service Name

orcl

sbyorcl

 

In this article, I will explain the step by step procedure to create a physical standby database using RMAN duplicate command without shutting down the primary database and using primary active database files. There is no need to take any database backups. This is new feature available in 11g database.

Primary Site Preparation :

1.      Enable Database Force Logging

2.      Create SRL (Standby Redo Logs)

3.      Modify Init.ora parameters

4.      Enable Archiving

5.      Create a init.ora file for Standby Database ( Optional )

6.      Configure listener.ora and tnsnames.ora

7.      Copy init.ora and password  files to Standby Server

 

Standby Site Preparation :

1.      Create a remote login password file ( if it is not copied from primary site )

2.      Create a directory structure

3.      Modify the init.ora parameter file (Optional)

4.      Configure listener.ora and tnsnames.ora

5.      Verify connectivity

 

Creating Physical Standby Database :

1.      Create Physical Standby Using RMAN Duplication From Active Database (New in 11g)

2.      Keep it in recovery

 

Verifications

 

Primary Site Preparation :

1.      Enable Database Force Logging:

 

SQL>  select FORCE_LOGGING from v$database;

SQL> ALTER DATABASE FORCE LOGGING;

 

2.      Create SRL ( Standby Redo Logs):

You need to create SRL with the same size or greater size as of the online redo logs and also the number of SRLs should be one greater than the online redologs.

 

SQL> select name,user from v$database;

NAME      USER

——— ——————————

ORCL      SYS

SQL> col group# for 9999

SQL> col member for a50

SQL> set linesize 120

SQL> select name,user from v$database;

NAME      USER

——— ——————————

ORCL      SYS

SQL> select GROUP#,THREAD#,MEMBERS,BYTES FROM V$LOG;

GROUP#    THREAD#    MEMBERS      BYTES

—— ———- ———- ———-

     1          1          1   52428800

     2          1          1   52428800

     3          1          1   52428800

SQL> select group#,member from v$logfile;

GROUP# MEMBER

—— ————————————————–

     3 /home/oracle/app/oracle/oradata/orcl/redo03.log

     2 /home/oracle/app/oracle/oradata/orcl/redo02.log

     1 /home/oracle/app/oracle/oradata/orcl/redo01.log

SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;

no rows selected

SQL> ALTER DATABASE ADD STANDBY LOGFILE (‘/home/oracle/app/oracle/oradata/orcl/s_redo01.log’) SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE (‘/home/oracle/app/oracle/oradata/orcl/s_redo02.log’) SIZE 52428800;

Database altered.

SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;

GROUP#      BYTES

—— ———-

     4   52428800

     5   52428800

SQL> ALTER DATABASE ADD STANDBY LOGFILE (‘/home/oracle/app/oracle/oradata/orcl/s_redo03.log’) SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE (‘/home/oracle/app/oracle/oradata/orcl/s_redo04.log’) SIZE 52428800;

Database altered.

SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;

GROUP#      BYTES

—— ———-

     4   52428800

     5   52428800

     6   52428800

     7   52428800

SQL>

 

3.      Modify the init.ora parameters:

 

Modify the init.ora parameters on the primary database side to reflect the following values. If you are using spfile, you can add these parameter online without shutting down the primary database.

 

DB_NAME=orcl

DB_UNIQUE_NAME=orcl

LOG_ARCHIVE_CONFIG=’DG_CONFIG=(orcl,sbyorcl)’

LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/app/oracle/flash_recovery_area/orcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl’

LOG_ARCHIVE_DEST_2=’SERVICE=sbyorcl ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=sbyorcl’

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

LOG_ARCHIVE_MAX_PROCESSES=30

FAL_SERVER=sbyorcl

DB_FILE_NAME_CONVERT=’sbyorcl’,’orcl’

LOG_FILE_NAME_CONVERT=’/home/oracle/app/oracle/flash_recovery_area/sbyorcl/’,’/home/oracle/app/oracle/flash_recovery_area/orcl/’

STANDBY_FILE_MANAGEMENT=AUTO

 

4.      Enable Archiving :

Make sure that your database is running in archive log mode. Because in a physical standby setup all the redologs generated on the primary database will be transferred to standby site and applied to the standby database.

 

SQL> shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> STARTUP MOUNT;

ORACLE instance started.

 

Total System Global Area  456146944 bytes

Fixed Size                  1344840 bytes

Variable Size             381684408 bytes

Database Buffers           67108864 bytes

Redo Buffers                6008832 bytes

Database mounted.

SQL> ALTER DATABASE ARCHIVELOG;

 

Database altered.

 

SQL> ALTER DATABASE OPEN;

 

Database altered.

 

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/

Oldest online log sequence     360

Next log sequence to archive   362

Current log sequence           362

SQL>

  

    

 

5.      Create a init.ora file for Standby Database: ( Optional)

We can specify the required init.ora parameter when using RMAN duplication command and  need not create a separate init.ora parmeter file.

 

SQL> CREATE PFILE=’/tmp/askm/initsbyorcl.ora’ FROM SPFILE;

 

File created.

 

6.      Configure listener.ora and tnsnames.ora:

 

[oracle@dgaskmpri01 admin]$ cat listener.ora

LISTENER_PRI =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))

    )

  )

 

SID_LIST_LISTENER_PRI =

  (SID_LIST =

    (SID_DESC =

      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2)

      (SID_NAME = orcl)

    )

  )

[oracle@dgaskmpri01 admin]$ cat tnsnames.ora

orcl =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID=orcl)

    )

  )

 

sbyorcl =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID=sbyorcl)

    )

  )

[oracle@dgaskmpri01 admin]$

 

7.      Copy init.ora and password files to Standby Server:

Create a temporary directory(/tmp/askm) on standby server and copy initsbyorcl.ora and password file(orapwsbyorcl) from primary server to standby server.

 

 

 

Standby Site Preparation :

 

1.      Create a remote login password file ( if it is not copied from primary site )

Copy the password file /tmp/askm/orapwsbyorcl to $ORACLE_HOME/dbs

 

2.      Create a directory structure

If you are using a different directory structure on the standby server, they you need to create all the directories on the standby site.

Copy initsbyorcl.ora to $ORACLE_HOME/dbs location.

 

[oracle@dgaskmsby01]$ mkdir /home/oracle/app/oracle/oradata/sbyorcl/

[oracle@dgaskmsby01]$ mkdir /home/oracle/app/oracle/flash_recovery_area/sbyorcl/

[oracle@dgaskmsby01]$ cd $ORACLE_HOME/dbs

[oracle@dgaskmsby01 sbyorcl]$ cp /tmp/askm/initsbyorcl.ora $ORACLE_HOME/dbs

 

 

3.      Modify the init.ora parameter file (Optional) :

Modify the initsbyorcl.ora file to reflect the following initialization parameters. This step is optional if you are specifying the required init.ora parameter in the RMAN duplication command.

 

DB_NAME=orcl

DB_UNIQUE_NAME=sbyorcl

LOG_ARCHIVE_CONFIG=’DG_CONFIG=(orcl,sbyorcl)’

CONTROL_FILES=’/home/oracle/app/oracle/oradata/sbyorcl/s_control01.ctl’, ‘/home/oracle/app/oracle/flash_recovery_area/sbyorcl/s_control02.ctl’

DB_FILE_NAME_CONVERT=’orcl’,’sbyorcl’

LOG_FILE_NAME_CONVERT=’/home/oracle/app/oracle/flash_recovery_area/orcl/’,’/home/oracle/app/oracle/flash_recovery_area/sbyorcl/’

LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=sbyorcl’

LOG_ARCHIVE_DEST_2=’SERVICE=orcl ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl’

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

STANDBY_FILE_MANAGEMENT=AUTO

FAL_SERVER=orcl

 

 

4.      Configure listener.ora and tnsnames.ora:

 

[oracle@dgaskmsby01 admin]$ cat listener.ora

LISTENER_SBY =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))

    )

  )

 

SID_LIST_LISTENER_SBY =

  (SID_LIST =

    (SID_DESC =

      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2)

      (SID_NAME = sbyorcl)

    )

  )

[oracle@dgaskmsby01 admin]$ cat tnsnames.ora

orcl =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID=orcl)

    )

  )

 

sbyorcl =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID=sbyorcl)

    )

  )

[oracle@dgaskmsby01 admin]$

 

 

5.      Verify connectivity

 

On Primary Server:

[oracle@dgaskmpri01]$ lsnrctl stop LISTENER_PRI

[oracle@dgaskmpri01]$ lsnrctl start LISTENER_PRI

[oracle@dgaskmpri01]$ tnsping orcl

[oracle@dgaskmpri01]$ tnsping sbyorcl

[oracle@dgaskmpri01]$ sqlplus sys/xxxxx@orcl

[oracle@dgaskmpri01]$ sqlplus sys/xxxxx@sbyorcl

 

On Standby Server:

[oracle@dgaskmsby01]$ lsnrctl stop LISTENER_SBY

[oracle@dgaskmsby01]$ lsnrctl start LISTENER_SBY

[oracle@dgaskmsby01]$ tnsping orcl

[oracle@dgaskmsby01]$ tnsping sbyorcl

[oracle@dgaskmsby01]$ sqlplus sys/xxxxx@orcl

[oracle@dgaskmsby01]$ sqlplus sys/xxxxx@sbyorcl

 

 

 

Creating Physical Standby Database :

 

1.      Create Physical Standby Using RMAN Duplication From Active Database (New in 11g) :

 

[oracle@dgaskmsby01 sbyorcl]$ sqlplus ‘/as sysdba’

 

SQL*Plus: Release 11.2.0.2.0 Production on Mon Nov 21 08:53:10 2011

 

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  456146944 bytes

Fixed Size                  1344840 bytes

Variable Size             322964152 bytes

Database Buffers          125829120 bytes

Redo Buffers                6008832 bytes

SQL>

 

[oracle@dgaskmpri01 tmp]$ rman target sys/oracle@orcl auxiliary sys/oracle@sbyorcl

 

Recovery Manager: Release 11.2.0.2.0 – Production on Mon Nov 21 08:55:07 2011

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORCL (DBID=1229390655)

connected to auxiliary database: ORCL (not mounted)

 

RMAN> run {

2> allocate channel prmy1 type disk;

3> allocate channel prmy2 type disk;

4> duplicate target database for standby from active database;

5> }

 

using target database control file instead of recovery catalog

allocated channel: prmy1

channel prmy1: SID=117 device type=DISK

 

allocated channel: prmy2

channel prmy2: SID=82 device type=DISK

 

Starting Duplicate Db at 21-NOV-11

released channel: prmy1

released channel: prmy2

RMAN-00571: =========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===========

RMAN-00571: =========================================================

RMAN-03002: failure of Duplicate Db command at 11/21/2011 08:58:23

RMAN-05501: aborting duplication of target database

RMAN-05503: at least one auxiliary channel must be allocated to execute this command

 

RMAN> run {

2> allocate channel prmy1 type disk;

3> allocate auxiliary channel stby type disk;

4> duplicate target database for standby from active database;

5> }

 

allocated channel: prmy1

channel prmy1: SID=117 device type=DISK

 

allocated channel: stby

channel stby: SID=21 device type=DISK

 

Starting Duplicate Db at 21-NOV-11

 

contents of Memory Script:

{

   backup as copy reuse

   targetfile  ‘/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/orapworcl’ auxiliary format

 ‘/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/orapwsbyorcl’   ;

}

executing Memory Script

 

Starting backup at 21-NOV-11

Finished backup at 21-NOV-11

 

contents of Memory Script:

{

   backup as copy current controlfile for standby auxiliary format  ‘/home/oracle/app/oracle/oradata/sbyorcl/s_control01.ctl’;

   restore clone controlfile to  ‘/home/oracle/app/oracle/flash_recovery_area/sbyorcl/s_control02.ctl’ from

 ‘/home/oracle/app/oracle/oradata/sbyorcl/s_control01.ctl’;

}

executing Memory Script

 

Starting backup at 21-NOV-11

channel prmy1: starting datafile copy

copying standby control file

output file name=/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/snapcf_orcl.f tag=TAG20111121T090020 RECID=3 STAMP=767782824

channel prmy1: datafile copy complete, elapsed time: 00:00:07

Finished backup at 21-NOV-11

 

Starting restore at 21-NOV-11

 

channel stby: copied control file copy

Finished restore at 21-NOV-11

 

contents of Memory Script:

{

   sql clone ‘alter database mount standby database’;

}

executing Memory Script

 

sql statement: alter database mount standby database

 

contents of Memory Script:

{

   set newname for tempfile  1 to

 "/home/oracle/app/oracle/oradata/sbyorcl/temp01.dbf";

   switch clone tempfile all;

   set newname for datafile  1 to

 "/home/oracle/app/oracle/oradata/sbyorcl/system01.dbf";

   set newname for datafile  2 to

 "/home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf";

   set newname for datafile  3 to

 "/home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf";

   set newname for datafile  4 to

 "/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf";

   set newname for datafile  5 to

 "/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf";

   set newname for datafile  6 to

 "/home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf";

   set newname for datafile  7 to

 "/home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf";

   backup as copy reuse

   datafile  1 auxiliary format

 "/home/oracle/app/oracle/oradata/sbyorcl/system01.dbf"   datafile

 2 auxiliary format

 "/home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf"   datafile

 3 auxiliary format

 "/home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf"   datafile

 4 auxiliary format

 "/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf"   datafile

 5 auxiliary format

 "/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf"   datafile

 6 auxiliary format

 "/home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf"   datafile

 7 auxiliary format

 "/home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf"   ;

   sql ‘alter system archive log current’;

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed tempfile 1 to /home/oracle/app/oracle/oradata/sbyorcl/temp01.dbf in control file

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting backup at 21-NOV-11

channel prmy1: starting datafile copy

input datafile file number=00002 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf

output file name=/home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf tag=TAG20111121T090043

channel prmy1: datafile copy complete, elapsed time: 00:06:00

channel prmy1: starting datafile copy

input datafile file number=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf

output file name=/home/oracle/app/oracle/oradata/sbyorcl/system01.dbf tag=TAG20111121T090043

channel prmy1: datafile copy complete, elapsed time: 00:07:12

channel prmy1: starting datafile copy

input datafile file number=00004 name=/home/oracle/app/oracle/oradata/orcl/users01.dbf

output file name=/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf tag=TAG20111121T090043

channel prmy1: datafile copy complete, elapsed time: 00:02:03

channel prmy1: starting datafile copy

input datafile file number=00003 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf

output file name=/home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf tag=TAG20111121T090043

channel prmy1: datafile copy complete, elapsed time: 00:01:23

channel prmy1: starting datafile copy

input datafile file number=00005 name=/home/oracle/app/oracle/oradata/orcl/example01.dbf

output file name=/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf tag=TAG20111121T090043

channel prmy1: datafile copy complete, elapsed time: 00:00:54

channel prmy1: starting datafile copy

input datafile file number=00007 name=/home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf

output file name=/home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf tag=TAG20111121T090043

channel prmy1: datafile copy complete, elapsed time: 00:00:17

channel prmy1: starting datafile copy

input datafile file number=00006 name=/home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf

output file name=/home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf tag=TAG20111121T090043

channel prmy1: datafile copy complete, elapsed time: 00:00:08

Finished backup at 21-NOV-11

 

sql statement: alter system archive log current

 

contents of Memory Script:

{

   switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched to datafile copy

input datafile copy RECID=3 STAMP=767783912 file name=/home/oracle/app/oracle/oradata/sbyorcl/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=4 STAMP=767783912 file name=/home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=5 STAMP=767783913 file name=/home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=6 STAMP=767783913 file name=/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=7 STAMP=767783913 file name=/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf

datafile 6 switched to datafile copy

input datafile copy RECID=8 STAMP=767783913 file name=/home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf

datafile 7 switched to datafile copy

input datafile copy RECID=9 STAMP=767783913 file name=/home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf

ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files

ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

 

RMAN-05535: WARNING: All redo log files were not defined properly.

ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files

ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

 

RMAN-05535: WARNING: All redo log files were not defined properly.

ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files

ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

 

RMAN-05535: WARNING: All redo log files were not defined properly.

ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files

ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

 

RMAN-05535: WARNING: All redo log files were not defined properly.

ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files

ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

 

RMAN-05535: WARNING: All redo log files were not defined properly.

ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files

ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

 

RMAN-05535: WARNING: All redo log files were not defined properly.

ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files

ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

 

RMAN-05535: WARNING: All redo log files were not defined properly.

Finished Duplicate Db at 21-NOV-11

released channel: prmy1

released channel: stby

 

RMAN>

 

NOTE : These warnings can be ignored as these are due to the initialization parameter STANDBY_FILE_MANAGEMENT is set to AUTO.

 

 

2.      Keep it in recovery:

 

[oracle@dgaskmsby01 sbyorcl]$ sqlplus ‘/as sysdba’

 

SQL*Plus: Release 11.2.0.2.0 Production on Mon Nov 21 09:19:27 2011

 

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

 

Database altered.

 

SQL> select database_role,switchover_status from v$database;

 

DATABASE_ROLE    SWITCHOVER_STATUS

—————- ——————–

PHYSICAL STANDBY NOT ALLOWED

 

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 

 SEQUENCE# APPLIED

———- ———

       517 YES

       518 YES

       519 IN-MEMORY

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /home/oracle/app/oracle/flash_recovery_area/sbyorcl/

Oldest online log sequence     515

Next log sequence to archive   0

Current log sequence           520

SQL>

 

 

 

Verifications :

 

On Standby:

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
—————- ——————–
PHYSICAL STANDBY NOT ALLOWED

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE# APPLIED
———- ———
       517 YES
       518 YES
       519 IN-MEMORY

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/sbyorcl/
Oldest online log sequence     515
Next log sequence to archive   0
Current log sequence           520
SQL>

 

On Primary :

Do some redo log switches

SQL> ALTER SYSTEM SWITCH LOGFILE;

[oracle@dgaskmpri01 tmp]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Mon Nov 21 09:21:23 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/
Oldest online log sequence     518
Next log sequence to archive   520
Current log sequence           520
SQL> alter system switch logfile;

System altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/
Oldest online log sequence     519
Next log sequence to archive   521
Current log sequence           521
SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
—————- ——————–
PRIMARY          TO STANDBY

SQL>

 

On Standby:

 Verify that the recent archived log file is shifted to standby side and applied with the following commands.

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE# APPLIED
———- ———
       517 YES
       518 YES
       519 YES
       520 IN-MEMORY

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/sbyorcl/
Oldest online log sequence     519
Next log sequence to archive   0
Current log sequence           521
SQL>

 

Other Useful Information:

To verify all the init.ora parameter in a single command:

egrep -i

"DB_NAME|DB_UNIQUE_NAME|LOG_ARCHIVE_CONFIG|CONTROL_FILES|LOG_ARCHIVE_DEST_1|LOG_ARCHIVE_DEST_2|

LOG_ARCHIVE_DEST_STATE_1|LOG_ARCHIVE_DEST_STATE_2|REMOTE_LOGIN_PASSWORDFILE|LOG_ARCHIVE_FORMAT|

LOG_ARCHIVE_MAX_PROCESSES|FAL_SERVER|DB_FILE_NAME_CONVERT|LOG_FILE_NAME_CONVERT|

STANDBY_FILE_MANAGEMENT" <specify init.ora parameter file>

 

To Cancel the Standby Recovery Mode:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

 

Useful commands To Troubleshoot:

select message from v$dataguard_status where dest_id = 2;

select archived_thread#, archived_seq#, applied_thread#, applied_seq# from v$archive_dest_status;

select registrar, creator, thread#, sequence#, first_change#, next_change# from v$archived_log;

select thread#, sequence#, first_change#, next_change# from v$log_history;

 

To Verify Recover Process On Standby:

select thread#, sequence# from v$log where status=’CURRENT’;  = >  On Primary

select thread#, sequence#, status from v$managed_standby where process=’MRP0′; = > On Standby

 

References :

Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE…FROM ACTIVE DATABASE [ID 1075908.1]

 

Hope It Helps

SRI

Posted in Data Guard | Tagged: , , , , , , , , , , , , , | 4 Comments »

Creating Physical Standby Database With RMAN Duplicate

Posted by Srikrishna Murthy Annam on December 20, 2011

Setup:

 

Primary Site

Standby Site

Hostname

dgaskmpri01

dgaskmsby01

Database Name

orcl

orcl

Database Unique Name

orcl

sbyorcl

Net Service Name

orcl

sbyorcl

 

Primary Site Preparation :

1.      Enable Database Force Logging

2.      Create SRL (Standby Redo Logs)

3.      Modify Init.ora parameters

4.      Enable Archiving

5.      Backup Primary Database including archivelogs with RMAN

6.      Create a controlfile for Standby Database using RMAN

7.      Create a init.ora file for Standby Database

8.      Configure listener.ora and tnsnames.ora

9.      Copy RMAN backups and configuration files to Standby Server

 

Standby Site Preparation :

1.      Create a remote login password file ( if it is not copied from primary site )

2.      Create a directory structure

3.      Modify the init.ora parameter file

4.      Configure listener.ora and tnsnames.ora

5.      Verify connectivity

 

Creating Physical Standby Database :

1.      Create Physical Standby Database With RMAN Duplicate command

2.      Keep it in recovery

 

Verifications

Prepared By SRI

 

 

Primary Site Preparation :

1. Enable Database Force Logging:

SQL>  select FORCE_LOGGING from v$database;

SQL> ALTER DATABASE FORCE LOGGING;

2. Create SRL ( Standby Redo Logs):

You need to create SRL with the same size or greater size as of the online redo logs and also the number of SRLs should be one greater than the online redologs.

SQL> select name,user from v$database;

NAME      USER

——— ——————————

ORCL      SYS

SQL> col group# for 9999

SQL> col member for a50

SQL> set linesize 120

SQL> select name,user from v$database;

NAME      USER

——— ——————————

ORCL      SYS

SQL> select GROUP#,THREAD#,MEMBERS,BYTES FROM V$LOG;

GROUP#    THREAD#    MEMBERS      BYTES

—— ———- ———- ———-

     1          1          1   52428800

     2          1          1   52428800

     3          1          1   52428800

SQL> select group#,member from v$logfile;

GROUP# MEMBER

—— ————————————————–

     3 /home/oracle/app/oracle/oradata/orcl/redo03.log

     2 /home/oracle/app/oracle/oradata/orcl/redo02.log

     1 /home/oracle/app/oracle/oradata/orcl/redo01.log

SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;

no rows selected

SQL> ALTER DATABASE ADD STANDBY LOGFILE (‘/home/oracle/app/oracle/oradata/orcl/s_redo01.log’) SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE (‘/home/oracle/app/oracle/oradata/orcl/s_redo02.log’) SIZE 52428800;

Database altered.

SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;

GROUP#      BYTES

—— ———-

     4   52428800

     5   52428800

SQL> ALTER DATABASE ADD STANDBY LOGFILE (‘/home/oracle/app/oracle/oradata/orcl/s_redo03.log’) SIZE 52428800;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE (‘/home/oracle/app/oracle/oradata/orcl/s_redo04.log’) SIZE 52428800;

Database altered.

SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;

GROUP#      BYTES

—— ———-

     4   52428800

     5   52428800

     6   52428800

     7   52428800

SQL>

 

3. Modify the init.ora parameters:

 

Modify the init.ora parameters on the primary database side to reflect the following values. If you are using spfile, you can add these parameter online without shutting down the primary database.

 

DB_NAME=orcl

DB_UNIQUE_NAME=orcl

LOG_ARCHIVE_CONFIG=’DG_CONFIG=(orcl,sbyorcl)’

LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/app/oracle/flash_recovery_area/orcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl’

LOG_ARCHIVE_DEST_2=’SERVICE=sbyorcl ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=sbyorcl’

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

LOG_ARCHIVE_MAX_PROCESSES=30

FAL_SERVER=sbyorcl

DB_FILE_NAME_CONVERT=’sbyorcl’,’orcl’

LOG_FILE_NAME_CONVERT=’/home/oracle/app/oracle/flash_recovery_area/sbyorcl/’,’/home/oracle/app/oracle/flash_recovery_area/orcl/’

STANDBY_FILE_MANAGEMENT=AUTO

 

4. Enable Archiving :

Make sure that your database is running in archive log mode. Because in a physical standby setup all the redologs generated on the primary database will be transferred to standby site and applied to the standby database.

SQL> shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> STARTUP MOUNT;

ORACLE instance started.

 

Total System Global Area  456146944 bytes

Fixed Size                  1344840 bytes

Variable Size             381684408 bytes

Database Buffers           67108864 bytes

Redo Buffers                6008832 bytes

Database mounted.

SQL> ALTER DATABASE ARCHIVELOG;

 

Database altered.

 

SQL> ALTER DATABASE OPEN;

 

Database altered.

 

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/

Oldest online log sequence     360

Next log sequence to archive   362

Current log sequence           362

SQL>

  

5. Backup Primary Database Including Archive Logs With RMAN:

In this demo I am using RMAN to backup database. We will also include archive logs in the same backups. This RMAN database backup along with archive logs will be transferred to standby server and used for RMAN duplication to create a  standby database. There is another options like RMAN duplicate from active database to create physical standby database without even having the primary database backup in 11g. But in this article I am showing RMAN duplication with primary database backups. To know the step by step instruction to create a physical standby database with RMAN duplicate command without having primary database backups, follow my next articles <place holder>.

Create a temporary directory (/tmp/askm/) on primary server to keep all RMAN backups.

[oracle@dgaskmpri01 orcl]$ rman target /

Recovery Manager: Release 11.2.0.2.0 – Production on Mon Nov 21 05:08:01 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1229390655)

RMAN> run {
2> allocate channel t1 type disk format ‘/tmp/askm/%U’;
3> backup database plus archivelog;
4> }

using target database control file instead of recovery catalog
allocated channel: t1
channel t1: SID=79 device type=DISK

…..

…. 

6. Create a controlfile for Standby Database Using RMAN :

 

RMAN> run {
2> allocate channel t1 type disk format ‘/tmp/askm/%U’;
3> backup current controlfile for standby;
4> }

allocated channel: t1
channel t1: SID=79 device type=DISK

…….

……

 

7. Create a init.ora file for Standby Database:

 

SQL> CREATE PFILE=’/tmp/askm/initsbyorcl.ora’ FROM SPFILE;

 

File created.

 

8. Configure listener.ora and tnsnames.ora:

[oracle@dgaskmpri01 admin]$ cat listener.ora

LISTENER_PRI =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))

    )

  )

 

SID_LIST_LISTENER_PRI =

  (SID_LIST =

    (SID_DESC =

      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2)

      (SID_NAME = orcl)

    )

  )

[oracle@dgaskmpri01 admin]$ cat tnsnames.ora

orcl =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID=orcl)

    )

  )

 

sbyorcl =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID=sbyorcl)

    )

  )

[oracle@dgaskmpri01 admin]$

 

9.  Copy RMAN backups and configuration files to Standby Server:

Create a temporary directory(/tmp/askm) on standby server and copy RMAN backup pieces, init.ora, password file(orapwsbyorcl) and standby controlfile (created with RMAN) from primary server to standby server.

 

Standby Site Preparation :

1. Create a remote login password file ( if it is not copied from primary site )

Copy the password file /tmp/askm/orapwsbyorcl to $ORACLE_HOME/dbs

2. Create a directory structure

If you are using a different directory structure on the standby server, they you need to create all the directories on the standby site. Copy initsbyorcl.ora to $ORACLE_HOME/dbs location.

[oracle@dgaskmsby01]$ mkdir /home/oracle/app/oracle/oradata/sbyorcl/

[oracle@dgaskmsby01]$ mkdir /home/oracle/app/oracle/flash_recovery_area/sbyorcl/

[oracle@dgaskmsby01]$ cd $ORACLE_HOME/dbs

[oracle@dgaskmsby01 sbyorcl]$ cp /tmp/askm/initsbyorcl.ora $ORACLE_HOME/dbs

3.      Modify the init.ora parameter file

Modify the initsbyorcl.ora file to reflect the following initialization parameters.

 

DB_NAME=orcl

DB_UNIQUE_NAME=sbyorcl

LOG_ARCHIVE_CONFIG=’DG_CONFIG=(orcl,sbyorcl)’

CONTROL_FILES=’/home/oracle/app/oracle/oradata/sbyorcl/s_control01.ctl’, ‘/home/oracle/app/oracle/flash_recovery_area/sbyorcl/s_control02.ctl’

DB_FILE_NAME_CONVERT=’orcl’,’sbyorcl’

LOG_FILE_NAME_CONVERT=’/home/oracle/app/oracle/flash_recovery_area/orcl/’,’/home/oracle/app/oracle/flash_recovery_area/sbyorcl/’

LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=sbyorcl’

LOG_ARCHIVE_DEST_2=’SERVICE=orcl ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl’

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

STANDBY_FILE_MANAGEMENT=AUTO

FAL_SERVER=orcl

 

4. Configure listener.ora and tnsnames.ora:

[oracle@dgaskmsby01 admin]$ cat listener.ora

LISTENER_SBY =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))

    )

  )

 

SID_LIST_LISTENER_SBY =

  (SID_LIST =

    (SID_DESC =

      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2)

      (SID_NAME = sbyorcl)

    )

  )

[oracle@dgaskmsby01 admin]$ cat tnsnames.ora

orcl =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID=orcl)

    )

  )

 

sbyorcl =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID=sbyorcl)

    )

  )

[oracle@dgaskmsby01 admin]$

 

5.Verify connectivity

On Primary Server:

[oracle@dgaskmpri01]$ lsnrctl stop LISTENER_PRI

[oracle@dgaskmpri01]$ lsnrctl start LISTENER_PRI

[oracle@dgaskmpri01]$ tnsping orcl

[oracle@dgaskmpri01]$ tnsping sbyorcl

[oracle@dgaskmpri01]$ sqlplus sys/xxxxx@orcl

[oracle@dgaskmpri01]$ sqlplus sys/xxxxx@sbyorcl

 

On Standby Server:

[oracle@dgaskmsby01]$ lsnrctl stop LISTENER_SBY

[oracle@dgaskmsby01]$ lsnrctl start LISTENER_SBY

[oracle@dgaskmsby01]$ tnsping orcl

[oracle@dgaskmsby01]$ tnsping sbyorcl

[oracle@dgaskmsby01]$ sqlplus sys/xxxxx@orcl

[oracle@dgaskmsby01]$ sqlplus sys/xxxxx@sbyorcl

 

 

Creating Physical Standby Database :

1. Create Physical Standby Database Using RMAN Duplicate Command :

 

I assume that I don’t have any catalog database and I will execute the following duplicate command on my standby server.

[oracle@dgaskmsby01 sbyorcl]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Mon Nov 21 06:18:37 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             322964152 bytes
Database Buffers          125829120 bytes
Redo Buffers                6008832 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@dgaskmsby01 sbyorcl]$ rman target sys/oracle@orcl auxiliary /

Recovery Manager: Release 11.2.0.2.0 – Production on Mon Nov 21 06:19:02 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1229390655)
connected to auxiliary database: ORCL (not mounted)

RMAN> duplicate target database for standby dorecover;

Starting Duplicate Db at 21-NOV-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK

contents of Memory Script:
{
   set until scn  8516736;
   restore clone standby controlfile;
}
executing Memory Script

executing command: SET until clause

Starting restore at 21-NOV-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /tmp/askm/07ms6f0f_1_1
channel ORA_AUX_DISK_1: piece handle=/tmp/askm/07ms6f0f_1_1 tag=TAG20111121T052015
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/home/oracle/app/oracle/oradata/sbyorcl/s_control01.ctl
output file name=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/s_control02.ctl
Finished restore at 21-NOV-11

contents of Memory Script:
{
   sql clone ‘alter database mount standby database’;
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
   set until scn  8516736;
   set newname for tempfile  1 to
"/home/oracle/app/oracle/oradata/sbyorcl/temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
"/home/oracle/app/oracle/oradata/sbyorcl/system01.dbf";
   set newname for datafile  2 to
"/home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf";
   set newname for datafile  3 to
"/home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf";
   set newname for datafile  4 to
"/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf";
   set newname for datafile  5 to
"/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf";
   set newname for datafile  6 to
"/home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf";
   set newname for datafile  7 to
"/home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf";
   restore
   clone database
   ;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

renamed tempfile 1 to /home/oracle/app/oracle/oradata/sbyorcl/temp01.dbf in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 21-NOV-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/sbyorcl/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/sbyorcl/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /home/oracle/app/oracle/oradata/sbyorcl/example01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf
channel ORA_AUX_DISK_1: restoring datafile 00007 to /home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf
channel ORA_AUX_DISK_1: reading from backup piece /tmp/askm/04ms6ebl_1_1
channel ORA_AUX_DISK_1: piece handle=/tmp/askm/04ms6ebl_1_1 tag=TAG20111121T050908
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:06:38
Finished restore at 21-NOV-11

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=3 STAMP=767781512 file name=/home/oracle/app/oracle/oradata/sbyorcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=4 STAMP=767781512 file name=/home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=767781512 file name=/home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=767781512 file name=/home/oracle/app/oracle/oradata/sbyorcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=7 STAMP=767781512 file name=/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=767781512 file name=/home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=9 STAMP=767781512 file name=/home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf

contents of Memory Script:
{
   set until scn  8516736;
   recover
   standby
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 21-NOV-11
using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=453
…..
…..
…..
archived log file name=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/1_512_701609923.arc thread=1 sequence=512
channel clone_default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/1_512_701609923.arc RECID=59 STAMP=767781543
archived log file name=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/1_513_701609923.arc thread=1 sequence=513
channel clone_default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/1_513_701609923.arc RECID=5 STAMP=767781541
media recovery complete, elapsed time: 00:00:26
Finished recover at 21-NOV-11
ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

RMAN-05535: WARNING: All redo log files were not defined properly.
ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

RMAN-05535: WARNING: All redo log files were not defined properly.
ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

RMAN-05535: WARNING: All redo log files were not defined properly.
ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

RMAN-05535: WARNING: All redo log files were not defined properly.
ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

RMAN-05535: WARNING: All redo log files were not defined properly.
ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

RMAN-05535: WARNING: All redo log files were not defined properly.
ORACLE error from auxiliary database: ORA-01511: error in renaming log/data files
ORA-01275: Operation RENAME is not allowed if standby file management is automatic.

RMAN-05535: WARNING: All redo log files were not defined properly.
Finished Duplicate Db at 21-NOV-11

RMAN>

Note : You can ignore the above warning messages in the session log as these are due to the parameter STANDBY_FILE_MANAGEMENT is set to AUTO.

2. Keep it in recovery:

 

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

 

Verifications :

On Standby:

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

On Primary :

Do some redo log switches

SQL> ALTER SYSTEM SWITCH LOGFILE;

On Standby:

  Verify that the recent archived log file is shifted to standby side and applied with the following commands.

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 

Other Useful Information:

To verify all the init.ora parameter in a single command:

egrep -i "DB_NAME|DB_UNIQUE_NAME|LOG_ARCHIVE_CONFIG|CONTROL_FILES|LOG_ARCHIVE_DEST_1|

LOG_ARCHIVE_DEST_2|LOG_ARCHIVE_DEST_STATE_1|LOG_ARCHIVE_DEST_STATE_2|

REMOTE_LOGIN_PASSWORDFILE|LOG_ARCHIVE_FORMAT|LOG_ARCHIVE_MAX_PROCESSES|

FAL_SERVER|DB_FILE_NAME_CONVERT|LOG_FILE_NAME_CONVERT|STANDBY_FILE_MANAGEMENT" <specify init.ora parameter file>

 

To Cancel the Standby Recovery Mode:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

 

Useful commands To Troubleshoot:

select message from v$dataguard_status where dest_id = 2;

select archived_thread#, archived_seq#, applied_thread#, applied_seq# from v$archive_dest_status;

select registrar, creator, thread#, sequence#, first_change#, next_change# from v$archived_log;

select thread#, sequence#, first_change#, next_change# from v$log_history;

 

To Verify Recover Process On Standby:

select thread#, sequence# from v$log where status=’CURRENT’;  = >  On Primary

select thread#, sequence#, status from v$managed_standby where process=’MRP0′; = > On Standby

 

References :

MOS ID : 789370.1

Hope It Helps

SRI

 

 

Posted in Data Guard | Tagged: , , , , , , , , , , , , , | 5 Comments »

Creating Physycal Standby With RMAN Recovery Option

Posted by Srikrishna Murthy Annam on December 19, 2011

In this article, I am going to explain step by step procedure to create a physical standby database using RMAN with database restore and recovery. We can also create physical standby database using RMAN duplicate, but in this article we are creating physical standby database without duplicate command.

  1. Backup primary database ( including archive logs)
  2. Backup controlfile for Standby database
  3. Copy created RMAN backups to standby server
  4. Modify init.ora parameters on primary and standby servers
  5. Configure listener.ora and tnsnames.ora on primary and standby
  6. Verify the connectivity on primary and standby
  7. Restore database on the standby server
  8. Recover database on the standby server
  9. Put the database in Managed Recovery mode on standby server


1. Backup Primary Database :

In this step we are backing up primary database including archive logs.

SQL> select name,user from v$database;
NAME      USER
——— ——————————
ORCL      SYS

SQL> select GROUP#,THREAD#,MEMBERS,BYTES FROM V$LOG;
GROUP#    THREAD#    MEMBERS      BYTES
———- ———- ———- ———-
1          1          1   52428800
2          1          1   52428800
3          1          1   52428800

SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;
GROUP#      BYTES
———- ———-
4   52428800
5   52428800
6   52428800
7   52428800

SQL> sho parameter spfile;
NAME                                 TYPE        VALUE
———————————— ———– ——————————
spfile                               string      /home/oracle/app/oracle/produc
t/11.2.0/dbhome_2/dbs/spfileor
cl.ora
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@dgaskmpri01 orcl]$ clear
[oracle@dgaskmpri01 orcl]$ rman target /

Recovery Manager: Release 11.2.0.2.0 – Production on Mon Nov 21 05:08:01 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1229390655)

RMAN> run {
2> allocate channel t1 type disk format ‘/tmp/askm/%U’;
3> backup database plus archivelog;
4> }

using target database control file instead of recovery catalog
allocated channel: t1
channel t1: SID=79 device type=DISK

Starting backup at 21-NOV-11
current log archived
channel t1: starting archived log backup set
channel t1: specifying archived log(s) in backup set
input archived log thread=1 sequence=370 RECID=10 STAMP=766832613
……………………………..

…………………………….

input archived log thread=1 sequence=443 RECID=137 STAMP=767436824
input archived log thread=1 sequence=444 RECID=138 STAMP=767436837
input archived log thread=1 sequence=445 RECID=139 STAMP=767436927
channel t1: starting piece 1 at 21-NOV-11
channel t1: finished piece 1 at 21-NOV-11
piece handle=/tmp/askm/02ms6eba_1_1 tag=TAG20111121T050849 comment=NONE
channel t1: backup set complete, elapsed time: 00:00:07
channel t1: starting archived log backup set
channel t1: specifying archived log(s) in backup set
input archived log thread=1 sequence=446 RECID=140 STAMP=767436935
input archived log thread=1 sequence=447 RECID=141 STAMP=767436937
input archived log thread=1 sequence=448 RECID=142 STAMP=767436952
input archived log thread=1 sequence=449 RECID=146 STAMP=767436985
input archived log thread=1 sequence=450 RECID=148 STAMP=767436997
input archived log thread=1 sequence=451 RECID=150 STAMP=767768458
input archived log thread=1 sequence=452 RECID=151 STAMP=767768928
channel t1: starting piece 1 at 21-NOV-11
channel t1: finished piece 1 at 21-NOV-11
piece handle=/tmp/askm/03ms6ebi_1_1 tag=TAG20111121T050849 comment=NONE
channel t1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-NOV-11

Starting backup at 21-NOV-11
channel t1: starting full datafile backup set
channel t1: specifying datafile(s) in backup set
input datafile file number=00002 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00004 name=/home/oracle/app/oracle/oradata/orcl/users01.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/home/oracle/app/oracle/oradata/orcl/example01.dbf
input datafile file number=00007 name=/home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf
input datafile file number=00006 name=/home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf
channel t1: starting piece 1 at 21-NOV-11
channel t1: finished piece 1 at 21-NOV-11
piece handle=/tmp/askm/04ms6ebl_1_1 tag=TAG20111121T050908 comment=NONE
channel t1: backup set complete, elapsed time: 00:09:36
channel t1: starting full datafile backup set
channel t1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel t1: starting piece 1 at 21-NOV-11
channel t1: finished piece 1 at 21-NOV-11
piece handle=/tmp/askm/05ms6etl_1_1 tag=TAG20111121T050908 comment=NONE
channel t1: backup set complete, elapsed time: 00:00:04
Finished backup at 21-NOV-11

Starting backup at 21-NOV-11
current log archived
channel t1: starting archived log backup set
channel t1: specifying archived log(s) in backup set
input archived log thread=1 sequence=453 RECID=152 STAMP=767769533
channel t1: starting piece 1 at 21-NOV-11
channel t1: finished piece 1 at 21-NOV-11
piece handle=/tmp/askm/06ms6etu_1_1 tag=TAG20111121T051853 comment=NONE
channel t1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-NOV-11
released channel: t1

RMAN>

2. Backup controlfile for Standby database :

RMAN> run {
2> allocate channel t1 type disk format ‘/tmp/askm/%U’;
3> backup current controlfile for standby;
4> }

allocated channel: t1
channel t1: SID=79 device type=DISK

Starting backup at 21-NOV-11
channel t1: starting full datafile backup set
channel t1: specifying datafile(s) in backup set
including standby control file in backup set
channel t1: starting piece 1 at 21-NOV-11
channel t1: finished piece 1 at 21-NOV-11
piece handle=/tmp/askm/07ms6f0f_1_1 tag=TAG20111121T052015 comment=NONE
channel t1: backup set complete, elapsed time: 00:00:02
Finished backup at 21-NOV-11
released channel: t1

RMAN>

3. Copy created RMAN backups to standby server  :

[root@dgaskmsby01 askm]# scp 192.168.1.34:/tmp/askm/* .
root@192.168.1.34’s password:
01ms6eb2_1_1                                                                                                                          100%   29MB   1.5MB/s   00:19
02ms6eba_1_1                                                                                                                          100%   23MB   1.9MB/s   00:12
03ms6ebi_1_1                                                                                                                          100% 1292KB   1.3MB/s   00:00
04ms6ebl_1_1                                                                                                                          100% 1916MB   1.6MB/s   20:05
05ms6etl_1_1                                                                                                                          100% 9824KB   2.4MB/s   00:04
06ms6etu_1_1                                                                                                                          100% 2049KB   2.0MB/s   00:01
07ms6f0f_1_1                                                                                                                          100% 9792KB   3.2MB/s   00:03
[root@dgaskmsby01 askm]# ls -lrt
total 2039416
-rw-r—– 1 root root   30110720 Nov 21 05:21 01ms6eb2_1_1
-rw-r—– 1 root root    1322496 Nov 21 05:21 03ms6ebi_1_1
-rw-r—– 1 root root   23854080 Nov 21 05:21 02ms6eba_1_1
-rw-r—– 1 root root 2008809472 Nov 21 05:42 04ms6ebl_1_1
-rw-r—– 1 root root   10059776 Nov 21 05:42 05ms6etl_1_1
-rw-r—– 1 root root    2097664 Nov 21 05:42 06ms6etu_1_1
-rw-r—– 1 root root   10027008 Nov 21 05:42 07ms6f0f_1_1
[root@dgaskmsby01 askm]# chown oracle:oracle *
[root@dgaskmsby01 askm]# ls -lrt
total 2039416
-rw-r—– 1 oracle oracle   30110720 Nov 21 05:21 01ms6eb2_1_1
-rw-r—– 1 oracle oracle    1322496 Nov 21 05:21 03ms6ebi_1_1
-rw-r—– 1 oracle oracle   23854080 Nov 21 05:21 02ms6eba_1_1
-rw-r—– 1 oracle oracle 2008809472 Nov 21 05:42 04ms6ebl_1_1
-rw-r—– 1 oracle oracle   10059776 Nov 21 05:42 05ms6etl_1_1
-rw-r—– 1 oracle oracle    2097664 Nov 21 05:42 06ms6etu_1_1
-rw-r—– 1 oracle oracle   10027008 Nov 21 05:42 07ms6f0f_1_1
[root@dgaskmsby01 askm]# chmod 660 *
[root@dgaskmsby01 askm]# ls -lrt
total 2039416
-rw-rw—- 1 oracle oracle   30110720 Nov 21 05:21 01ms6eb2_1_1
-rw-rw—- 1 oracle oracle    1322496 Nov 21 05:21 03ms6ebi_1_1
-rw-rw—- 1 oracle oracle   23854080 Nov 21 05:21 02ms6eba_1_1
-rw-rw—- 1 oracle oracle 2008809472 Nov 21 05:42 04ms6ebl_1_1
-rw-rw—- 1 oracle oracle   10059776 Nov 21 05:42 05ms6etl_1_1
-rw-rw—- 1 oracle oracle    2097664 Nov 21 05:42 06ms6etu_1_1
-rw-rw—- 1 oracle oracle   10027008 Nov 21 05:42 07ms6f0f_1_1

4. Modify init.ora parameters on primary and standby servers  :

On Primary :

DB_NAME=orcl
DB_UNIQUE_NAME=orcl
LOG_ARCHIVE_CONFIG=’DG_CONFIG=(orcl,sbyorcl)’
LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/app/oracle/flash_recovery_area/orcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl’
LOG_ARCHIVE_DEST_2=’SERVICE=sbyorcl ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=sbyorcl’
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=sbyorcl
DB_FILE_NAME_CONVERT=’sbyorcl’,’orcl’
LOG_FILE_NAME_CONVERT=’/home/oracle/app/oracle/flash_recovery_area/sbyorcl/’,’/home/oracle/app/oracle/flash_recovery_area/orcl/’
STANDBY_FILE_MANAGEMENT=AUTO

On Standby :

DB_NAME=orcl
DB_UNIQUE_NAME=sbyorcl
LOG_ARCHIVE_CONFIG=’DG_CONFIG=(orcl,sbyorcl)’
CONTROL_FILES=’/home/oracle/app/oracle/oradata/sbyorcl/s_control01.ctl’, ‘/home/oracle/app/oracle/flash_recovery_area/sbyorcl/s_control02.ctl’
DB_FILE_NAME_CONVERT=’orcl’,’sbyorcl’
LOG_FILE_NAME_CONVERT=’/home/oracle/app/oracle/flash_recovery_area/orcl/’,’/home/oracle/app/oracle/flash_recovery_area/sbyorcl/’
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_DEST_1=’LOCATION=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=sbyorcl’
LOG_ARCHIVE_DEST_2=’SERVICE=orcl ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl’
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=orcl

5. Configure listener.ora and tnsnames.ora on primary and standby :

On Primary :

[oracle@dgaskmpri01 admin]$ cat listener.ora
LISTENER_PRI =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))
)
)

SID_LIST_LISTENER_PRI =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2)
(SID_NAME = orcl)
)
)
[oracle@dgaskmpri01 admin]$ cat tnsnames.ora
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID=orcl)
)
)

sbyorcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID=sbyorcl)
)
)
[oracle@dgaskmpri01 admin]$

On Standby :

[oracle@dgaskmsby01 admin]$ cat listener.ora
LISTENER_SBY =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))
)
)

SID_LIST_LISTENER_SBY =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2)
(SID_NAME = sbyorcl)
)
)
[oracle@dgaskmsby01 admin]$ cat tnsnames.ora
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID=orcl)
)
)

sbyorcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID=sbyorcl)
)
)
[oracle@dgaskmsby01 admin]$

6. Verify the connectivity on primary and standby :

On Primary Server:
[oracle@dgaskmpri01]$ lsnrctl stop LISTENER_PRI
[oracle@dgaskmpri01]$ lsnrctl start LISTENER_PRI
[oracle@dgaskmpri01]$ tnsping orcl
[oracle@dgaskmpri01]$ tnsping sbyorcl
[oracle@dgaskmpri01]$ sqlplus sys/xxxxx@orcl
[oracle@dgaskmpri01]$ sqlplus sys/xxxxx@sbyorcl

On Standby Server:
[oracle@dgaskmsby01]$ lsnrctl stop LISTENER_SBY
[oracle@dgaskmsby01]$ lsnrctl start LISTENER_SBY
[oracle@dgaskmsby01]$ tnsping orcl
[oracle@dgaskmsby01]$ tnsping sbyorcl
[oracle@dgaskmsby01]$ sqlplus sys/xxxxx@orcl
[oracle@dgaskmsby01]$ sqlplus
sys/xxxxx@sbyorcl

7. Restore database on the standby server :

[oracle@dgaskmsby01 dbs]$ rman target /

Recovery Manager: Release 11.2.0.2.0 – Production on Mon Nov 21 05:47:02 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area     456146944 bytes

Fixed Size                     1344840 bytes
Variable Size                322964152 bytes
Database Buffers             125829120 bytes
Redo Buffers                   6008832 bytes

RMAN> set dbid=1229390655;  ( Get dbid from primary database using select dbid from v$database )

executing command: SET DBID

RMAN> restore standby controlfile from ‘/tmp/askm/07ms6f0f_1_1’; (find controlfile backup using “list backup of controlfile”)

Starting restore at 21-NOV-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/home/oracle/app/oracle/oradata/sbyorcl/s_control01.ctl
output file name=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/s_control02.ctl
Finished restore at 21-NOV-11

RMAN> sql ‘alter database mount standby database’;

sql statement: alter database mount standby database
released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 21-NOV-11
Starting implicit crosscheck backup at 21-NOV-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=70 device type=DISK
Crosschecked 6 objects
Finished implicit crosscheck backup at 21-NOV-11

Starting implicit crosscheck copy at 21-NOV-11
using channel ORA_DISK_1
Crosschecked 2 objects
Finished implicit crosscheck copy at 21-NOV-11

searching for all files in the recovery area
cataloging files…
no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/sbyorcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/sbyorcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/sbyorcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/sbyorcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/app/oracle/oradata/sbyorcl/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /home/oracle/app/oracle/oradata/sbyorcl/APEX_1246426611663638.dbf
channel ORA_DISK_1: restoring datafile 00007 to /home/oracle/app/oracle/oradata/sbyorcl/APEX_1265209995679366.dbf
channel ORA_DISK_1: reading from backup piece /tmp/askm/04ms6ebl_1_1
channel ORA_DISK_1: piece handle=/tmp/askm/04ms6ebl_1_1 tag=TAG20111121T050908
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:06:43
Finished restore at 21-NOV-11

RMAN>

8. Recover database on the standby server :

In the recovery we need to recover database till the sequence number that we backed up on primary. So we first need to find out the sequence until which we need to recover database. As we got the controlfile on standby server from primary, it contains the archive log information.

RMAN> list backup of archivelog all;

List of Backup Sets
===================

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
1       28.72M     DISK        00:00:04     21-NOV-11
BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20111121T050849
Piece Name: /tmp/askm/01ms6eb2_1_1

  List of Archived Logs in backup set 1
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    370     8283932    10-NOV-11 8294856    10-NOV-11
1    371     8294856    10-NOV-11 8295635    15-NOV-11
1    372     8295635    15-NOV-11 8295841    15-NOV-11
1    373     8295841    15-NOV-11 8299622    15-NOV-11
1    374     8299622    15-NOV-11 8299779    15-NOV-11
1    375     8299779    15-NOV-11 8299786    15-NOV-11
1    376     8299786    15-NOV-11 8300508    15-NOV-11
1    377     8300508    15-NOV-11 8303447    16-NOV-11
1    378     8303447    16-NOV-11 8303644    16-NOV-11
1    379     8303644    16-NOV-11 8304443    16-NOV-11
1    380     8304443    16-NOV-11 8306427    16-NOV-11
1    381     8306427    16-NOV-11 8311445    16-NOV-11

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
2       22.75M     DISK        00:00:04     21-NOV-11
BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20111121T050849
Piece Name: /tmp/askm/02ms6eba_1_1

  List of Archived Logs in backup set 2
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    382     8311445    16-NOV-11 8331453    16-NOV-11
1    383     8331453    16-NOV-11 8331456    16-NOV-11
1    384     8331456    16-NOV-11 8331535    16-NOV-11
1    385     8331535    16-NOV-11 8331848    16-NOV-11
1    386     8331848    16-NOV-11 8331991    16-NOV-11
1    387     8331991    16-NOV-11 8332501    16-NOV-11
1    388     8332501    16-NOV-11 8352510    16-NOV-11
1    389     8352510    16-NOV-11 8352513    16-NOV-11
1    390     8352513    16-NOV-11 8352520    16-NOV-11
1    391     8352520    16-NOV-11 8352812    16-NOV-11
1    392     8352812    16-NOV-11 8352893    16-NOV-11
1    393     8352893    16-NOV-11 8356299    16-NOV-11
1    394     8356299    16-NOV-11 8356573    16-NOV-11
1    395     8356573    16-NOV-11 8359371    16-NOV-11
1    396     8359371    16-NOV-11 8359432    16-NOV-11
1    397     8359432    16-NOV-11 8359877    17-NOV-11
1    398     8359877    17-NOV-11 8359922    17-NOV-11
1    399     8359922    17-NOV-11 8360248    17-NOV-11
1    400     8360248    17-NOV-11 8360292    17-NOV-11
1    401     8360292    17-NOV-11 8360731    17-NOV-11
1    402     8360731    17-NOV-11 8361395    17-NOV-11
1    403     8361395    17-NOV-11 8381405    17-NOV-11
1    404     8381405    17-NOV-11 8381408    17-NOV-11
1    405     8381408    17-NOV-11 8381599    17-NOV-11
1    406     8381599    17-NOV-11 8381636    17-NOV-11
1    407     8381636    17-NOV-11 8384663    17-NOV-11
1    408     8384663    17-NOV-11 8384724    17-NOV-11
1    409     8384724    17-NOV-11 8384813    17-NOV-11
1    410     8384813    17-NOV-11 8405084    17-NOV-11
1    411     8405084    17-NOV-11 8405087    17-NOV-11
1    412     8405087    17-NOV-11 8405116    17-NOV-11
1    413     8405116    17-NOV-11 8405193    17-NOV-11
1    414     8405193    17-NOV-11 8405410    17-NOV-11
1    415     8405410    17-NOV-11 8405440    17-NOV-11
1    416     8405440    17-NOV-11 8408755    17-NOV-11
1    417     8408755    17-NOV-11 8408924    17-NOV-11
1    418     8408924    17-NOV-11 8409211    17-NOV-11
1    419     8409211    17-NOV-11 8409218    17-NOV-11
1    420     8409218    17-NOV-11 8409575    17-NOV-11
1    421     8409575    17-NOV-11 8409813    17-NOV-11
1    422     8409813    17-NOV-11 8410578    17-NOV-11
1    423     8410578    17-NOV-11 8430587    17-NOV-11
1    424     8430587    17-NOV-11 8430590    17-NOV-11
1    425     8430590    17-NOV-11 8430598    17-NOV-11
1    426     8430598    17-NOV-11 8430913    17-NOV-11
1    427     8430913    17-NOV-11 8431165    17-NOV-11
1    428     8431165    17-NOV-11 8431186    17-NOV-11
1    429     8431186    17-NOV-11 8432049    17-NOV-11
1    430     8432049    17-NOV-11 8452060    17-NOV-11
1    431     8452060    17-NOV-11 8452063    17-NOV-11
1    432     8452063    17-NOV-11 8452070    17-NOV-11
1    433     8452070    17-NOV-11 8452190    17-NOV-11
1    434     8452190    17-NOV-11 8452423    17-NOV-11
1    435     8452423    17-NOV-11 8452439    17-NOV-11
1    436     8452439    17-NOV-11 8453802    17-NOV-11
1    437     8453802    17-NOV-11 8454030    17-NOV-11
1    438     8454030    17-NOV-11 8454220    17-NOV-11
1    439     8454220    17-NOV-11 8474230    17-NOV-11
1    440     8474230    17-NOV-11 8474233    17-NOV-11
1    441     8474233    17-NOV-11 8474463    17-NOV-11
1    442     8474463    17-NOV-11 8474511    17-NOV-11
1    443     8474511    17-NOV-11 8474680    17-NOV-11
1    444     8474680    17-NOV-11 8474693    17-NOV-11
1    445     8474693    17-NOV-11 8494871    17-NOV-11

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
3       1.26M      DISK        00:00:01     21-NOV-11
BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20111121T050849
Piece Name: /tmp/askm/03ms6ebi_1_1

  List of Archived Logs in backup set 3
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    446     8494871    17-NOV-11 8494874    17-NOV-11
1    447     8494874    17-NOV-11 8494901    17-NOV-11
1    448     8494901    17-NOV-11 8495084    17-NOV-11
1    449     8495084    17-NOV-11 8495266    17-NOV-11
1    450     8495266    17-NOV-11 8495280    17-NOV-11
1    451     8495280    17-NOV-11 8496187    21-NOV-11
1    452     8496187    21-NOV-11 8497172    21-NOV-11

BS Key  Size       Device Type Elapsed Time Completion Time
——- ———- ———– ———— —————
6       2.00M      DISK        00:00:00     21-NOV-11
BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20111121T051853
Piece Name: /tmp/askm/06ms6etu_1_1

  List of Archived Logs in backup set 6
Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
—- ——- ———- ——— ———- ———
1    453     8497172    21-NOV-11 8498444    21-NOV-11

RMAN>

The last sequence number from the above session log is 453. So we need to recover database on standby untill sequence number 454.

RMAN> recover database until sequence 454;

Starting recover at 21-NOV-11
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=453
channel ORA_DISK_1: reading from backup piece /tmp/askm/06ms6etu_1_1
channel ORA_DISK_1: piece handle=/tmp/askm/06ms6etu_1_1 tag=TAG20111121T051853
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
archived log file name=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/1_453_701609923.arc thread=1 sequence=453
Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: ‘/home/oracle/app/oracle/oradata/sbyorcl/system01.dbf’

media recovery complete, elapsed time: 00:00:10
Finished recover at 21-NOV-11

RMAN> exit

If you get any warnings, ( something like we got in the above session log) , we can ignore it.

9. Put the database in Managed Recovery mode on standby server :

[oracle@dgaskmsby01 dbs]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Mon Nov 21 05:59:36 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Database altered.

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
—————- ——————–
PHYSICAL STANDBY TO PRIMARY

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

Verify on the Primary :

[oracle@dgaskmpri01 askm]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Mon Nov 21 06:01:51 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
—————- ——————–
PRIMARY          RESOLVABLE GAP

SQL>

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
—————- ——————–
PRIMARY          TO STANDBY

SQL>

This is how we will create physical standby database with RMAN recovery option. I am going to explain in my next article the process of creating a physical standby database with RMAN duplicate option.

References : 469493.1

Hope it helps

SRI

Posted in Data Guard | Tagged: , , , , , , , , , , | 1 Comment »

Creating A Dataguard Broker Configuration Using DGMGRL

Posted by Srikrishna Murthy Annam on December 13, 2011

            In this article we will see step by step instructions on how to configure dataguard broker configuration using DGMGRL utility. The dataguard broker makes it easy to maintain and administer several standby databases. Dataguard broker maintains its own configuration files and runs a background process DMON both on primary and standby database servers. Dataguard broker configuration can be created using either OEM grid control or using a command line utility DGMGRL. In the present article we are using DGMGRL to create dataguard broker configuration to maintain standby databases.

Setup:

 

Primary Site

Standby Site

Hostname

dgaskmpri01

dgaskmsby01

Database Name

orcl

orcl

Database Unique Name

orcl

sbyorcl

Net Service Name

orcl

sbyorcl

 

  1. Prepare Primary Site ( Modify init.ora and listener.ora )
  2. Prepare Standby site ( Modify init.ora and listener.ora )
  3. Create Dataguard configuration
  4. Adding Standby Database
  5. Verify the Configuration
  6. Enable Configuration
  7. Verifying Configuration With Switchover
  8. Monitoring DataGuard Broker Configuration
Prepared By SRI

1.Prepare Primary Site :

Init.ora Changes: DB_BROKER_CONFIG_FILEn parameter is used to specify the location of the dataguard configuration. DG_BROKER_START parameter is used to start the broker automatically when the instance starts.

SQL> alter system set dg_broker_config_file1=’/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/dr1orcl.dat’ sid=’*’;

System altered.

SQL> alter system set dg_broker_config_file2=’/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/dr2orcl.dat’ sid=’*’;

System altered.

SQL> alter system set dg_broker_start=true  sid=’*’;

System altered.

Listener.ora Changes : GLOBAL_DBNAME attribute value should be set as shown in the following listener.ora configuraiton on primary site otherwise you will get TNS-12154 error during switch over configuration. A service with name <sid>_DGMGRL will be started when the listener is started.

[oracle@dgaskmpri01 admin]$ cat listener.ora 
LISTENER_PRI = 
  (DESCRIPTION_LIST = 
    (DESCRIPTION = 
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525)) 
    ) 
    (DESCRIPTION = 
      (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525)) 
    ) 
  )

SID_LIST_LISTENER_PRI = 
  (SID_LIST = 
    (SID_DESC = 
      (GLOBAL_DBNAME = orcl_DGMGRL.localdomain) 
      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2) 
      (SID_NAME = orcl) 
      (SERVICE_NAME = orcl.localdomain) 
    ) 
  ) 
[oracle@dgaskmpri01 admin]$

2. Prepare Standby site:

Init.ora Changes:

SQL> alter system set dg_broker_config_file1=’/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/dr1sbyorcl.dat’ sid=’*’;

System altered.

SQL> alter system set dg_broker_config_file2=’/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/dr2sbyorcl.dat’ sid=’*’;

System altered.

SQL> alter system set dg_broker_start=true  sid=’*’;

System altered.

Listener.ora Changes:

[oracle@dgaskmsby01 admin]$ cat listener.ora 
LISTENER_SBY = 
  (DESCRIPTION_LIST = 
    (DESCRIPTION = 
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525)) 
    ) 
    (DESCRIPTION = 
      (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525)) 
    ) 
  )

SID_LIST_LISTENER_SBY = 
  (SID_LIST = 
    (SID_DESC = 
      (GLOBAL_DBNAME = sbyorcl_DGMGRL.localdomain) 
      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2) 
      (SID_NAME = sbyorcl) 
      (SERVICE_NAME = sbyorcl.localdomain) 
    ) 
  ) 
[oracle@dgaskmsby01 admin]$

3. Create Dataguard configuration:

On the primary Database Server connect to database using DGMGRL utility.

[oracle@dgaskmpri01 dbs]$ dgmgrl

DGMGRL for Linux: Version 11.2.0.2.0 – Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle

Connected.

DGMGRL> CREATE CONFIGURATION ‘askm_config’ AS PRIMARY DATABASE IS ‘orcl’ CONNECT IDENTIFIER IS orcl;

Configuration "askm_config" created with primary database "orcl"

DGMGRL> show configuration;

Configuration – askm_config

  Protection Mode: MaxPerformance

  Databases:

    orcl – Primary database

Fast-Start Failover: DISABLED

Configuration Status:

DISABLED

DGMGRL>

In the created configuration command,

askm_config = It is the name of the configuration. And it can be anything that your choice.

Primary Database is ‘orcl’ = Here ‘orcl’  is primary database db_unique_name value

Connect Identifier is ‘orcl’ = Here ‘orcl’  is alias name defined in tnsnames.ora to connect to primary database.

4. Adding Standby Databas:

DGMGRL> ADD DATABASE ‘sbyorcl’ AS CONNECT IDENTIFIER IS sbyorcl MAINTAINED AS PHYSICAL;

Database "sbyorcl" added

DGMGRL> show configuration;

Configuration – askm_config

  Protection Mode: MaxPerformance

  Databases:

    orcl    – Primary database

    sbyorcl – Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

DISABLED

DGMGRL>

6. Enable Configuration:

DGMGRL> help enable configuration;

Enables a configuration, a database, or fast-start failover

Syntax:

  ENABLE CONFIGURATION;

  ENABLE DATABASE <database name>;

  ENABLE FAST_START FAILOVER [CONDITION <condition>];

DGMGRL> enable configuration;

Enabled.

DGMGRL> show configuration;

Configuration – askm_config

  Protection Mode: MaxPerformance

  Databases:

    orcl    – Primary database

    sbyorcl – Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS

DGMGRL>

7. Verifying Configuration With Switchover:

[oracle@dgaskmpri01 dbs]$ dgmgrl

DGMGRL for Linux: Version 11.2.0.2.0 – Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle

Connected.

DGMGRL> switchover to ‘sbyorcl’;

Performing switchover NOW, please wait…

New primary database "sbyorcl" is opening…

Operation requires shutdown of instance "orcl" on database "orcl"

Shutting down instance "orcl"…

ORACLE instance shut down.

Operation requires startup of instance "orcl" on database "orcl"

Starting instance "orcl"…

ORACLE instance started.

Database mounted.

Switchover succeeded, new primary is "sbyorcl"

DGMGRL>

DGMGRL> exit

[oracle@dgaskmpri01 dbs]$ clear

[oracle@dgaskmpri01 dbs]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Thu Nov 17 08:54:54 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS

—————- ——————–

PHYSICAL STANDBY NOT ALLOWED

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@dgaskmpri01 dbs]$ dgmgrl

DGMGRL for Linux: Version 11.2.0.2.0 – Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/oracle

Connected.

DGMGRL> switchover to ‘orcl’;

Performing switchover NOW, please wait…

New primary database "orcl" is opening…

Operation requires shutdown of instance "sbyorcl" on database "sbyorcl"

Shutting down instance "sbyorcl"…

ORACLE instance shut down.

Operation requires startup of instance "sbyorcl" on database "sbyorcl"

Starting instance "sbyorcl"…

ORACLE instance started.

Database mounted.

Switchover succeeded, new primary is "orcl"

DGMGRL> exit

[oracle@dgaskmpri01 dbs]$ sqlplus ‘/as sysdba’

SQL*Plus: Release 11.2.0.2.0 Production on Thu Nov 17 08:56:46 2011

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS

—————- ——————–

PRIMARY          TO STANDBY

SQL>

8. Monitoring DataGuard Broker Configuration:

DGMGRL> help DGMGRL> show configuration;

DGMGRL> edit database "orcl" set property LogXptMode=’SYNC’;

DGMGRL> show database ‘orcl’ ‘LogXptStatus’;

DGMGRL> edit configuration set protection mode as MaxAvailability;

DGMGRL> enable fast_start failover; DGMGRL> show database ‘orcl’;

DGMGRL> enable database ‘orcl’; DGMGRL> remove configuration;

DGMGRL> show database verbose orcl;

DGMGRL> show database orcl InconsistentProperties

DGMGRL> show database ‘orcl’ ‘StatusReport’;

Reference :

http://docs.oracle.com/cd/B12037_01/server.101/b10822/cli.htm
Setup and maintenance of Data Guard Broker using DGMGRL [ID 201669.1]
10g DGMGRL CLI Configuration [ID 260112.1]
Unable To Recreate Data Guard Fast Start Failover Configuration With DGMGRL [ID 454418.1]
Creating a configuration using Data Guard Manager [ID 214071.1]
Interaction Between the Data Guard Broker and a Data Guard Configuration [ID 249703.1]
http://www.izzysoft.de/oracle/ifaqmaker.php?id=7;toc=1
Hope It Helps
SRI

Posted in Data Guard | Tagged: , , , , , , , | 11 Comments »

Creating A Physical Standby Database (11gR2)

Posted by Srikrishna Murthy Annam on December 7, 2011

Setup:

 

Primary Site

Standby Site

Hostname

dgaskmpri01

dgaskmsby01

Database Name

orcl

orcl

Database Unique Name

orcl

sbyorcl

Net Service Name

orcl

sbyorcl

 

Prepared By SRI
Prepared By SRI

Primary Site Preparation :

1.      Enable Database Force Logging

2.      Create SRL (Standby Redo Logs)

3.      Modify Init.ora parameters

4.      Enable Archiving

5.      Backup Primary Database

6.      Create a controlfile for Standby Database

7.      Create a init.ora file for Standby Database

8.      Configure listener.ora and tnsnames.ora

9.      Copy backups and configuration files to Standby Server

 

Standby Site Preparation :

1.      Create a remote login password file ( if it is not copied from primary site )

2.      Create a directory structure

3.      Modify the init.ora parameter file

4.      Configure listener.ora and tnsnames.ora

5.      Verify connectivity

 

Creating Physical Standby Database :

1.      Start the physical Standby Database

2.      Keep it in recovery

 

Verifications

 

Primary Site Preparation :

1.      Enable Database Force Logging:

SQL>  select FORCE_LOGGING from v$database;
SQL> ALTER DATABASE FORCE LOGGING;

2.      Create SRL ( Standby Redo Logs):

You need to create SRL with the same size or greater size as of the online redo logs and also the number of SRLs should be one greater than the online redologs.

SQL> select name,user from v$database;
NAME      USER
--------- ------------------------------
ORCL      SYS
SQL> col group# for 9999
SQL> col member for a50
SQL> set linesize 120
SQL> select name,user from v$database;
NAME      USER
--------- ------------------------------
ORCL      SYS
SQL> select GROUP#,THREAD#,MEMBERS,BYTES FROM V$LOG;
GROUP#    THREAD#    MEMBERS      BYTES
------ ---------- ---------- ----------
     1          1          1   52428800
     2          1          1   52428800
     3          1          1   52428800
SQL> select group#,member from v$logfile;
GROUP# MEMBER
------ --------------------------------------------------
     3 /home/oracle/app/oracle/oradata/orcl/redo03.log
     2 /home/oracle/app/oracle/oradata/orcl/redo02.log
     1 /home/oracle/app/oracle/oradata/orcl/redo01.log
SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;
no rows selected
SQL> ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/app/oracle/oradata/orcl/s_redo01.log') SIZE 52428800;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/app/oracle/oradata/orcl/s_redo02.log') SIZE 52428800;
Database altered.
SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;
GROUP#      BYTES
------ ----------
     4   52428800
     5   52428800
SQL> ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/app/oracle/oradata/orcl/s_redo03.log') SIZE 52428800;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/app/oracle/oradata/orcl/s_redo04.log') SIZE 52428800;
Database altered.
SQL> SELECT GROUP#, BYTES FROM V$STANDBY_LOG;
GROUP#      BYTES
------ ----------
     4   52428800
     5   52428800
     6   52428800
     7   52428800
SQL>

 

3.      Modify the init.ora parameters:

 

Modify the init.ora parameters on the primary database side to reflect the following values. If you are using spfile, you can add these parameter online without shutting down the primary database.

 

DB_NAME=orcl
DB_UNIQUE_NAME=orcl
LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,sbyorcl)'
LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/app/oracle/flash_recovery_area/orcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl'
LOG_ARCHIVE_DEST_2='SERVICE=sbyorcl ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=sbyorcl'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=sbyorcl
DB_FILE_NAME_CONVERT='sbyorcl','orcl'
LOG_FILE_NAME_CONVERT='/home/oracle/app/oracle/flash_recovery_area/sbyorcl/','/home/oracle/app/oracle/flash_recovery_area/orcl/'
STANDBY_FILE_MANAGEMENT=AUTO

 

4.      Enable Archiving :

Make sure that your database is running in archive log mode. Because in a physical standby setup all the redologs generated on the primary database will be transferred to standby site and applied to the standby database.

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> STARTUP MOUNT;
ORACLE instance started.
Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             381684408 bytes
Database Buffers           67108864 bytes
Redo Buffers                6008832 bytes
Database mounted.

SQL> ALTER DATABASE ARCHIVELOG;
Database altered.

SQL> ALTER DATABASE OPEN;
Database altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/
Oldest online log sequence     360
Next log sequence to archive   362
Current log sequence           362
SQL>

  

5.      Backup Primary Database :

In this demo I am using cold backup of the primary database. There are various other options like RMAN duplicate from active database to create physical standby database without even having the primary database backup in 11g. But in this article I am showing setup without RMAN and using simple sql commands.

Create a temporary directory (/tmp/askm/) on primary server and copy all the controlfile,online redolog files and database files to this location after shutting down the database.

    

6.      Create a controlfile for Standby Database:

SQL> startup mount
ORACLE instance started.
Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             381684408 bytes
Database Buffers           67108864 bytes
Redo Buffers                6008832 bytes
Database mounted.

SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/tmp/askm/s_control01.ctl';
Database altered.

SQL> ALTER DATABASE OPEN;
Database altered.

 

7.      Create a init.ora file for Standby Database:

 

SQL> CREATE PFILE='/tmp/askm/initsbyorcl.ora' FROM SPFILE;
File created.

 

8.      Configure listener.ora and tnsnames.ora:

[oracle@dgaskmpri01 admin]$ cat listener.ora
LISTENER_PRI =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))
    )
  )
SID_LIST_LISTENER_PRI =
  (SID_LIST =
    (SID_DESC =
      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2)
      (SID_NAME = orcl)
    )
  )

[oracle@dgaskmpri01 admin]$ cat tnsnames.ora
orcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID=orcl)
    )
  )

sbyorcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID=sbyorcl)
    )
  )
[oracle@dgaskmpri01 admin]$

 

9.      Copy backups and configuration files to Standby Server:

Create a temporary directory(/tmp/askm) on standby server and copy coldbackup, init.ora, password file(orapwsbyorcl) and standby controlfile (s_control01.ctl) from primary server to standby server.

 

Standby Site Preparation :

1.      Create a remote login password file ( if it is not copied from primary site )

Copy the password file /tmp/askm/orapwsbyorcl to $ORACLE_HOME/dbs

2.      Create a directory structure

If you are using a different directory structure on the standby server, they you need to create all the directories on the standby site.

Then copy coldbackup to the appropriate locations on the standby server. Also copy init.ora to $ORACLE_HOME/dbs location.

[oracle@dgaskmsby01]$ mkdir /home/oracle/app/oracle/oradata/sbyorcl/
[oracle@dgaskmsby01]$ mkdir /home/oracle/app/oracle/flash_recovery_area/sbyorcl/
[oracle@dgaskmsby01]$ cd $ORACLE_HOME/dbs
[oracle@dgaskmsby01 dbs]$ cd /home/oracle/app/oracle/oradata/sbyorcl/
[oracle@dgaskmsby01 sbyorcl]$ cp /tmp/askm/*.dbf .
[oracle@dgaskmsby01 sbyorcl]$ cp /tmp/askm/*.log .
[oracle@dgaskmsby01 sbyorcl]$ cp /tmp/askm/s_control01.ctl .
[oracle@dgaskmsby01 sbyorcl]$ cp /tmp/askm/s_control01.ctl /home/oracle/app/oracle/flash_recovery_area/sbyorcl/s_control02.ctl
[oracle@dgaskmsby01 sbyorcl]$ cp /tmp/askm/initsbyorcl.ora $ORACLE_HOME/dbs

3.      Modify the init.ora parameter file

Modify the initsbyorcl.ora file to reflect the following initialization parameters

DB_NAME=orcl
DB_UNIQUE_NAME=sbyorcl
LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,sbyorcl)'
CONTROL_FILES='/home/oracle/app/oracle/oradata/sbyorcl/s_control01.ctl', '/home/oracle/app/oracle/flash_recovery_area/sbyorcl/s_control02.ctl'
DB_FILE_NAME_CONVERT='orcl','sbyorcl'
LOG_FILE_NAME_CONVERT='/home/oracle/app/oracle/flash_recovery_area/orcl/','/home/oracle/app/oracle/flash_recovery_area/sbyorcl/'
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/app/oracle/flash_recovery_area/sbyorcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=sbyorcl'
LOG_ARCHIVE_DEST_2='SERVICE=orcl ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=orcl

 

4.      Configure listener.ora and tnsnames.ora:

[oracle@dgaskmsby01 admin]$ cat listener.ora
LISTENER_SBY =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))
    )
  )
SID_LIST_LISTENER_SBY =
  (SID_LIST =
    (SID_DESC =
      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_2)
      (SID_NAME = sbyorcl)
    )
  )

[oracle@dgaskmsby01 admin]$ cat tnsnames.ora
orcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmpri01.localdomain)(PORT = 1525))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID=orcl)
    )
  )

sbyorcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dgaskmsby01.localdomain)(PORT = 1525))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID=sbyorcl)
    )
  )
[oracle@dgaskmsby01 admin]$

 

5.      Verify connectivity

On Primary Server:

[oracle@dgaskmpri01]$ lsnrctl stop LISTENER_PRI
[oracle@dgaskmpri01]$ lsnrctl start LISTENER_PRI
[oracle@dgaskmpri01]$ tnsping orcl
[oracle@dgaskmpri01]$ tnsping sbyorcl
[oracle@dgaskmpri01]$ sqlplus sys/xxxxx@orcl
[oracle@dgaskmpri01]$ sqlplus sys/xxxxx@sbyorcl

 

On Standby Server:

[oracle@dgaskmsby01]$ lsnrctl stop LISTENER_SBY
[oracle@dgaskmsby01]$ lsnrctl start LISTENER_SBY
[oracle@dgaskmsby01]$ tnsping orcl
[oracle@dgaskmsby01]$ tnsping sbyorcl
[oracle@dgaskmsby01]$ sqlplus sys/xxxxx@orcl
[oracle@dgaskmsby01]$ sqlplus sys/xxxxx@sbyorcl

 

 

Creating Physical Standby Database :

1.      Start the physical Standby Database:

 

SQL> startup mount

ORACLE instance started.

 

Total System Global Area  456146944 bytes

Fixed Size                  1344840 bytes

Variable Size             381684408 bytes

Database Buffers           67108864 bytes

Redo Buffers                6008832 bytes

Database mounted.

SQL>

 

2.      Keep it in recovery:

 

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

 

Verifications :

On Standby:

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

On Primary :

Do some redo log switches

SQL> ALTER SYSTEM SWITCH LOGFILE;

On Standby:

  Verify that the recent archived log file is shifted to standby side and applied with the following commands.

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 

Other Useful Information:

To verify all the init.ora parameter in a single command:

egrep -i "DB_NAME|DB_UNIQUE_NAME|LOG_ARCHIVE_CONFIG|CONTROL_FILES|LOG_ARCHIVE_DEST_1|LOG_ARCHIVE_DEST_2|LOG_ARCHIVE_DEST_STATE_1|LOG_ARCHIVE_DEST_STATE_2|REMOTE_LOGIN_PASSWORDFILE|LOG_ARCHIVE_FORMAT|LOG_ARCHIVE_MAX_PROCESSES|FAL_SERVER|DB_FILE_NAME_CONVERT|LOG_FILE_NAME_CONVERT|STANDBY_FILE_MANAGEMENT" <specify init.ora parameter file>

 

To Cancel the Standby Recovery Mode:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

 

Useful commands To Troubleshoot:

select message from v$dataguard_status where dest_id = 2;
select archived_thread#, archived_seq#, applied_thread#, applied_seq# from v$archive_dest_status;
select registrar, creator, thread#, sequence#, first_change#, next_change# from v$archived_log;
select thread#, sequence#, first_change#, next_change# from v$log_history;

 

To Verify Recover Process On Standby:

select thread#, sequence# from v$log where status='CURRENT';  = >  On Primary
select thread#, sequence#, status from v$managed_standby where process='MRP0'; = > On Standby

 

References :

http://download.oracle.com/docs/cd/E11882_01/server.112/e25608/create_ps.htm#i63561

MOS ID :  249703.1

 

Hope It Helps

SRI

Posted in Data Guard | Tagged: , , , , , , , , , , | 9 Comments »

Physical Standby Switch Over Demo

Posted by Srikrishna Murthy Annam on September 16, 2010

This demo shows how to perform switch over operations for physical stand by operations.

One important point to remember:
Though the fact, that the previous Standby database became the primary afterwards applies to both variants – there are small differences which should for sure be considered. The most important is: After a FailOver there is no way to convert the former primary instance into a standby database for the new primary system: Due to the fact that both of them created redo information after the FailOver, they are completely out of sync, and in no way they can be synchronized again . The only possibility to get a new standby system again is to create it from the scratch.

After a SwitchOver, on the other hand, we have both, the primary and the standby system, available again as we had before. This means you should think twice before doing a FailOver.

Posted in Data Guard | Tagged: , , , , | 2 Comments »

 
%d bloggers like this: