Oracle 11g part 3

Continuing with the last uncovered topics from the last document:

·         Network-enabled database duplication without backups

You can use the DUPLICATE command to create a duplicate database or physical standby database over the network without a need for pre-existing database backups. This form of duplication is called active database duplication.

·         Improved integration with Data Guard

You can now set persistent RMAN configurations for a primary or physical standby database when RMAN is not connected as TARGET to the database. RMAN works seamlessly on all databases in the Data Guard environment, enabling you to use backups made on one database for restore and recovery on another database. The same recovery catalog can manage metadata for all primary and standby databases.

·         Block change tracking support for standby databases

You can enable block change tracking on a physical standby database. When you back up the standby database, RMAN can use the block change tracking file to quickly identify the blocks that changed since the last incremental backup.

·         Integration with VSS-enabled applications

The Oracle VSS writer is integrated with applications that use the Volume Shadow Copy Service (VSS) infrastructure on Windows. You can use VSS-enabled software and storage systems to back up and restore an Oracle database. A key benefit is the ability to make a shadow copy of an open database.

·         Lost write detection

You can enable the DB_LOST_WRITE_PROTECT initialization parameter to detect a lost write during managed recovery of a standby database or media recovery of a primary database. Lost write detection is disabled by default.

·         Oracle Flashback Transaction Backout

You can reverse a transaction. Oracle Database determines the dependencies between transactions and in effect creates a compensating transaction that reverses the unwanted changes. The database rewinds to a state as if the transaction, and any transactions that could be dependent on it, never occurred.

·         Flashback data archive

A flashback data archive enables the database to automatically track and store all transactional changes to a table for the duration of its lifetime. Thus, you do not need to build this functionality into database applications.

A flashback data archive is especially useful for compliance, audit reports, data analysis, and DSS (Decision Support Systems). You can use some of the logical flashback features with a flashback data archive to access data from far in the past.

 

Network-enabled database duplication without backups.

 

Before Oracle 11g when we want to duplicate a database using RMAN we had only the backup-based duplication, that means we should send our backup to the destination before start the duplicate session, now with Oracle 11g we can perform the Active Database Duplication, that basically means Oracle will create all duplicated control files, redo logs and datafiles automatically on the destination side, and it will use an auxiliary channel to transfer the data, also you can duplicate the whole database or just a subset of it.

 

To duplicate a database in a host with the same file system structure using Active Database Duplication:

 

1 – Create an auxiliary instance on the destination host, basically you can copy your initfile from the target and just change the instance name to aux for example.

Create the password file:

 

Orapwd file=orapwaux password=oracle

 

After that start the instance on the destination side.

We need to have the password file because a session will be created using the SYS account from the source to the destination database.

 

2 – Create the same directory structure on the destination side, in my case:

 

/oracle/oradata/test

 

3 – Configure the tns and listener for both servers.

 

4 – Now connect on the target database as described and also in the auxiliary database, where you are going to duplicate it.

 

rman

 

Recovery Manager: Release 11.1.0.6.0 - Production on Thu Aug 30 11:49:36 2007

 

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

 

RMAN> connect target sys/oracle@test

 

connected to target database: TEST (DBID=1928403553)

 

RMAN> connect auxiliary sys/oracle@aux

 

connected to auxiliary database: TEST (not mounted)

 

 

5 – Executing the duplicate command, you will see that it show all the commands that it automatically executes:

 

RMAN> DUPLICATE TARGET DATABASE

2>    TO AUX

3>    FROM ACTIVE DATABASE

4>    SPFILE

5>    NOFILENAMECHECK;

 

Starting Duplicate Db at 30-AUG-07

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=152 device type=DISK

 

contents of Memory Script:

{

   backup as copy reuse

   file  '/oracle/11.1/dbs/spfiletest.ora' auxiliary format

 '/oracle/11.1/dbs/spfileaux.ora'   ;

   sql clone "alter system set spfile= ''/oracle/11.1/dbs/spfileaux.ora''";

}

executing Memory Script

 

Starting backup at 30-AUG-07

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=142 device type=DISK

Finished backup at 30-AUG-07

 

sql statement: alter system set spfile= ''/oracle/11.1/dbs/spfileaux.ora''

 

