Aug 30, 2014

Oracle XML Database status INVALID in dba_registry during Upgrade - a case study

Database upgrade from Oracle 10.2.0.4(10g) to 11.2.0.4(11g) - Using Manual upgrade
Fix : Oracle XML Database status INVALID in dba_registry during Upgrade 

Activity:

I started to upgrade one of my production database which oracle version is 10.2.0.4. I have to upgrade as Oracle 11.2.0.4. Following steps I have completed: ( Manual Upgrade)

1) Downloaded Oracle 11.2.04 version software and copy to a location. Sure about Oracle Homes. Start runinstaller. Select different Oracle Home location as like mentioned below.
   10g Home : /u01/app/oracle/product/10.2.0/db_1
   11g Home : /u01/app/oracle/product/11.2.0/db_1
Caution: Don't install Oracle 11g software to exiting home. There will be change of DB crash.
2) After runinstaller, Select the following:
    - New Oracle Home and Base ( as above)
    - Software Only
    - Enterprise / Standard Edition
3)  Rune the pre-upgrade tool: ( from 11g Home) -- must run
    - SQL> spool "upgrade_stat.log";
    - SQL> @$ORACLE_HOME/rdbms/admin/utlu112i.sql
It will give what to set or do. Here are sample history of log :
    - Minimum undo tbs size=512MB
    - Increase share_pool size = 224MB
    - Any patch set to apply ( if lower version, like 10.2.1 to 11.2.0.4) etc.
4) If any patchset to apply, download and apply with following steps:
    a) Take a full RMAN backup and down the database.
    b) Install patch set to any other location and start runinstaller and continue up to END..
    c) export ORACLE_SID
    d) Start the DB in Upgrade mode.
    e) SQL> @?/rdbms/admin/catupgrd.sql
    f) SQL> @?/rdbms/admin/utlrp.sql
    g) Shut immediate and startup again.
5) After patch set apply, set the recommended values like undo, shared_pool etc.
6) Again run the pre-upgrade tool. No issue should come. "No update parameter changes required" Message should come.
7) Shut down 10g database.
8) Change the location of parameter file(pfile) to new 11g 'dbs'.( $ORACLE_HOME/dbs)
9) Edit the /etc/oratab file and set new 11g home.
10) Edit the bash profile in case of Linux .
11) Edit the parameter file and set 11g specific parameters like diag_dest, audit_dest etc.
12) Now we will upgrade:
     $ sqlplus / as sysdba
     SQL> startup upgrade;
     SQL> @?/rdbms/admin/catupgrd.sql
     SQL> @?/rdbms/admin/utlrp.sql
     SQL> shut immediate;
     SQL> startup;

These are my basic steps. All steps are over but when I executed "catupgrd.sql" and "utlrp.sql". I faced the following:
    a) catupgrd.sql completed very fast which should not and shows below errors.

DOC>#######################################################################
DOC>#######################################################################
DOC>   The following error is generated if the pre-upgrade tool has not been
DOC>   run in the old ORACLE_HOME home prior to upgrading a pre-11.2 database:
DOC>
DOC>   SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')
DOC>                       *
DOC>      ERROR at line 1:
DOC>      ORA-01722: invalid number
DOC>
DOC>     o Action:
DOC>       Shutdown database ("alter system checkpoint" and then "shutdown abort").
DOC>       Revert to the original oracle home and start the database.
DOC>       Run pre-upgrade tool against the database.
DOC>       Review and take appropriate actions based on the pre-upgrade
DOC>       output before opening the datatabase in the new software version.
DOC>
DOC>#######################################################################
DOC>#######################################################################
DOC>#

    b) utlrp.sql shows the following errors at end:

warning for:

Warning: XDB now invalid, could not find xdbconfig
ORDIM registered 5 XML schemas.
The following XML schemas are not registered:
http://xmlns.oracle.com/ord/dicom/UIDdefinition_1_0
http://xmlns.oracle.com/ord/dicom/anonymity_1_0
http://xmlns.oracle.com/ord/dicom/attributeTag_1_0
http://xmlns.oracle.com/ord/dicom/constraint_1_0
http://xmlns.oracle.com/ord/dicom/datatype_1_0
http://xmlns.oracle.com/ord/dicom/manifest_1_0
http://xmlns.oracle.com/ord/dicom/mapping_1_0
http://xmlns.oracle.com/ord/dicom/mddatatype_1_0
http://xmlns.oracle.com/ord/dicom/metadata_1_0
http://xmlns.oracle.com/ord/dicom/orddicom_1_0
http://xmlns.oracle.com/ord/dicom/preference_1_0
http://xmlns.oracle.com/ord/dicom/privateDictionary_1_0
http://xmlns.oracle.com/ord/dicom/rpdatatype_1_0
http://xmlns.oracle.com/ord/dicom/standardDictionary_1_0
ORDIM DICOM repository has 0 documents.
The following default DICOM repository documents are not installed:
ordcman.xml
ordcmcmc.xml
ordcmcmd.xml
ordcmct.xml
ordcmmp.xml
ordcmpf.xml
ordcmpv.xml
ordcmsd.xml
ordcmui.xml

Fix/ Solution:

Investigation:
1) Verify the registry after upgrade:
set line 120;
column COMP_NAME format a35;
column VERSION format a10;
column status format a10;
select COMP_NAME, VERSION,status from dba_registry;

COMP_NAME                           VERSION    STATUS
----------------------------------- ---------- ----------
Oracle Enterprise Manager           11.2.0.4.0 VALID
OLAP Catalog                        11.2.0.4.0 VALID
Spatial                             11.2.0.4.0 VALID
Oracle Multimedia                   11.2.0.4.0 INVALID
Oracle XML Database                 11.2.0.4.0 INVALID
Oracle Text                         11.2.0.4.0 VALID
Oracle Expression Filter            11.2.0.4.0 VALID
Oracle Rules Manager                11.2.0.4.0 VALID
Oracle Workspace Manager            11.2.0.4.0 VALID
Oracle Database Catalog Views       11.2.0.4.0 VALID
Oracle Database Packages and Types  11.2.0.4.0 VALID
JServer JAVA Virtual Machine        11.2.0.4.0 VALID
Oracle XDK                          11.2.0.4.0 VALID
Oracle Database Java Packages       11.2.0.4.0 VALID
OLAP Analytic Workspace             11.2.0.4.0 VALID
Oracle OLAP API                     11.2.0.4.0 INVALID

Here few components are not upgraded. Focus on Oracle XML Database which is require for my environment.

Misc: Verify your optimizer values like below. If not matched, then change values using 'alter system set ...'

SQL> show parameter optimizer;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ---------
optimizer_capture_sql_plan_baselines boolean     FALSE
optimizer_dynamic_sampling           integer     2
optimizer_features_enable            string      11.2.0.3
optimizer_index_caching              integer     0
optimizer_index_cost_adj             integer     100
optimizer_mode                       string      ALL_ROWS
optimizer_secure_view_merging        boolean     TRUE
optimizer_use_invisible_indexes      boolean     FALSE
optimizer_use_pending_statistics     boolean     FALSE
optimizer_use_sql_plan_baselines     boolean     TRUE
SQL>


2) Find the output for below query:
SQL> select any_path from resource_view;
select any_path from resource_view
*
ERROR at line 1:
ORA-31000: Resource 'http://xmlns.oracle.com/xdb/acl.xsd' is not an XDB schema document

From the above two investigation, it is confirmed that pre-upgraded tool is not executed or during startup upgrade session may be canceled or terminated or some other issue may came.

Fix/ Solution:

To validate Oracle Multimedia you can check Oracle Support note: How To Reload Oracle Multimedia Related Information When XML Database (=XDB) Has Been Reinstalled [ID 965892.1]. To validate Oracle Multimedia we followed the following procedure.

sqlplus / as sysdba
SQL>@?/rdbms/admin/catnoqm.sql
SQL>@?/rdbms/admin/catqm.sql
SQL>@?/rdbms/admin/utlrp.sql

Now no message ( as above seen) are not cumming. Now do the following also.

SQL> alter session set current_schema="ORDSYS";
SQL> @/u01/app/oracle/product/11.2.0/db_1/ord/im/admin/imxreg.sql;
SQL> @/u01/app/oracle/product/11.2.0/db_1/ord/im/admin/impbs.sql;
SQL> @/u01/app/oracle/product/11.2.0/db_1/ord/im/admin/impvs.sql;
SQL> @/u01/app/oracle/product/11.2.0/db_1/ord/im/admin/imtyb.sql;
SQL> @/u01/app/oracle/product/11.2.0/db_1/ord/im/admin/implb.sql;
SQL> @/u01/app/oracle/product/11.2.0/db_1/ord/im/admin/imxrepos.sql;
SQL> exit
sqlplus / as sysdba 

SQL> set serveroutput on
SQL> exec validate_ordim;
SQL> exit

Now all of the components are valid.

Conclusion:

Before you upgrade your database version using the manual method always check OS environment variables pointing to new ORACLE HOME.
  


Aug 26, 2014

Duplicate database Using RMAN in Oracle Database 11gR2

We will see how to create duplicate database from available rman backup.o

a) Active Database Duplication method - from Primary
b)  Duplicate database from RMAN Backup

a) Following Active Database Duplication method - from Primary

Introduction:

Oracle 11g introduced the ability to create duplicate databases directly without the need for a backup. This is known as active database duplication. The process is similar to the backup-based duplication, with a few exceptions. First, and most obviously, you don't need a backup of the source system, but it does have to be in ARCHIVELOG mode.

Purpose of Database Duplication: 
A duplicate database is useful for a variety of purposes, most of which involve testing. You can perform the following tasks in a duplicate database:
  • Test backup and recovery procedures
  • Test an upgrade to a new release of Oracle Database
  • Test the effect of applications on database performance
  • Create a standby database
  • Generate reports
Techniques for Duplicating a Database:
RMAN supports two basic types of duplication: active database duplication and backup-based duplication.

A connection to both is required for active database duplication.

Figure-1 shows the decision tree for the two duplication techniques.









Active Database Duplication:
In active database duplication, RMAN connects as TARGET to the source database instance and as AUXILIARY to the auxiliary instance. RMAN copies the live source database over the network to the auxiliary instance, thereby creating the duplicate database. No backups of the source database are required. Figure -2 illustrates active database duplication.
















             Figure-2 Active Database Duplication

Steps of Database Duplication (Active method)

A) Pre-Configuration Steps:

1) Find Source and Target database 
Assume host name of Source database is "DB1" and target database is "DB2". Both Severs are stand-alone type.
Assume source database name is PRODDB and target database name is REPDB.
2) Find connectivity between both hosts
use ping with IP from both server. Ping status should OK.
3) Verify OS and database versions
Assume OS version RHEL 6.3 and Oracle Software version 11.2.0.3
4) Verify Source database database size and more than space should available in target database.
5) Check Archive log is enabled in source database.


B) Configuration steps:

-- in proposed duplicate database side
1) configure listener.
Check listener should up and running in target side.
2) configure tnsname.ora for itself and source also
Check tnsping from both databses. Both side status should OK.
3) configure initREPDB.ora ( Duplicate Specific parameters)

db_name='REPDB'
DB_FILE_NAME_CONVERT='/u01/EHISDC/ORADATA/PRODDB/','/u10/ORADATA/REPDB/'
LOG_FILE_NAME_CONVERT='/u01/EHISDC/ORADATA/PRODDB/','/u10/ORADATA/REPDB/'

See sample pfile:


















Note: Remove db_unique_name option, if your target database listener is blocking.

4) create a password file in source database and move it to target database side and rename it database SID name.
e.g.,
-- Source side
DB1] $ cd $ORACLE_HOME/dbs
DB1] $ orapwd force=y file=orapwPRODDB password=system
$ scp orapwPRODDB oracle@DB2:/$ORACLE_HOME/dbs
-- Traget side
DB2] $ cd $ORACLE_HOME/dbs
$ mv orapwPRODDB orapwREPDB
Now check connectivity using sqlplus in source database using password. It should connect
DB1] $ sqlplus /nolog
sql> connect sys/system@REPDB as sysdba
connected.

C) Create Duplicate database:

1) When connecting to RMAN, you must use a connect string for both the target and auxiliary connections.

$ export ORACLE_SID=$PROD
$ rman target=sys/system auxiliary=sys/system@UAT
OR
$ rman target /
rman> connect auxiliary sys/system@REPDB;


2) Include the FROM ACTIVE DATABASE clause in the DUPLICATE command.

RMAN>
run {
allocate channel ch1 type disk;
allocate auxiliary channel stby1 type disk;
duplicate target database to REPDB from active database;
}


2)  Duplicate database from RMAN Backup

Note: Automatically database will be created and open it r/w mode also.

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

b)  Duplicate database from RMAN Backup

You can create duplicate database from backup. If source and target directory structure for C|R|D files are same then most probably you may not face any issues. But if directory structure are different, then you need to follow "SET NEWNAME FOR DATAFILE xx TO" method.

a). add following in pfile ( only required if you are not using OMF and source & target file structure different)

*.db_file_name_convert='/u02/oracle/oradata','/u03/oracle/oradata'
*.log_file_name_convert ='/u02/oracle/oradata','/u03/oracle/oradata'

b). create directory structures for C|R|D files and other audit location