contents of Memory Script:

{

   sql clone "alter system set  db_name =

 ''AUX'' comment=

 ''duplicate'' scope=spfile";

   sql clone "alter system set  db_unique_name =

 ''AUX'' comment=

 ''duplicate'' scope=spfile";

   shutdown clone immediate;

   startup clone nomount ;

}

executing Memory Script

 

sql statement: alter system set  db_name =  ''AUX'' comment= ''duplicate'' scope=spfile

 

sql statement: alter system set  db_unique_name =  ''AUX'' comment= ''duplicate'' scope=spfile

 

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area     732352512 bytes

 

Fixed Size                     1302428 bytes

Variable Size                675283044 bytes

Database Buffers              50331648 bytes

Redo Buffers                   5435392 bytes

 

contents of Memory Script:

{

   set newname for datafile  1 to

 "/oracle/oradata/test/system01.dbf";

   set newname for datafile  2 to

 "/oracle/oradata/test/sysaux01.dbf";

   set newname for datafile  3 to

 "/oracle/oradata/test/sqlmag01.dbf";

   set newname for datafile  4 to

 "/oracle/oradata/test/users01.dbf";

   set newname for datafile  5 to

 "/oracle/oradata/test/test_block01.dbf";

   set newname for datafile  6 to

 "/oracle/oradata/test/rman_catalog01.dbf";

   set newname for datafile  7 to

 "/oracle/oradata/test/undotbs201.dbf";

   backup as copy reuse

   datafile  1 auxiliary format

 "/oracle/oradata/test/system01.dbf"   datafile

 2 auxiliary format

 "/oracle/oradata/test/sysaux01.dbf"   datafile

 3 auxiliary format

 "/oracle/oradata/test/sqlmag01.dbf"   datafile

 4 auxiliary format

 "/oracle/oradata/test/users01.dbf"   datafile

 5 auxiliary format

 "/oracle/oradata/test/test_block01.dbf"   datafile

 6 auxiliary format

 "/oracle/oradata/test/rman_catalog01.dbf"   datafile

 7 auxiliary format

 "/oracle/oradata/test/undotbs201.dbf"   ;

   sql 'alter system archive log current';

}

executing Memory Script

 

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 30-AUG-07

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

input datafile file number=00002 name=/oracle/oradata/test/sysaux01.dbf

 

output file name=/oracle/oradata/test/sysaux01.dbf tag=TAG20070830T122317 RECID=                                                                              0 STAMP=0

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00001 name=/oracle/oradata/test/system01.dbf

output file name=/oracle/oradata/test/system01.dbf tag=TAG20070830T122317 RECID=                                                                              0 STAMP=0

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00004 name=/oracle/oradata/test/users01.dbf

output file name=/oracle/oradata/test/users01.dbf tag=TAG20070830T122317 RECID=0                                                                               STAMP=0

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:26

channel ORA_DISK_1: starting datafile copy

input datafile file number=00006 name=/oracle/oradata/test/rman_catalog01.dbf

output file name=/oracle/oradata/test/rman_catalog01.dbf tag=TAG20070830T122317                                                                               RECID=0 STAMP=0

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15

channel ORA_DISK_1: starting datafile copy

input datafile file number=00007 name=/oracle/oradata/test/undotbs201.dbf

output file name=/oracle/oradata/test/undotbs201.dbf tag=TAG20070830T122317 RECI                                                                              D=0 STAMP=0

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15

channel ORA_DISK_1: starting datafile copy

input datafile file number=00003 name=/oracle/oradata/test/sqlmag01.dbf

output file name=/oracle/oradata/test/sqlmag01.dbf tag=TAG20070830T122317 RECID=                                                                              0 STAMP=0

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting datafile copy

input datafile file number=00005 name=/oracle/oradata/test/test_block01.dbf

output file name=/oracle/oradata/test/test_block01.dbf tag=TAG20070830T122317 RE                                                                              CID=0 STAMP=0

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 30-AUG-07

 

sql statement: alter system archive log current

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX" RESETLOGS ARCHIVELOG

  MAXLOGFILES     16

  MAXLOGMEMBERS      3

  MAXDATAFILES      100

  MAXINSTANCES     8

  MAXLOGHISTORY     2336

 LOGFILE

  GROUP  1  SIZE 50 M ,

  GROUP  2  SIZE 50 M ,

  GROUP  3  SIZE 50 M

 DATAFILE

  '/oracle/oradata/test/system01.dbf'

 CHARACTER SET WE8ISO8859P15

 

 

contents of Memory Script:

{

   backup as copy reuse

   archivelog like  "/oracle/11.1/dbs/arch1_12_631806660.dbf" auxiliary format

 "/oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_12_%u_.arc"   ar                                                                              chivelog like

 "/oracle/flash_recovery_area/TEST/archivelog/2007_08_30/o1_mf_1_12_3ffbfqtv_.ar                                                                              c" auxiliary format

 "/oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_12_%u_.arc"   ;

   catalog clone recovery area;

   switch clone datafile all;

}

executing Memory Script

 

Starting backup at 30-AUG-07

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log copy

input archived log thread=1 sequence=12 RECID=140 STAMP=631974472

output file name=/oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_1                                                                              2_3aiqmaic_.arc RECID=0 STAMP=0

channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting archived log copy

input archived log thread=1 sequence=12 RECID=141 STAMP=631974472

output file name=/oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_1                                                                              2_3biqmaij_.arc RECID=0 STAMP=0

channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01

Finished backup at 30-AUG-07

 

searching for all files in the recovery area

 

List of Files Unknown to the Database

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

File Name: /oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_12_3aiq                                                                              maic_.arc

File Name: /oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_12_3biq                                                                              maij_.arc

cataloging files...

cataloging done

 

List of Cataloged Files

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

File Name: /oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_12_3aiq                                                                              maic_.arc

File Name: /oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_12_3biq                                                                              maij_.arc

 

datafile 2 switched to datafile copy

input datafile copy RECID=1 STAMP=631974751 file name=/oracle/oradata/test/sysau                                                                              x01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=2 STAMP=631974751 file name=/oracle/oradata/test/sqlma                                                                              g01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=3 STAMP=631974751 file name=/oracle/oradata/test/users                                                                              01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=4 STAMP=631974751 file name=/oracle/oradata/test/test_                                                                              block01.dbf

datafile 6 switched to datafile copy

input datafile copy RECID=5 STAMP=631974751 file name=/oracle/oradata/test/rman_                                                                              catalog01.dbf

datafile 7 switched to datafile copy

input datafile copy RECID=6 STAMP=631974752 file name=/oracle/oradata/test/undot                                                                              bs201.dbf

 

contents of Memory Script:

{

   set until scn  18642873;

   recover

   clone database

    delete archivelog

   ;

}

executing Memory Script

 

executing command: SET until clause

 

Starting recover at 30-AUG-07

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=153 device type=DISK

 

starting media recovery

 

archived log for thread 1 with sequence 12 is already on disk as file /oracle/fl                                                                              ash_recovery_area/AUX/archivelog/2007_08_30/o1_mf_1_12_3aiqmaic_.arc

archived log file name=/oracle/flash_recovery_area/AUX/archivelog/2007_08_30/o1_                                                                              mf_1_12_3aiqmaic_.arc thread=1 sequence=12

media recovery complete, elapsed time: 00:00:00

Finished recover at 30-AUG-07

 

contents of Memory Script:

{

   shutdown clone immediate;

   startup clone nomount ;

}

executing Memory Script

 

database dismounted

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area     732352512 bytes

 

Fixed Size                     1302428 bytes

Variable Size                675283044 bytes

Database Buffers              50331648 bytes

Redo Buffers                   5435392 bytes

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX" RESETLOGS ARCHIVELOG

  MAXLOGFILES     16

  MAXLOGMEMBERS      3

  MAXDATAFILES      100

  MAXINSTANCES     8

  MAXLOGHISTORY     2336

 LOGFILE

  GROUP  1  SIZE 50 M ,

  GROUP  2  SIZE 50 M ,

  GROUP  3  SIZE 50 M

 DATAFILE

  '/oracle/oradata/test/system01.dbf'

 CHARACTER SET WE8ISO8859P15

 

 

contents of Memory Script:

{

   set newname for tempfile  1 to

 "/oracle/oradata/test/temp01.dbf";

   switch clone tempfile all;

   catalog clone datafilecopy  "/oracle/oradata/test/sysaux01.dbf";

   catalog clone datafilecopy  "/oracle/oradata/test/sqlmag01.dbf";

   catalog clone datafilecopy  "/oracle/oradata/test/users01.dbf";

   catalog clone datafilecopy  "/oracle/oradata/test/test_block01.dbf";

   catalog clone datafilecopy  "/oracle/oradata/test/rman_catalog01.dbf";

   catalog clone datafilecopy  "/oracle/oradata/test/undotbs201.dbf";

   switch clone datafile all;

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed tempfile 1 to /oracle/oradata/test/temp01.dbf in control file

 

cataloged datafile copy

datafile copy file name=/oracle/oradata/test/sysaux01.dbf RECID=1 STAMP=63197476                                                                              4

 

cataloged datafile copy

datafile copy file name=/oracle/oradata/test/sqlmag01.dbf RECID=2 STAMP=63197476                                                                              5

 

cataloged datafile copy

datafile copy file name=/oracle/oradata/test/users01.dbf RECID=3 STAMP=631974765

 

cataloged datafile copy

datafile copy file name=/oracle/oradata/test/test_block01.dbf RECID=4 STAMP=6319                                                                              74765

 

cataloged datafile copy

datafile copy file name=/oracle/oradata/test/rman_catalog01.dbf RECID=5 STAMP=63                                                                              1974765

 

cataloged datafile copy

datafile copy file name=/oracle/oradata/test/undotbs201.dbf RECID=6 STAMP=631974                                                                              765

 

datafile 2 switched to datafile copy

input datafile copy RECID=1 STAMP=631974764 file name=/oracle/oradata/test/sysau                                                                              x01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=2 STAMP=631974765 file name=/oracle/oradata/test/sqlma                                                                              g01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=3 STAMP=631974765 file name=/oracle/oradata/test/users                                                                              01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=4 STAMP=631974765 file name=/oracle/oradata/test/test_                                                                              block01.dbf

datafile 6 switched to datafile copy

input datafile copy RECID=5 STAMP=631974765 file name=/oracle/oradata/test/rman_                                                                              catalog01.dbf

datafile 7 switched to datafile copy

input datafile copy RECID=6 STAMP=631974765 file name=/oracle/oradata/test/undot                                                                              bs201.dbf

 

contents of Memory Script:

{

   Alter clone database open resetlogs;

}

executing Memory Script

 

database opened

Finished Duplicate Db at 30-AUG-07

 

After that you can check you auxiliary instance, that actually now is your duplicated database:

 

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

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

 

SQL> select instance_name from v$instance;

 

INSTANCE_NAME

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

aux

 

SQL> select open_mode from v$database;

 

OPEN_MODE

----------

READ WRITE

 

SQL> select name from v$database;

 

NAME

---------

AUX

 

You saw the database was all copied over to the destination server, and it did all the processes automatically.

 

If your destination does not have the same directory structure, you just need to use these parameters on the init file:

 

DB_FILE_NAME_CONVERT – where you specify the source and target datafile separated by comma.

PARAMETER_VALUE_CONVERT – this one will change every parameter using one string by the other.

LOG_FILE_NAME_CONVERT – the same as the above but for the redo log files.

 

Or you can simply use it directly on the DUPLICATE DATABASE command:

 

DUPLICATE TARGET DATABASE
TO AUX
FROM ACTIVE DATABASE   
DB_FILE_NAME_CONVERT '/oracle/oradata/test/','/oracle/oradata/aux/'
  SPFILE 
    PARAMETER_VALUE_CONVERT '/oracle/oradata/test/', '/oracle/oradata/aux/'
    SET SGA_MAX_SIZE '300M'
    SET SGA_TARGET '250M'
    SET LOG_FILE_NAME_CONVERT '/oracle/oradata/test/redo/','/oracle/oradata/aux/redo/';

 

Improved integration with Data Guard

 

Not only the integration was improved but also some new features were created to improve the standby administration.

 

In first place let’s create a standby environment.

 

If you are already familiar in how to do that in the older releases you will see that you can still do it in the same way.

 

Parameters used to create a physical standby database:

 

Parameter

Recommended Setting

DB_NAME

Specify an 8-character name. Use the same name for all standby databases.

DB_UNIQUE_NAME

Specify a unique name for each database. This name stays with the database and does not change, even if the primary and standby databases reverse roles.

LOG_ARCHIVE_CONFIG

Specify the DG_CONFIG attribute on this parameter to list the DB_UNIQUE_NAME of the primary and standby databases in the Data Guard configuration; this enables the dynamic addition of a standby database to a Data Guard configuration that has an Oracle RAC primary database running in either maximum protection or maximum availability mode. By default, the LOG_ARCHIVE_CONFIG parameter enables the database to send and receive redo.

CONTROL_FILES

Specify the path name for the control files on the primary database. It is recommended that a second copy of the control file is available so an instance can be easily restarted after copying the good control file to the location of the bad control file.

LOG_ARCHIVE_DEST_n

Specify where the redo data is to be archived on the primary and standby systems.

Note: If a flash recovery area was configured (with the DB_RECOVERY_FILE_DEST initialization parameter) and you have not explicitly configured a local archiving destination with the LOCATION attribute, Data Guard automatically uses the LOG_ARCHIVE_DEST_10 initialization parameter as the default destination for local archiving.

LOG_ARCHIVE_DEST_STATE_n

Specify ENABLE to allow redo transport services to transmit redo data to the specified destination.

REMOTE_LOGIN_PASSWORDFILE

This parameter must be set to EXCLUSIVE or SHARED if a remote login password file is used to authenticate administrative users or redo transport sessions.

LOG_ARCHIVE_FORMAT

Specify the format for the archived redo log files using a thread (%t), sequence number (%s), and resetlogs ID (%r).

LOG_ARCHIVE_MAX_PROCESSES =integer

Specify the maximum number (from 1 to 30) of archiver (ARCn) processes you want Oracle software to invoke initially. The default value is 4.

FAL_SERVER

Specify the Oracle Net service name of the FAL server (typically this is the database running in the Standby role). When the Primary  database is running in the standby role, it uses the Standby  database as the FAL server from which to fetch (request) missing archived redo log files if Standby  is unable to automatically send the missing log files.

FAL_CLIENT

Specify the Oracle Net service name of the Primary database. The FAL server (Standby) copies missing archived redo log files to the Primary standby database.

DB_FILE_NAME_CONVERT

Specify the path name and filename location of the primary database datafiles followed by the standby location. This parameter converts the path names of the primary database datafiles to the standby datafile path names. If the standby database is on the same system as the primary database or if the directory structure where the datafiles are located on the standby site is different from the primary site, then this parameter is required. Note that this parameter is used only to convert path names for physical standby databases. Multiple pairs of paths may be specified by this parameter.

LOG_FILE_NAME_CONVERT

Specify the location of the primary database online redo log files followed by the standby location. This parameter converts the path names of the primary database log files to the path names on the standby database. If the standby database is on the same system as the primary database or if the directory structure where the log files are located on the standby system is different from the primary system, then this parameter is required. Multiple pairs of paths may be specified by this parameter.

STANDBY_FILE_MANAGEMENT

Set to AUTO so when datafiles are added to or dropped from the primary database, corresponding changes are made automatically to the standby database.

 

Steps to create a physical standby database:

 

1 – Make a hotbackup or cold backup and move the files to the Standby server.

 

2 – Create a Standby controlfile

 

3 – Prepare the parameter files.

 

4 – Prepare the environment, tnsnames, etc…

 

As you saw for a standby database works you need to have your primary database in archivelog mode, so if you are not in this mode, please do so.

 

Since my database is very small, I will use a hot backup and ftp the files directly to the destinations.

 

The Primary database calls LONDON and the Standby CAMPINAS(my old home town).

 

Step 1:

 

SQL> select file_name from dba_data_files;

 

FILE_NAME

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

/oracle/oradata/test/system01.dbf

/oracle/oradata/test/sysaux01.dbf

/oracle/oradata/test/users01.dbf

/oracle/oradata/test/test_block01.dbf

/oracle/oradata/test/sqlmag01.dbf

/oracle/oradata/test/undotbs201.dbf

/oracle/oradata/test/rman_catalog01.dbf

 

 

SQL> alter database begin backup;

 

Now I can FTP the files to the Standby server.

When the FTP is done I end the backup.

 

SQL> alter database end backup;

 

Database altered.

 

Step 2:

 

SQL> alter database create standby controlfile as '/oracle/controlstb.ctl';

 

Database altered.

 

Copy the standby controlfile to the Standy server.

 

Step 3:

 

Parameter file for the Primary database:

 

processes=150

sessions=170

sga_target=0

control_files=('/oracle/oradata/test/control01.ctl','/oracle/oradata/test/control02.ctl','/oracle/oradata/test/control03.ctl')

db_block_size=8192

compatible=11.1.0.0.0

undo_management=AUTO

undo_tablespace=UNDOTBS2

instance_number=0

ldap_directory_sysauth=no

open_cursors=300

star_transformation_enabled=FALSE

pga_aggregate_target=183500800

 

db_name=london

remote_login_passwordfile=EXCLUSIVE

 

#Archive and Standby Parameters

db_recovery_file_dest='/oracle/flash_recovery_area'

db_recovery_file_dest_size=70g

 

db_unique_name=london

 

LOG_ARCHIVE_CONFIG='DG_CONFIG=(london,campinas)'

LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc

LOG_ARCHIVE_DEST_1='location=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=london'

LOG_ARCHIVE_DEST_2='SERVICE=campinas ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=campinas'

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

STANDBY_FILE_MANAGEMENT=AUTO

FAL_SERVER=campinas

FAL_CLIENT=london

 

Services_names=london, primary

 

Local_listener=’(ADDRESS=(PROTOCOL=tcp)(HOST=primary)(PORT=1535))’

 

TNS on the primary server:

campinas =

     (DESCRIPTION=

         (ADDRESS_LIST=

            (ADDRESS=(PROTOCOL=TCP)(HOST=standby)(PORT=1535))

         )

     (CONNECT_DATA=

         (SERVICE_NAME=campinas)

     )

)

 

 

Standby Parameter:

 

processes=150

sessions=170

sga_target=0

control_files=('/oracle/oradata/test/controlstb.ctl')

db_block_size=8192

compatible=11.1.0.0.0

undo_management=AUTO

undo_tablespace=UNDOTBS2

instance_number=0

ldap_directory_sysauth=no

open_cursors=300

star_transformation_enabled=FALSE

pga_aggregate_target=183500800

 

db_name=london

remote_login_passwordfile=EXCLUSIVE

 

#Archive and Standby Parameters

db_recovery_file_dest='/oracle/flash_recovery_area'

db_recovery_file_dest_size=70g

 

db_unique_name=campinas

 

LOG_ARCHIVE_CONFIG='DG_CONFIG=(london,campinas)'

LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc

LOG_ARCHIVE_DEST_1='location=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=campinas'

LOG_ARCHIVE_DEST_2='SERVICE=london ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=london'

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

STANDBY_FILE_MANAGEMENT=AUTO

FAL_SERVER=london

FAL_CLIENT=campinas

Local_listener=’(ADDRESS=(PROTOCOL=tcp)(HOST=rapiddbdr.turner.com)(PORT=1535))’

 

 

TNS on the Standby server:

london =

     (DESCRIPTION=

         (ADDRESS_LIST=

            (ADDRESS=(PROTOCOL=TCP)(HOST=primary)(PORT=1535))

         )

     (CONNECT_DATA=

         (SERVICE_NAME=london)

     )

)

 

An important consideration is about the listener, if you want to use tns failover, that we will check later, you can not register the database manually using the clause:

 

SID_LIST_LISTENER=

   (SID_LIST=

        (SID_DESC=

          (GLOBAL_DBNAME=test)

          (SID_NAME=test)

          (ORACLE_HOME=/oracle/11.1)

         )

 

Instead you just need to use the init parameter local_listener to specify a listener that is using a different port of 1521.

 

Another thing, both standby and primary must have the same password for the SYS user, so the easiest way is copy the primary password file to the standby server as well.

 

After everything set up, you can start the standby:

 

Startup nomount

Alter database mount standy database;

Alter database recover managed standby database disconnect from session;

 

After that your standby is ready to apply the redo logs that will come from the primary database.

 

Now that we have our standby working, let’s test the improvements.

 

Setting up the TNS failover:

 

London =

  (DESCRIPTION_LIST =

    (FAILOVER = true)

    (LOAD_BALANCE = FALSE)

    (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1535))(CONNECT_DATA = (SERVICE_NAME = primary)))

    (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1535))(CONNECT_DATA = (service_name = primary)))

  )

 

 