Note: Run the backup in source like similar as shown in below
connect target `/'
run
{
allocate channel chd1 device type disk;
allocate channel chd2 device type disk;
backup as compressed backupset incremental level 0 database plus archivelog;
release channel chd1;
release channel chd2;


Note: Auto backup on must be configured in the above case and you need to copy those backup files to target. Here all backups will be available in db_recovery_dest location.

OR
You can use below script.
e.g.,

run
{
sql 'alter system archive log current';
backup device type disk as backupset current controlfile format '/u03/backup/proddb_full_cf.bkp' tag 'proddb_full_cf';
backup device type disk incremental level 0 database format '/u03/backup/proddb_full_db_%U.bkp' tag 'proddb_full_db';
sql 'alter system archive log current';
backup device type disk archivelog all format '/u03/backup/proddb_full_al_%U.bkp' not backed up 2 times tag 'proddb_full_arc';

}


c) Start the database in nomount stage.
$ sqlplus / as sysdba
SQL> startup nomount;
ORACLE instance started.

d) Backup files with auto Bkp
$ ls -ltr
-rw-r-----. 1 oracle oinstall     220672 Mar 18 22:24 o1_mf_annnn_TAG20170318T222448_ddtslrwt_.bkp
-rw-r-----. 1 oracle oinstall       4608 Mar 18 22:24 o1_mf_annnn_TAG20170318T222448_ddtslrvy_.bkp
-rw-r-----. 1 oracle oinstall   12708352 Mar 18 22:24 o1_mf_annnn_TAG20170318T222448_ddtslrsp_.bkp
-rw-r-----. 1 oracle oinstall 2946310144 Mar 18 22:47 o1_mf_nnndf_TAG20170318T222452_ddtslxoq_.bkp
-rw-r-----. 1 oracle oinstall 2602360832 Mar 18 22:48 o1_mf_nnndf_TAG20170318T222452_ddtsly31_.bkp
-rw-r-----. 1 oracle oinstall 4789755904 Mar 18 22:55 o1_mf_nnndf_TAG20170318T222452_ddtslyjw_.bkp
-rw-r-----. 1 oracle oinstall 4372389888 Mar 18 22:56 o1_mf_nnndf_TAG20170318T222452_ddtslz1g_.bkp
-rw-r-----. 1 oracle oinstall    1840640 Mar 18 22:56 o1_mf_annnn_TAG20170318T225630_ddtvg74l_.bkp
-rw-r-----. 1 oracle oinstall       8192 Mar 18 23:06 o1_mf_1_4700_ddtvzpol_.arc
-rw-r-----. 1 oracle oinstall       1024 Mar 18 23:06 o1_mf_1_4699_ddtvzkw1_.arc
-rw-r-----. 1 oracle oinstall     627712 Mar 18 23:06 o1_mf_1_4698_ddtvzhld_.arc
-rw-r-----. 1 oracle oinstall    3643904 Mar 18 23:06 o1_mf_1_4697_ddtvg6j4_.arc
-rw-r-----. 1 oracle oinstall     218624 Mar 18 23:06 o1_mf_1_4696_ddtslr78_.arc
-rw-r-----. 1 oracle oinstall       1024 Mar 18 23:06 o1_mf_1_4695_ddts5s8n_.arc
-rw-r-----. 1 oracle oinstall       2560 Mar 18 23:06 o1_mf_1_4694_ddts5pqj_.arc
-rw-r-----. 1 oracle oinstall       1024 Mar 18 23:06 o1_mf_1_4693_ddts5md7_.arc
-rw-r-----. 1 oracle oinstall   39057408 Mar 18 23:06 o1_mf_1_4692_ddts5kt4_.arc
-rw-r-----. 1 oracle oinstall   13631488 Mar 18 23:07 o1_mf_s_938991392_ddtvg8yn_.bkp


e) Change ownership and permissions of Backup pieces.

$ id
uid=502(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),503(oper),506(asmdba) 
$

 #chown -R oracle:oinstall 2017_03_18
 #chmod -R 775 2017_03_18

f) Create Duplicate database.

$rman auxiliary / log = rmandup_2017_03_18.log
run
{
ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux3 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux4 DEVICE TYPE DISK;
DUPLICATE DATABASE "PROD" DBID 3590353289 TO "UAT" BACKUP LOCATION '/u04/2017_03_18' NOFILENAMECHECK;
release channel aux1;
release channel aux2;
release channel aux3;
release channel aux4;
}


OR

you can script like below to call with nohup option:

vi uat_rman_duplicate_script.rman

run
{
ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux3 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux4 DEVICE TYPE DISK;
DUPLICATE DATABASE "prod" DBID 3590353289 TO "uat" BACKUP LOCATION '/u04/2017_03_18' NOFILENAMECHECK;
release channel aux1;
release channel aux2;
release channel aux3;
release channel aux4;
}

$ env | grep ORA
ORACLE_UNQNAME=uat
ORACLE_SID=uat
ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1


$ nohup rman auxiliary / @uat_rman_duplicate_script.rman log=uat_rman_duplicate_2017_03_18.log &


g) Check the database status.

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
UAT       READ WRITE           PRIMARY

SQL> 


When directory structure NOT same for C/R/D files:

You can follow the same steps as given above, but step-5 to be modified and you can use below method. Omit db_file_name_convert and log_file_name_convert from parameter file.

rman> RUN
{
ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
SET NEWNAME FOR DATAFILE 1 TO '/u02/oracle/uatdata/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/u02/oracle/uatdata/sysaux01.dbf';
...
SET NEWNAME FOR DATAFILE 61 TO '/u02/oracle/uatdata/txn_data01.dbf';
SET NEWNAME FOR DATAFILE 62 TO '/u02/oracle/uatdata/undo_01.dbf';
DUPLICATE DATABASE "PROD" DBID 3655036336 TO "UAT" BACKUP LOCATION '/prod/FRA/PROD/backupset/2017_04_13' NOFILENAMECHECK;
LOGFILE
GROUP 1 ('/u02/oracle/uatdata/redo01.log') SIZE 500M REUSE,
GROUP 2 ('/u02/oracle/uatdata/redo02.log') SIZE 500M REUSE,
GROUP 3 ('/u02/oracle/uatdata/redo03.log') SIZE 500M REUSE,
GROUP 4 ('/u02/oracle/uatdata/redo04.log') SIZE 500M REUSE,
release channel aux1;
release channel aux2;
}


Note: If you are Creating Duplicate database from TAPE backups, then you can follow below method in rman script. But you should ensure where your TAPE agent is runnig, give the same path with required inforrmation:

e.g., 


run {
set dbid xxxxxxx;
allocate auxiliary channel ch1 device type sbt parms="SBT_LIBRARY=/opt/commvault/Base/libobk.so,BLKSIZE=1048576";
duplicate database 'EXMPRD' to 'EXMUAT' NOFILENAMECHECK;

}

OR
## To retsore up to specific period.

run {
set dbid xxxxxxx;
set until time "TO_DATE('2017-03-18 07:00:00', 'YYYY-MM-DD HH24:MI:SS')";
allocate auxiliary channel ch1 device type sbt parms="SBT_LIBRARY=/opt/commvault/Base/libobk.so,BLKSIZE=1048576";
duplicate database 'EXMPRD' to 'EXMUAT' NOFILENAMECHECK;

}


Issues and Troubleshooting:

-- Issue-1:

DBGSQL:     TARGET> begin :fhdbi := dbms_rcvcat.getDbid; end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :fhdbi = 32767
released channel: stby1
released channel: ch1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 08/21/2014 19:52:49
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
ORA-06550: line 1, column 17:
PLS-00201: identifier 'DBMS_RCVCAT.GETDBID' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored


Solution:1: like this

pfile :
*.db_name=prod1
*.db_unique_name=prod2


-- Issue-2:
RMAN-04006:  ORA-28547:

RMAN-04006: error from auxiliary database: ORA-28547: connection to server failed, probable Oracle Net admin error

Solution:2:

1) re-create password file for target / duplicate database properly
2) recheck tnsnames.ora entry
3) Check the target database/ duplcate database listener status
4) While connecting auxiliary database, check auxiliary is connecting or not.

-- Issue-3:

Oracle instance shut down
released channel: ch1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 03/02/2015 17:37:34
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-06136: ORACLE error from auxiliary database: ORA-01102: cannot mount database in EXCLUSIVE mode

OR

Solution-1: 

If any oracle process is running with your duplicate database name, then kill them.

e.g.

$ ps -ef|grep $ORACLE_SID
$ kill -9 <pid>

Solution-2:

Add below parameter in standby parameter.

*.remote_login_passwordfile='EXCLUSIVE'

Solution-3:

Comment below entry in standby parameter file if you have kept/ add.

.db_unique_name='primary_dbname'

-- Issue - 4:

Oracle instance shut down
released channel: ch1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/29/2015 16:54:33
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ch1 channel at 04/29/2015 16:54:24
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-01017: invalid username/password; logon denied
ORA-17629: Cannot connect to the remote database server

Solution:
1) re-create password file in target db and test connection from source db.
2) Check the listener status. No blocked service should be there: 
e.g.
Services Summary...
Service "PROD1" has 2 instance(s).
  Instance "PROD1", status UNKNOWN, has 1 handler(s) for this service...
  Instance "PROD1", status BLOCKED, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PROD2" has 2 instance(s).
  Instance "PROD2", status UNKNOWN, has 1 handler(s) for this service...
  Instance "PROD2", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

Verify your listener:
sample listener.ora

LISTENER_UAT =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = uat-bkp)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME =/u01/app/oracle/product/11.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = UAT)
      (ORACLE_HOME =/u01/app/oracle/product/11.2.0/db_1)

    )
  )

ADR_BASE_LISTENER_UAT = /u01/app/oracle

Note: Most of cases issue will come when listener.ora is not configured properly.

3) while you are connecting from source database via rman to target database, check which target db is connecting:

sample:

$ rman target=sys/system auxiliary=sys/system@UAT;

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Apr 29 18:45:29 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: PROD (DBID=123456789)
connected to auxiliary database: UAT (not mounted)

4) Check source db is archivelog mode is on or not.

The the rman log / message while creating duplicate database:
.....
.....
duplicate target database to UAT from active database;
}
2> 3> 4> 5> 
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=964 device type=DISK

allocated channel: stby1
channel stby1: SID=541 device type=DISK

Starting Duplicate Db at 29-APR-15

contents of Memory Script:
{
   sql clone "create spfile from memory";
}
executing Memory Script

sql statement: create spfile from memory

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

Oracle instance shut down

connected to auxiliary database (not started)

Fixed Size                     2237008 bytes
Variable Size               1577061808 bytes
Database Buffers            8455716864 bytes
Redo Buffers                  19767296 bytes
allocated channel: stby1
channel stby1: SID=272 device type=DISK

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''PROD'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''UAT'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u01/ORADATA/UAT/control01.ctl';
   restore clone controlfile to  '/u01/ORADATA/UAT/control02.ctl' from 
 '/u01/ORADATA/UAT/control01.ctl';
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''PROD'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set  db_unique_name =  ''UAT'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down

...
...
 72 auxiliary format 
 "/u01/ORADATA/UAT/SUPPORT_01.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
...
...
Starting backup at 29-APR-15
channel ch1: starting datafile copy
input datafile file number=00033 name=/u01/ORADATA/PROD/HR01.dbf
...
...
input datafile copy RECID=71 STAMP=878325378 file name=/u01/ORADATA/UAT/SUPPORT_01.dbf

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 29-APR-15
released channel: ch1
released channel: stby1

RMAN>


Issue -5 : When data block corruption will come during duplicate database creation:

I found below message like this and terminated the session:
.....
.....
.....
datafile 71 switched to datafile copy
input datafile copy RECID=70 STAMP=878329989 file name=/u01/ORADATA/UAT/HR02.dbf
datafile 72 switched to datafile copy
input datafile copy RECID=71 STAMP=878329989 file name=/u01/ORADATA/UAT/SUPPORT_01.dbf

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00601: fatal error in recovery manager
RMAN-03004: fatal error during execution of command
RMAN-10041: Could not re-create polling channel context following failure. 
RMAN-10024: error setting up for rpc polling
RMAN-10005: error opening cursor
RMAN-10002: ORACLE error: ORA-03114: not connected to ORACLE
RMAN-03002: failure of Duplicate Db command at 04/29/2015 20:33:48
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-06136: ORACLE error from auxiliary database: ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 1
ORA-01578: ORACLE data block corrupted (file # 1, block # 86663)
ORA-01110: data file 1: '/u01/ORADATA/UAT/system01.dbf'
Process ID: 25656
Session ID: 805 Serial number: 5
$

The above message is clearly telling there is issue with disk and corrupted block in source database.

Action to be taken:
1) Verify source database block corruption issues.
2) Validate some backups for corrupted blocks in source and then transfer to target database and again validate in target database side and restore.
3) The last option is to take a full export dump and restore it.

Note: Try to replace the exiting storage.

Thanks .. This document will help you. Cheers!!!

Aug 21, 2014

FAST_START FAILOVER (FSFO) & Reinstate Failed Primary database

Start Failover using Dataguard Broker

Fast-Start Failover: Concepts
Oracle introduced the Fast-Start Failover (FSF) feature set in Release 10gR2, but it’s been enhanced significantly in Oracle 11g to permit much finer-grained control over the conditions under which a FSF would be initiated. Simply put, FSF ensures that under the appropriate circumstances – some of which are mandatory, and some of which are optionally-configured - a failover to the chosen standby target database will occur without DBA intervention. The following occurrences will initiate FSF:

Fast-Start Failover detects one of these failover situations through the Fast-Start Failover Observer (FSFO). The FSFO leverages the Oracle Call Interface (OCI) architecture to decide when a failover is necessary, which physical standby database should be the target of the failover, and how long to wait until it declares a failover is absolutely necessary. The good news is that I have quite a bit of control over these three directives, all of which are completely configurable using the Data Guard Broker Manager utility (DGMGRL).

Topics to be discussed:
1) Basic checks / requirements for FAST_START FAILOVER
2) Enable fast start failover.
3) Verify the fast-start failover configuration.
4) Fast_start failover gracefull - seamless application access
5) Managing observer
6) Reinstating a Failed Primary Database


1) Basic checks / requirements for FAST_START FAILOVER

Here are the following basic check for fast_start failover in active dataguad environment using dataguad broker:
1.1) Ensure standby redo logs are configured on the primary and target standby databases.
1.2) Ensure the LogXptMode Property is set to SYNC/ASYNC for both primary and standby database
1.3) Set the FastStartFailoverTarget configuration property.
1.4) Upgrade the protection mode to MAXAVAILABILITY ( if necessary)
1.5) Enable Flashback Database on the primary and target standby databases.
1.6) Start the observer

Note: Active dataguard setup and broker setup should be completed carefully. ( See my next publication )

1.1) Ensure standby redo logs are configured on the primary and target standby databases:

Standby redo logs must be configured on the primary and standby databases. Configure n+1 standby redo logs. i.e., if in primary database, there are 3 redolog groups then set 4 standby redo logs.

1.2) Ensure the LogXptMode Property is set to SYNC/ASYNC for both primary and standby database:

The LogXptMode configurable database property must be set to SYNC on the primary and target standby databases. To set the redo transport service that corresponds to the protection mode you plan to set, use the EDIT DATABASE (property) command on the primary and target standby databases. For example, if the protection mode to be set is MAXAVAILABILITY, you must set the LogXptMode property to SYNC on the primary database and on the target standby database, as shown in the following examples:
Primary:

DGMGRL> show database 'PRIMARY';

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

Database Status: SUCCESS

DGMGRL> show configuration;

Configuration - DR_Config
  Protection Mode: MaxAvailability
  Databases:
    PRIMARY - Primary database
    STANDBY - Physical standby database
Fast-Start Failover: DISABLED

Configuration Status: SUCCESS

Standby]

DGMGRL> show database 'STANDBY';

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

Database Status: SUCCESS

DGMGRL> show configuration;

Configuration - DR_Config
  Protection Mode: MaxAvailability
  Databases:
    PRIMARY - Primary database
    STANDBY - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status: SUCCESS
DGMGRL>


1.3) Set the FastStartFailoverTarget configuration property.:

If you have two or more standby databases, set up the FastStartFailoverTarget configuration property on the primary database to indicate the desired target standby database. For example:

PRIMARY]
DGMGRL> connect sys@PRIMARY
Password:
Connected.

DGMGRL> EDIT DATABASE 'PRIMARY' SET PROPERTY FastStartFailoverTarget='STANDBY';
Property "faststartfailovertarget" updated

DGMGRL>

STANDBY]
DGMGRL> connect sys@STANDBY
Password:
Connected.

DGMGRL> EDIT DATABASE 'STANDBY' SET PROPERTY FastStartFailoverTarget='PRIMARY';

Property "faststartfailovertarget" updated

1.4 : Upgrade the protection mode to MAXAVAILABILITY, if necessary.

If it is necessary to upgrade the protection mode, use the following DGMGRL EDIT CONFIGURATION command. For example:

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;

1.5 : Enable Flashback Database on the primary and target standby databases.

If it is not already enabled on the primary and standby databases, enable Flashback Database by issuing the following statements on each database:
ALTER SYSTEM SET UNDO_RETENTION=3600 SCOPE=SPFILE;
ALTER SYSTEM SET UNDO_MANAGEMENT='AUTO' SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
SHOW PARAMETER UNDO;
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320 SCOPE=BOTH;
ALTER DATABASE ARCHIVELOG;
ALTER SYSTEM SET db_recovery_file_dest_size=<size>;
ALTER SYSTEM SET db_recovery_file_dest=<directory-specification>;
ALTER DATABASE FLASHBACK ON;
ALTER DATABASE OPEN;

Note : Ensure the UNDO_RETENTION and DB_FLASHBACK_RETENTION_TARGET initialization parameters are set to sufficiently large values so that reinstatement is still possible after a prolonged outage.

1.6) Start the observer

Start the observer by logging into the observer computer and running DGMGRL. Connect to the configuration as SYS and then issue the START OBSERVER command. Note that the command does not return; that is you will not get DGMGRL prompt after issuing the command.

DGMGRL> CONNECT sys@PRIMARY;
Password: password
Connected.

DGMGRL> START OBSERVER;
Observer started

Note : The terminal session will appear to hang at this point.

When starting the observer interactively, Oracle recommends that connection credentials be supplied as a command parameter to the DGMGRL CONNECT command, as shown in the example, rather than as a command line parameter to the DGMGRL command. This practice prevents other users on the system from using a utility (for example, the UNIX ps utility) to display the connection credentials.
When starting the observer from a script, Oracle recommends that you use a method that supports 'connect /', so that database connection credentials do not have to be embedded within the script. If you choose to use a client-side Oracle Wallet as a secure external password store (see Oracle Database Advanced Security Administrator's Guide), be sure to add credentials for both the primary and fast-start failover target standby databases. The database connect string that you specify when adding the credentials for each database must match the ObserverConnectIdentifer or DGConnectIdentifier configurable database property.
To maximize the benefits of FSFO, the observer should run on a different host than the primary and standby databases. Ideally the primary, standby, and observer will be in geographically separate areas. The observer is very lightweight, requiring few system resources.  Unlike the primary / standby interconnect, where bandwidth and latency are determining performance factors, the observer requires very little network bandwidth and is not overly latency sensitive, allowing the it to be placed practically anywhere a reliable connection is available.

Since the observer is a specialized instance of a DGMGRL session, the observer host should be installed with either the Oracle Client Administrator software or the full Oracle Database software stack.
Note that Now My Oracle Client Version is 11.2.0.1.0. We will proceed to start the observer.

Running a StatusReport on the primary should verify that the error is due to a missing observer.

DGMGRL> show database 'PRIMARY' statusreport;
STATUS REPORT
       INSTANCE_NAME   SEVERITY ERROR_TEXT

Note: No error came means, you can proceed. Be sure flashback enabled, undo retain value will be greater as discussed earlier. Don't initiate failover unless at least 30 minutes of history is available


2) Enable fast start failover:

You can enable fast-start failover while connected to any database system in the broker configuration. For example:

DGMGRL> ENABLE FAST_START FAILOVER;
Enabled.

3) Verify the Fast-Start Failover configuration.

Now Cross-check and start "FAST_START FAILOVER":

Use the SHOW FAST_START FAILOVER command to display the fast-start failover settings:

DGMGRL> show FAST_START FAILOVER;

Fast-Start Failover: ENABLED
  Threshold:        30 seconds
  Target:           STANDBY
  Observer:         edc-noc-01d
  Lag Limit:        30 seconds (not in use)
  Shutdown Primary: TRUE
  Auto-reinstate:   TRUE
Configurable Failover Conditions
  Health Conditions:
    Corrupted Controlfile          YES
    Corrupted Dictionary           YES
    Inaccessible Logfile            NO
    Stuck Archiver                  NO
    Datafile Offline               YES
  Oracle Error Conditions:     (none)
DGMGRL>

Note : The FastStartFailoverPmyShutdown and FastStartFailoverAutoReinstate configuration properties do not affect whether the former primary database is shut down and automatically reinstated, respectively, when a fast-start failover occurs if either a user configurable fast-start failover condition is detected or if an application initiated a fast-start failover by calling the DBMS_DG.INITIATE_FS_FAILOVER function. In these cases, the former primary database is always shut down and never automatically reinstated.


4) Fast_start fail-over graceful - seamless application access:

4.1) Create and Start Services
4.2) 4.2) Configure client tnsnames.ora entry
4.3) Verify created service status
4.4) Demo table ( records more than 10 Lakh) to test access when failover happen
4.5) Test the Failover and test graceful access
4.6) Verify the target standby database is ready for failover. in PRIMARY]

-- create service
SQL>
exec dbms_service.create_service(service_name => 'REPORT',network_name => 'REPORT',aq_ha_notifications =>
TRUE,failover_method => 'BASIC',failover_type => 'SELECT',failover_retries => 30,failover_delay => 5);

-- Start Service
sql> exec dbms_service.START_SERVICE('REPORT');

-- Create procedure to trigger for starting/ stopping service in case of shut down of Primary database.
SQL>
create or replace procedure p_cmc_taf_service is
  v_role VARCHAR(30);
begin
  select DATABASE_ROLE into v_role from V$DATABASE;
  if v_role = 'PRIMARY' then
    DBMS_SERVICE.START_SERVICE('REPORT');
  else
    DBMS_SERVICE.STOP_SERVICE('REPORT');
  end if;
end;
/

-- Create triggers to call above procedure when start the database
SQL> 
create or replace TRIGGER trg_cmc_taf_service_startup
  after startup on database
begin
  p_cmc_taf_service;
end;
/
-- Create triggers to call above procedure when database role will be changed in the database
SQL>
create or replace TRIGGER trg_cmc_taf_manage_rolechange
  after db_role_change on database
begin
  p_cmc_taf_service;
end;
/

4.2) Configure client tnsnames.ora entry

in Client]
-- Add tns entry on client side : First do this entry and confirm

-- tnsnames.ora entry:
-- For single IP
REPORT =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.18)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = REPORT)
    )
  )

-- For Application to access seamlessly

REPORT =
(DESCRIPTION =
   (ADDRESS_LIST=
     (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.18)(PORT = 1522))
     (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.17)(PORT = 1521))
   )
     (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = REPORT)
    (FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=30)(DELAY=5))
     )
)


4.3) Veryfy created service status
-- Test the listener status

$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 16-AUG-2014 17:39:38
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=EH-UAT-DB)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                04-AUG-2014 17:27:58
Uptime                    12 days 0 hr. 11 min. 39 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /rmandisk/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /rmandisk/app/oracle/diag/tnslsnr/EH-UAT-DB/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=EH-UAT-DB)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PRIMARY" has 2 instance(s).
  Instance "PRIMARY", status UNKNOWN, has 1 handler(s) for this service...
  Instance "PRIMARY", status READY, has 1 handler(s) for this service...
Service "PRIMARYXDB" has 1 instance(s).
  Instance "PRIMARY", status READY, has 1 handler(s) for this service...
Service "PRIMARY_DGB" has 1 instance(s).
  Instance "PRIMARY", status READY, has 1 handler(s) for this service...
Service "PRIMARY_DGMRGL.EH-UAT-DB" has 1 instance(s).
  Instance "PRIMARY", status UNKNOWN, has 1 handler(s) for this service...
Service "REPORT" has 1 instance(s).
  Instance "PRIMARY", status READY, has 1 handler(s) for this service...
The command completed successfully

Conclusion:
1) able to connect through service 'REPORT'.
2) Listener status showing the created service 'REPORT'

i.e., OK about service. Next to test below tnsnames entry for seamless application connection.

-- To confirm:
1) Run tnsping REPORT --  succeeded
2) Connect sqlplus window using service name 'REPORT' -- succeeded

Now it is ready for failover testing.....

4.4) Demo table ( records more than 10 Lakh) to test access when failover happen

Create Big table to test a “select” query furring failover operation.

-- Create a big table to test during failover in client machine
-- Create structure
create table big_table as
select rownum id,
               OWNER, OBJECT_NAME, SUBOBJECT_NAME,
               OBJECT_ID, DATA_OBJECT_ID,
               OBJECT_TYPE, CREATED, LAST_DDL_TIME,
               TIMESTAMP, STATUS, TEMPORARY,
               GENERATED, SECONDARY
  from all_objects a  where 1=0;

-- Insert data ( input 100000 when execute the pl-sql block)
declare
    l_cnt number;
    l_rows number := &1;
begin
    insert /*+ append */
    into big_table
    select rownum,OWNER, OBJECT_NAME, SUBOBJECT_NAME,
          OBJECT_ID, DATA_OBJECT_ID, OBJECT_TYPE,
        CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS,
        TEMPORARY, GENERATED, SECONDARY
      from all_objects a where rownum <= &1;
    l_cnt := sql%rowcount;
    commit;
    while (l_cnt < l_rows)
    loop
        insert /*+ APPEND */ into big_table
        select rownum+l_cnt,
               OWNER, OBJECT_NAME, SUBOBJECT_NAME,
               OBJECT_ID, DATA_OBJECT_ID,
               OBJECT_TYPE, CREATED, LAST_DDL_TIME,
               TIMESTAMP, STATUS, TEMPORARY,
               GENERATED, SECONDARY
          from big_table
         where rownum <= l_rows-l_cnt;
        l_cnt := l_cnt + sql%rowcount;
        commit;
    end loop;
end;
/

-- add a constraint
SQL> alter table big_table add constraint big_table_pk primary key(id);
-- Gather the statistics
SQL> exec dbms_stats.gather_table_stats(ownname => 'SYS',tabname => 'BIG_TABLE',cascade => TRUE);

4.5) Test the Failover and test graceful access

Now our preparation is over and ready to test fire the missile “failover”.

PRIMARY]
DGMGRL> connect sys@PRIMARY;
Password:
Connected.

DGMGRL> show database 'PRIMARY';
Database - PRIMARY
  Role:            PRIMARY
  Intended State:  TRANSPORT-ON
  Instance(s):     PRIMARY
Database Status: SUCCESS
DGMGRL>
DGMGRL> show configuration;
Configuration - DR_Config
  Protection Mode: MaxAvailability
  Databases:
    PRIMARY - Primary database
    STANDBY - (*) Physical standby database
Fast-Start Failover: ENABLED
Configuration Status:SUCCESS
DGMGRL>

DGMGRL> SHOW FAST_START FAILOVER;
Fast-Start Failover: ENABLED
  Threshold:        30 seconds
  Target:           STANDBY
  Observer:         edc-noc-01d
  Lag Limit:        30 seconds (not in use)
  Shutdown Primary: TRUE
  Auto-reinstate:   TRUE
Configurable Failover Conditions
  Health Conditions:
    Corrupted Controlfile          YES
    Corrupted Dictionary           YES
    Inaccessible Logfile            NO
    Stuck Archiver                  NO
    Datafile Offline               YES
  Oracle Error Conditions:     (none)
DGMGRL>

4.6) Verify the target standby database is ready for failover.

If fast-start failover is initiated, the observer verifies the target standby database is ready to fail over to the primary database role.
  • Fast-start failover cannot occur if:
  • Fast-start failover is no longer enabled
  • The observer cannot connect to the target standby database
  • The observer and the target standby database are inconsistent with regard to the current state of the broker configuration
  • The observer is not running
  • If the protection mode is maximum availability and the target standby database was not synchronized with the primary database at the time the primary database failed
  • If the protection mode is maximum performance and the apply point of the target standby database lags the redo generation point of the primary database by more than the amount specified by the FastStartFailoverLagLimit configuration property at the time the primary database failed
  • The target standby database has contact with the primary database
  • The FS_FAILOVER_STATUS column in the V$DATABASE view for the target standby database displays a reason why fast-start failover cannot occur
  • A manual failover is already in progress.
  • The primary database was shut down without using the ABORT option

Follow the steps test Fast_start Failover :

Step 1   Connect to the target standby database.

DGMGRL> connect sys@STANDBY;

Step 2   Issue the failover command.

    Now you can issue the failover command to make the target standby database the new primary database for the configuration. Note that after the failover completes, the original primary database cannot be used as a standby database of the new primary database unless it is re-enabled.

DGMGRL> FAILOVER TO database-name [IMMEDIATE];
e.g.,
DGMGRL> FAILOVER TO 'STANDBY';
Performing failover NOW, please wait...
Error: ORA-16600: not connected to target standby database for failover

Failed.
Unable to failover
DGMGRL>

oops !!! Failed, Oh my God... Ok No. issues, We will troubleshoot

Solution: You may be in other than Standby database. Be sure you logged into Standby database though broker.

DGMGRL> connect sys@STANDBY;
Password:
Connected.

DGMGRL> show database 'STANDBY';
Database - STANDBY
  Role:            PHYSICAL STANDBY
  Intended State:  APPLY-ON
  Transport Lag:   0 seconds
  Apply Lag:       0 seconds
  Real Time Query: OFF
  Instance(s):
    STANDBY
Database Status: SUCCESS

DGMGRL> show configuration;
Configuration - DR_Config
  Protection Mode: MaxAvailability
  Databases:
    PRIMARY - Primary database
    STANDBY - (*) Physical standby database
Fast-Start Failover: ENABLED

Configuration Status: SUCCESS

DGMGRL>
DGMGRL> FAILOVER TO 'STANDBY';
Performing failover NOW, please wait...
Failover succeeded, new primary is "STANDBY"
DGMGRL>
                      
Ohhh.. Yes , Working fine.


Test Case:

I have connected to created service 'REPORT' and started executing a long running query. In the mean time I fired command manual failover. I observed, my “select” query continued and not terminated the session. This situation tells the story that application is continued seamlessly. Application server can't disturb. Only Transactions will be failed what are in primary. Next connection onwards it will continue. Now its time to re-instate the old primary as standby. Because existing standby is new primary database.


    If the target standby database is an Oracle RAC physical or snapshot standby database, the broker will direct CRS to shut down all instances except the apply instance before it continues the failover. If the other instances cannot be shut down, the failover fails. In this case, you must manually shut down all instances except the apply instance and issue the FAILOVER command again. It is also important that you do not start any new instances during the failover. The broker will direct CRS to restart instances that were shut down prior to the failover. No instances will be shut down if failing over to a logical standby database.


5) Managing observer

The observer is integrated in the DGMGRL client-side component of the broker and typically runs on a different computer from the primary or standby databases and from the computer where you manage the broker configuration. The observer continuously monitors the fast-start failover environment to ensure the primary database is available The observer's main purpose is to enhance high availability and lights out computing by reducing the human intervention required by the manual failover process that can add minutes or hours to downtime.
You can manage the observer through either the Data Guard Overview pages in Oracle Enterprise Manager or using DGMGRL commands

1.1) Stopping the Observer:
5.2) How the Observer Maintains Fast-Start Failover Configuration Information
5.3) What Happens if the Observer Fails?

1.1) Stopping the Observer:

You may want to stop the observer when you no longer want to use fast-start failover or if you want to move the observer to a different host machine.

To stop the observer when fast-start failover is enabled, the primary database and target standby database must be connected and communicating with each other. Stopping the observer does not disable the fast-start failover. However, fast-start failover cannot occur when the target standby database is in the unobserved state.

To stop the observer when fast-start failover is not enabled, the primary database must be running.You can stop the observer while connected to any database in the broker configuration that has network connectivity to the primary database, as follows:

--Using Enterprise Manager

Choose the Stop Observer option on the first page of the fast-start failover wizard and click Continue at the bottom of the page. See the Enterprise Manager online help system for more information.

--Using DGMGRL

Issue the following command:

DGMGRL> STOP OBSERVER;

Note:
The observer does not stop immediately when you issue STOP OBSERVER command. When the broker receives the STOP OBSERVER request, it informs the observer the next time the observer contacts the broker.

5.2) How the Observer Maintains Fast-Start Failover Configuration Information:

The observer persistently maintains information about the fast-start failover configuration in a binary file created in the working directory where you started the observer. By default, the observer creates this file in the current working directory when it is started and names the file fsfo.dat. This file contains connect identifiers to both the primary and the target standby databases.
Ensure this file cannot be read by unauthorized users.
Once the observer is started, you cannot change the file's name and location. However, you can change the name or the location of the file if you start the observer using the DGMGRL START OBSERVER command and include the FILE qualifier. See the START OBSERVER command for more information.
Note:
If the observer is stopped abnormally (for example, by typing CTRL/C), restart it and reference the existing fsfo.dat file with the FILE qualifier.

5.3) What Happens if the Observer Fails?

If the primary and target standby databases stay connected but the connection to the observer is lost, then the broker reports that the configuration is not observed. The configuration and database status report that the observer is not running and return one of the following
status messages:
ORA-16658: unobserved fast-start failover configuration
ORA-16820: fast-start failover observer is no longer observing this database
While the configuration is in the unobserved state, fast-start failover cannot happen. Therefore, the primary database can continue processing transactions, even if the target standby database fails. The configuration status returns the SUCCESS status after the observer reestablishes its connection to the primary database, which then notifies the target standby database.

5.4) How the Broker Performs an Immediate Failover Operation

Once you start an immediate failover, the broker:
1.    Verifies that the target standby database is enabled. If the standby database is not enabled for management by the broker, then the failover cannot occur.
2.    Stops Redo Apply or SQL Apply on the standby database immediately, without waiting until all available redo data has been applied. This may result in data loss.
3.    Transitions the target standby database into the primary role, opens the new primary database in read/write mode, and starts redo transport services.
After an immediate failover completes, all the standby databases in the configuration, regardless of their type, are disabled. They must be reenabled before they can serve as standby database to the new primary database.The broker allows the failover to proceed as long as there are no errors for the standby database that you selected to participate in the failover.

6) Reinstating a Failed Primary Database:

You can use the broker's REINSTATE command to re-enable the failed primary database after performing a complete failover to either a physical, snapshot, or logical standby database. You can also use the broker's REINSTATE command to reenable any physical standby databases that were not the target of the failover operation but were disabled during a complete failover to a physical standby database.

6.1) Whan failed primary can be re-instated
6.2) Basic steps to reinstate a database
6.3) Reinstatement Using Enterprise Manager
6.4) How to Re-create and Reenable a Disabled Database
6.5) Reinstating a Failed Primary Database


6.1) Whan failed primary can be re-instated
Databases that can be reinstated will have the following status value:
ORA-16661: the standby database needs to be reinstated
For the REINSTATE command to succeed, Flashback Database must have been enabled on the database prior to the failover and there must be sufficient flashback logs on that database. In addition, the database to be reinstated and the new primary database must have network connectivity.

6.2) Basic steps to reinstate a database:
1.    Restart the database to the mounted state
2.    Connect to the new primary database
3.    Use Enterprise Manager or DGMGRL to reinstate the database
When reinstating a failed primary database, the broker reenables it as a standby database of the same type (physical or logical standby database) as the old standby database. When reinstating physical standby databases that were disabled during a failover, the broker reenables them as physical standby databases to the new primary database.

6.3) Reinstatement Using Enterprise Manager

On the Data Guard Overview page, click the Database must be reinstated link. This brings up the General Properties page that provides a Reinstate button. After you click the Reinstate button, Enterprise Manager begins reinstating the database.
When the process is complete, the database will be enabled as a standby database to the new primary database, and Enterprise Manager displays the Data Guard Overview page.
Reinstatement Using DGMGRL
Issue the following command while connected to any database in the broker configuration, except the database that is to be reinstated:

DGMGRL> REINSTATE DATABASE db_unique_name;
The newly reinstated standby database will begin serving as standby database to the new primary database. If the database is not reinstated successfully, then you must reenable it from a copy of the new primary database.

6.4) How to Re-create and Reenable a Disabled Database :

If you performed a failover or switchover that requires you to re-create the failed primary database or standby databases that were disabled during the role transition, follow the procedures in Oracle Data Guard Concepts and Administration.
Note that if you are re-creating the old primary database, it must be created as the standby type of the old standby database. For example, if the old standby was a physical standby, then the old primary must be re-created as a physical standby. It can then be properly enabled.
After the database has been re-created, enable broker management of the re-created standby database by using the DGMGRL ENABLE DATABASE command.


6.5) Reinstating a Failed Primary Database

After failover, now primary database is 'STANDBY'.  So old primay database to be re-instead as physical stand by database. See below status from current primary database 'STANDBY'.

DGMGRL> FAILOVER TO 'STANDBY';
Performing failover NOW, please wait...
Failover succeeded, new primary is "STANDBY"
DGMGRL>

DGMGRL> show database 'STANDBY';

Database - STANDBY

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

  Database Warning(s):
    ORA-16817: unsynchronized fast-start failover configuration

Database Status: WARNING
DGMGRL>

DGMGRL> show configuration;

Configuration - DR_Config

  Protection Mode: MaxAvailability
  Databases:
    STANDBY - Primary database
      Warning: ORA-16817: unsynchronized fast-start failover configuration

    PRIMARY - (*) Physical standby database (disabled)
      ORA-16661: the standby database needs to be reinstated

Fast-Start Failover: ENABLED

Configuration Status: WARNING

DGMGRL>

If your primary database had been configured with Flashback Database, you can easily reinstate the failed primary database as a standby database of the new primary database. The failed primary database will be reinstated as a standby type that matches the old standby database. For example, if you failed over to a physical standby database, the old primary will be reinstated as a physical standby database.

To reinstate the failed primary database, start it to the mounted state. Then run DGMGRL, connect to the new primary database and reinstate the old primary database.

Step 1   Restart the Old Primary Database

SQL> startup mount;
ORACLE instance started.

Database mounted.
SQL>
SQL> select name,open_mode from v$database;

NAME          OPEN_MODE
---------         --------------------
PRIMARY       MOUNTED

SQL>


Step 2   Connect to new primary database do the following:

DGMGRL> connect sys@STANDBY;
Password:
Connected.
DGMGRL>

DGMGRL> REINSTATE DATABASE 'PRIMARY';
Reinstating database "PRIMARY", please wait...
Error: ORA-16653: failed to reinstate database

Failed.
Reinstatement of database "PRIMARY" failed

Note: Your primary database may not in mout state.

Step 3  Now REINSTATE the old primary database to make it physical standby

DGMGRL> REINSTATE DATABASE 'PRIMARY';
Reinstating database "PRIMARY", please wait...
Reinstatement of database "PRIMARY" succeeded
DGMGRL>
Now, old primary database ( PRIMARY) is re-instated as new physical standby database.


Step 4   Verify / Cross-check status:
-- See configuration
DGMGRL> SHOW CONFIGURATION;

Configuration - DR_Config
  Protection Mode: MaxAvailability
  Databases:
    STANDBY - Primary database
    PRIMARY - (*) Physical standby database
Fast-Start Failover: ENABLED

Configuration Status: SUCCESS

DGMGRL>

Connect to new physical standby ( old primary):
DGMGRL> connect sys@PRIMARY;
Password:
Connected.
DGMGRL> 

DGMGRL> show configuration;

Configuration - DR_Config

  Protection Mode: MaxAvailability
  Databases:
    STANDBY - Primary database
    PRIMARY - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status: SUCCESS

DGMGRL>
-- See the standby database
DGMGRL> show database 'PRIMARY';

Database - PRIMARY

  Role:            PHYSICAL STANDBY
  Intended State:  APPLY-ON
  Transport Lag:   0 seconds
  Apply Lag:       0 seconds
  Real Time Query: OFF
  Instance(s):     PRIMARY
Database Status: SUCCESS
DGMGRL>

-- See the status of new standby database
DGMGRL> SHOW DATABASE 'PRIMARY' 'StatusReport';
STATUS REPORT
       INSTANCE_NAME   SEVERITY ERROR_TEXT

DGMGRL>

-- See the current status of fast_stat failover

DGMGRL> SHOW FAST_START FAILOVER;

Fast-Start Failover: ENABLED

  Threshold:        30 seconds
  Target:           PRIMARY
  Observer:         edc-noc-01d
  Lag Limit:        30 seconds (not in use)
  Shutdown Primary: TRUE
  Auto-reinstate:   TRUE

Configurable Failover Conditions
  Health Conditions:
    Corrupted Controlfile          YES
    Corrupted Dictionary           YES
    Inaccessible Logfile            NO
    Stuck Archiver                  NO
    Datafile Offline               YES

  Oracle Error Conditions:
    (none)

DGMGRL> 

Thanks .. Cheers !!!!

Translate >>