As you saw I’ve used the parameter service_names to define 2 services for each instance, one to be used by the dataguard, and another one that we will be used for our client connection.

 

The reason I did that is because the TNS failover is based on the service name, that means if the listener is listening for a service it will try to connect even if the database is not open.

 

So when we do a switchover or a failover, we just change the service name dynamically and the tns failover will work.

 

That is why for both servers I’ve used the service name primary, so when I start to use the standby database I will do the following:

 

To perform a switchover:

Primary database:

ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

 

Shutdown immediate

Startup mount

Alter database mount standby database;

Alter database recover managed standby database disconnect from session;

 

LONDON (old primary)

Alter system set service_names=London; (I’ve removed the primary service name now)

 

Standby Database:

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

Shutdown immediate

Startup;

 

CAMPINAS (new primary)

Alter system set service_names=campinas, primary;

 

At this point when some one try to connect to the primary service name it will go to the standby server.

 

 

Now that we have a standby working let’s check the new features:

 

Common features used by Redo application:

 

Compression for gap resolution:

 

 

To use that feature in first place you need to buy a different license, that is not a good start.

 

To activate compression we need to specify on the log_archive_dest_.. parameter COMPRESSION=ENABLE.

 

After that you can check on V$ARCHIVE_DEST to see if the compression is enable for the specified destination.

 

Eg:

LOG_ARCHIVE_DEST_2='SERVICE=london ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=london compression=enable'

 

Alter system set LOG_ARCHIVE_DEST_2='SERVICE=london ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=london compression=enable';

 

I’ve done some tests and honestly it didn’t work as expected, there is a lack of documentation as well. I’ve created a gap of more than 50 archives and it didn’t compress anything.

 

So we will need to wait some answer from Oracle about that.

 

Redo transport response time histogram

The V$REDO_DEST_RESP_HISTOGRAM dynamic performance view contains a histogram of response times for each SYNC redo transport destination. The data in this view can be used to assist in the determination of an appropriate value for the LOG_ARCHIVE_DEST_n NET_TIMEOUT attribute.

Enhancements around DB_UNIQUE_NAME

You can now find the DB_UNIQUE_NAME of the primary database from the standby database by querying the new PRIMARY_DB_UNIQUE_NAME column in the V$DATABASE view. Also, Oracle Data Guard release 11g ensures each database's DB_UNIQUE_NAME is different. After upgrading to 11g, any databases with the same DB_UNIQUE_NAME will not be able to communicate with each other.

SQL>  select name, db_unique_name from v$database;

 

NAME      DB_UNIQUE_NAME

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

LONDON    campinas

 

 

 

Real-time query

 

Before Oracle 11g a physical standby database could be opened as read only, but the redo apply was stopped, now we have the capability to keep applying the redo transactions and use the standby in read only mode at the same time:

 

These are the steps to put your standby in read only mode with redo still being applied:

 

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

 

Database altered.

 

SQL> ALTER DATABASE OPEN;

 

Database altered.

 

SQL> select open_mode from v$database;

 

OPEN_MODE

----------

READ ONLY

 

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

 

Database altered.

 

Just a small detail, you need to buy a separate license for that…

 

This is a very useful tool, you could point out all your reports to this standby database without losing synchronism.

 

Snapshoot database.

 

Another very interesting new feature is the Snapshoot database, with it you can turn your standby in an read write database, do whatever you want, and then turn it back as a standby again.

 

The only thing is meanwhile you are in read write mode, the synchronization will stop, your archives will continue to be pushed over but will not be applied, only when you turn it back to standby, it will start to catch up.

 

It use the flashback feature to be able to do that, that means it will undo everything you have done before it start to synchronize it again.

 

Let’s check.

 

 

 

 

 

 

My standby is in Real-Time query:

 

SQL>  select count(1) from obj;

 

  COUNT(1)

----------

     68967

 

 

Now I’m going to move it to snapshoot database:

 

SQL> alter database recover managed standby database cancel;

 

Database altered.

 

SQL> ALTER DATABASE CONVERT TO SNAPSHOT STANDBY ;

 

Database altered.

 

SQL> shutdown

ORA-01507: database not mounted

 

 

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  313860096 bytes

Fixed Size                  1299624 bytes

Variable Size              96471896 bytes

Database Buffers          209715200 bytes

Redo Buffers                6373376 bytes

Database mounted.

Database opened.

SQL> select open_mode from v$database;

 

OPEN_MODE

----------

READ WRITE

 

At this moment, I’m read write mode, and my standby database keeps sending the archived through the network.

 

SQL> delete from obj where object_id>10000;

 

59248 rows deleted.

 

SQL> commit;

 

Commit complete.

 

SQL> select count(1) from obj;

 

  COUNT(1)

----------

      9719

 

Now I’m going to return my snapshot to a standby again:

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  313860096 bytes

Fixed Size                  1299624 bytes

Variable Size              96471896 bytes

Database Buffers          209715200 bytes

Redo Buffers                6373376 bytes

 

SQL> alter database mount;

 

Database altered.

 

SQL>  ALTER DATABASE CONVERT TO PHYSICAL STANDBY;

 

Database altered.

 

SQL> shutdown immediate

ORA-01507: database not mounted

 

 

ORACLE instance shut down.

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  313860096 bytes

Fixed Size                  1299624 bytes

Variable Size              96471896 bytes

Database Buffers          209715200 bytes

Redo Buffers                6373376 bytes

SQL> alter database mount standby database;

 

Database altered.

 

SQL> alter database recover managed standby database disconnect from session;

 

Database altered.

 

After wait a few seconds the redo to be applied I will open it in read only and see how the OBJ table is:

 

SQL> alter database recover managed standby database cancel;

 

Database altered.

 

SQL> alter database open read only;

 

Database altered.

 

SQL>  select count(1) from obj;

 

  COUNT(1)

----------

     68967

 

There we go, our standby is back, this feature can be very handful when we need to do some tests using production data up to date, and better we can get back our standby without recreate it.

 

Improved Integration with RMAN

A number of enhancements in RMAN help to simplify backup and recovery operations across all primary and physical standby databases, when using a catalog. Also, you can use the RMAN DUPLICATE command to create a physical standby database over the network without a need for pre-existing database backups.

New Features Specific to SQL Apply and Logical Standby Databases

The following list summarizes the new features for SQL Apply and logical standby databases in Oracle Database 11g Release 1 (11.1):

Support for additional object datatypes and PL/SQL package support

o        XML stored as CLOB

Support for additional PL/SQL Package

o        DBMS_RLS (row level security or Virtual Private Database)

o        DBMS_FGA

Support Transparent Data Encryption (TDE)

Data Guard SQL Apply can be used to provide data protection for the primary database with Transparent Data Encryption enabled. This allows a logical standby database to provide data protection for applications with advanced security requirements.

Dynamic setting of Data Guard SQL Apply parameters

You can now configure specific SQL Apply parameters without requiring SQL Apply to be restarted. Using the DBMS_LOGSTDBY.APPLY_SET package, you can dynamically set initialization parameters, thus improving the manageability, uptime, and automation of a logical standby configuration.

In addition, the APPLY_SET and APPLY_UNSET subprograms include two new parameters: LOG_AUTO_DEL_RETENTION_TARGET and EVENT_LOG_DEST.

Enhanced RAC switchover support for logical standby databases

When switching over to a logical standby database where either the primary database or the standby database is using Oracle RAC, the SWITCHOVER command can be used without having to shut down any instance, either at the primary or at the logical standby database.

Enhanced DDL handling in Oracle Data Guard SQL Apply

SQL Apply will execute parallel DDLs in parallel (based on availability of parallel servers).

Use of the PL/SQL DBMS_SCHEDULER package to create Scheduler jobs on a standby database

Scheduler Jobs can be created on a standby database using the PL/SQL DBMS_SCHEDULER package and can be associated with an appropriate database role so that they run when intended (for example, when the database is the primary, standby, or both).

Not finished yet…..