Sie sind auf Seite 1von 180

Appendix A

Practices and Solutions


Table of Contents
Practices for Lesson 1: Introduction to Oracle Data Guard ................................................ 4
Practices for Lesson 2: Creating a Physical Standby Database by Using SQL and
RMAN Commands ........................................................................................................... 5
Practice 2-1: Preparing the Primary Database ................................................................ 6
Practice 2-2: Creating the Physical Standby Database ................................................. 12
Practice 2-3: Verifying That the Physical Standby Database Is Performing Correctly 27
Practices for Lesson 3: Oracle Data Guard Broker: Overview ......................................... 29
Practices for Lesson 4: Creating a Data Guard Broker Configuration ............................. 30
Practice 4-1: Setting the DG_BROKER_START Initialization Parameter .................. 31
Practice 4-2: Creating a Listener Service for the Primary Database ............................ 33
Practice 4-3: Creating a Listener Service for the Standby Database ............................ 36
Practice 4-4: Creating an Oracle Net Service Name for the Primary Database............ 39
Practice 4-5: Creating an Oracle Net Service Name for the Standby Database ........... 42
Practice 4-6: Creating the Broker Configuration .......................................................... 45
Practice 4-7: Enabling the Broker Configuration ......................................................... 47
Practices for Lesson 5: Creating a Physical Standby Database by Using Enterprise
Manager Grid Control ..................................................................................................... 48
Practice 5-1: Installing the Oracle Management Agent ................................................ 49
Practice 5-2: Configuring Monitoring Credentials for Your Primary Database ........... 61
Practice 5-3: Configuring Monitoring Credentials for Your Standby Database........... 62
Practice 5-4: Adding a Physical Standby Database to Your Configuration ................. 63
Practice 5-5: Verifying the Broker Configuration ........................................................ 72
Practice 5-6: Deleting the Database .............................................................................. 75
Practices for Lesson 6: Creating a Logical Standby Database ......................................... 77
Practice 6-1: Creating a Logical Standby Database ...................................................... 78
Practice 6-2: Implementing SQL Apply Filtering ........................................................ 82
Practices for Lesson 7: Configuring Data Protection Modes............................................ 86
Practice 7-1: Setting the Data Protection Mode by Using DGMGRL .......................... 87
Practice 7-2: Setting the Data Protection Mode by Using Enterprise Manager Grid
Control .......................................................................................................................... 91
Practices for Lesson 8: Monitoring a Data Guard Broker Configuration ........................ 96
Practice 8-1: Viewing Log File Details ........................................................................ 97
Practice 8-2: Using DGMGRL to Monitor the Configuration .................................... 101
Practices for Lesson 9: Optimizing a Data Guard Configuration ................................... 106
Practice 9-1: Configuring Network Compression of Redo Data ................................ 107
Practices for Lesson 10: Using Flashback Database in a Data Guard Configuration ..... 109
Practice 10-1: Configuring Flashback Database on the Primary Database ................ 110
Practice 10-2: Configuring Flashback Database on the Standby Database ................ 111
Practices for Lesson 11: Performing Role Transitions ................................................... 112
Practice 11-1: Performing Switchover by Using DGMGRL ...................................... 113
Practice 11-2: Performing Switchover by Using Enterprise Manager........................ 119
Practices for Lesson 12: Enabling Fast-Start Failover .................................................... 121
Practice 12-1: Enabling Fast-Start Failover ................................................................ 122
Practice 12-2: Starting the Observer ........................................................................... 124

Oracle Database 11g: Data Guard Administration A - 2


Practice 12-3: Testing Fast-Start Failover .................................................................. 126
Practice 12-4: Switching Back to Your Primary Database ......................................... 130
Practice 12-5: Stopping the Observer and Disabling Fast-Start Failover ................... 132
Practices for Lesson 13: Creating and Managing a Snapshot Standby Database ........... 134
Practice 13-1: Verifying Flashback Database on the Physical Standby Database ...... 135
Practice 13-2: Converting the Physical Standby Database to a Snapshot Standby
Database ...................................................................................................................... 137
Practice 13-3: Updating the Databases and Verifying Redo Shipment ...................... 138
Practice 13-4: Converting the Snapshot Standby Database to a Physical Standby
Database ...................................................................................................................... 140
Practices for Lesson 14: Using Oracle Active Data Guard............................................. 145
Practice 14-1: Using Real-Time Query....................................................................... 146
Practice 14-2: Enabling Block Change Tracking........................................................ 151
Practices for Lesson 15: Backup and Recovery Considerations in an Oracle Data Guard
Configuration ................................................................................................................ 152
Practice 15-1: Creating the Recovery Catalog ............................................................ 153
Practice 15-2: Registering Your Database in the Recovery Catalog .......................... 155
Practice 15-3: Configuring RMAN Parameters .......................................................... 158
Practice 15-4: Recovering a Data File in Your Primary Database ............................. 162
Practices for Lesson 16: Managing Client Connectivity ................................................ 167
Practice 16-1: Creating a Service ................................................................................ 168
Practice 16-2: Creating an AFTER STARTUP Trigger ............................................. 170
Practice 16-3: Creating an Oracle Net Service Name on Your Primary Database Host
..................................................................................................................................... 171
Practice 16-4: Creating an Oracle Net Service Name on Your Standby Database Host
..................................................................................................................................... 173
Practice 16-5: Testing Your Implementation .............................................................. 174
Practices for Lesson 17: Patching and Upgrading Databases in a Data Guard
Configuration ................................................................................................................ 179

Oracle Database 11g: Data Guard Administration A - 3


Practices for Lesson 1: Introduction to Oracle
Data Guard
There are no practices for Lesson 1, “Introduction to Oracle Data Guard.”

Oracle Database 11g: Data Guard Administration A - 4


Practices for Lesson 2: Creating a Physical Standby
Database by Using SQL and RMAN Commands
In the practices for Lesson 2, “Creating a Physical Standby Database by Using SQL and
RMAN Commands,” you create a physical standby database by using SQL and RMAN
commands.

Use this page to record information about the databases in your configuration.

Primary Database
Database Name: _________________________________________________
Instance Name: _________________________________________________
Database Unique Name: __________________________________________
Target Name: ___________________________________________________
Host: __________________________________________________________
Oracle Home: ____________________________________________________

Standby Database
Database Name: _________________________________________________
Instance Name: _________________________________________________
Database Unique Name: __________________________________________
Target Name: ___________________________________________________
Host: __________________________________________________________
Oracle Home: ____________________________________________________

Standby Database
Database Name: _________________________________________________
Instance Name: _________________________________________________
Database Unique Name: __________________________________________
Target Name: ___________________________________________________
Host: __________________________________________________________
Oracle Home: ____________________________________________________

Standby Database
Database Name: _________________________________________________
Instance Name: _________________________________________________
Database Unique Name: __________________________________________
Target Name: ___________________________________________________
Host: __________________________________________________________
Oracle Home: ____________________________________________________

Oracle Database 11g: Data Guard Administration A - 5


Practice 2-1: Preparing the Primary Database
In this practice, you verify that the primary database is configured correctly to support a
physical standby database.

Your primary database is named pc<nn>prmy, where nn represents the number of the
PC you are using in the classroom.
You create a standby database named pc<nn>sby1, where nn represents the number of
the PC that you are using in the classroom (and your primary database is on).
For example, if you are using PC 5, your primary database is pc05prmy and your
standby database is pc05sby1.
1) Open a terminal window. Change to the labs directory. Verify that the
ORACLE_SID environment variable is set to your primary database. Invoke
SQL*Plus and connect as SYSDBA to your primary database. Determine if FORCE
LOGGING is enabled. If it is not enabled, enable FORCE LOGGING mode.
[oracle@edt3r17p0-pc00prmy ~]$ cd labs
[oracle@edt3r17p0-pc00prmy labs]$ echo $ORACLE_SID
pc00prmy
[oracle@edt3r17p0-pc00prmy labs]$
[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Oct 15


15:05:44 2007

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

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

SQL> SELECT force_logging FROM v$database;

FOR
---
NO

SQL> ALTER DATABASE FORCE LOGGING;

Database altered.

SQL> SELECT force_logging FROM v$database;

FOR
---
YES

Oracle Database 11g: Data Guard Administration A - 6


Practice 2-1: Preparing the Primary Database (continued)

2) Configure the standby redo logs on the primary database. You can use the
cr_sby_redologs.sql script.

SQL> @cr_sby_redologs
SQL> ALTER DATABASE ADD STANDBY LOGFILE
2 '/u01/app/oracle/oradata/pc00prmy/srl01.log' size
52428800
3 /

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE


2 '/u01/app/oracle/oradata/pc00prmy/srl02.log' size
52428800
3 /

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE


2 '/u01/app/oracle/oradata/pc00prmy/srl03.log' size
52428800
3 /

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE


2 '/u01/app/oracle/oradata/pc00prmy/srl04.log' size
52428800
3 /

Database altered.

3) Set the LOG_ARCHIVE_CONFIG and LOG_ARCHIVE_DEST_1 initialization


parameters on the primary database. You must specify the name of your primary
database and your standby database; do not use the names shown in the examples.
Note: Be sure to leave a blank space before each of the attributes of
LOG_ARCHIVE_DEST_1.
SQL> alter system set log_archive_config =
'dg_config=(pc00prmy,pc00sby1)';

System altered.

SQL> show parameter log_archive_config

NAME TYPE VALUE


-------------------- --------- -----------------------------
log_archive_config string dg_config=(pc00prmy,pc00sby1)

Oracle Database 11g: Data Guard Administration A - 7


Practice 2-1: Preparing the Primary Database (continued)

SQL> alter system


2 set log_archive_dest_1 =
3 'service=pc00sby1 async
4 valid_for=(online_logfile,primary_role)
5 db_unique_name=pc00sby1';

System altered.
SQL> show parameter log_archive_dest_1

NAME TYPE VALUE


-------------------- ------- -----------------------------
log_archive_dest_1 string service=pc00sby1 async
valid_for=(online_logfile,
primary_role)
db_unique_name=pc00sby1
Note: Output formatted for legibility
4) Configure the ARCHIVELOG mode and enable automatic archiving.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 41
Current log sequence 43

SQL> SHUTDOWN IMMEDIATE


Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP MOUNT
ORACLE instance started.

Total System Global Area 627732480 bytes


Fixed Size 1301728 bytes
Variable Size 448791328 bytes
Database Buffers 171966464 bytes
Redo Buffers 5672960 bytes
Database mounted.

SQL> ALTER DATABASE ARCHIVELOG;

Database altered.

SQL> ALTER DATABASE OPEN;

Database altered.
5) Increase the size of the flash recovery area to 5 GB. Exit SQL*Plus.
SQL> alter system set db_recovery_file_dest_size = 5G;

Oracle Database 11g: Data Guard Administration A - 8


Practice 2-1: Preparing the Primary Database (continued)
System altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
[oracle@edt3r17p0-pc00prmy labs]$
6) Invoke RMAN and log in to your primary database.
[oracle@edt3r17p0-pc00prmy labs]$ rman

Recovery Manager: Release 11.1.0.6.0 - Production on Tue Nov


27 02:25:22 2007

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

RMAN> connect target /

connected to target database: PC00PRMY (DBID=1159023676)


7) Make a whole database backup, including archived redo log files. Exit RMAN.
RMAN> backup database plus archivelog;

Starting backup at 27-NOV-07


current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=116 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=27 RECID=1
STAMP=639713780
input archived log thread=1 sequence=28 RECID=2
STAMP=639714352
channel ORA_DISK_1: starting piece 1 at 27-NOV-07
channel ORA_DISK_1: finished piece 1 at 27-NOV-07
piece
handle=/u01/app/oracle/flash_recovery_area/PC00PRMY/backupset/
2007_11_27/o1_mf_annnn_TAG20071127T022553_3np7g7l5_.bkp
tag=TAG20071127T022553 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
Finished backup at 27-NOV-07
Starting backup at 27-NOV-07
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set

Oracle Database 11g: Data Guard Administration A - 9


Practice 2-1: Preparing the Primary Database (continued)
input datafile file number=00001
name=/u01/app/oracle/oradata/pc00prmy/system01.dbf
input datafile file number=00002
name=/u01/app/oracle/oradata/pc00prmy/sysaux01.dbf
input datafile file number=00003
name=/u01/app/oracle/oradata/pc00prmy/undotbs01.dbf
input datafile file number=00005
name=/u01/app/oracle/oradata/pc00prmy/example01.dbf
input datafile file number=00004
name=/u01/app/oracle/oradata/pc00prmy/users01.dbf
channel ORA_DISK_1: starting piece 1 at 27-NOV-07
channel ORA_DISK_1: finished piece 1 at 27-NOV-07
piece
handle=/u01/app/oracle/flash_recovery_area/PC00PRMY/backupset/
2007_11_27/o1_mf_nnndf_TAG20071127T022600_3np7ghlp_.bkp
tag=TAG20071127T022600 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:01:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 27-NOV-07
channel ORA_DISK_1: finished piece 1 at 27-NOV-07
piece
handle=/u01/app/oracle/flash_recovery_area/PC00PRMY/backupset/
2007_11_27/o1_mf_ncsnf_TAG20071127T022600_3np7kd6s_.bkp
tag=TAG20071127T022600 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
Finished backup at 27-NOV-07

Starting backup at 27-NOV-07


current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=29 RECID=3
STAMP=639714461
channel ORA_DISK_1: starting piece 1 at 27-NOV-07
channel ORA_DISK_1: finished piece 1 at 27-NOV-07
piece
handle=/u01/app/oracle/flash_recovery_area/PC00PRMY/backupset/
2007_11_27/o1_mf_annnn_TAG20071127T022741_3np7kmgx_.bkp
tag=TAG20071127T022741 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
Finished backup at 27-NOV-07

RMAN> exit

Oracle Database 11g: Data Guard Administration A - 10


Practice 2-1: Preparing the Primary Database (continued)
Recovery Manager complete.
[oracle@edt3r17p0-pc00prmy labs]$

Oracle Database 11g: Data Guard Administration A - 11


Practice 2-2: Creating the Physical Standby Database
In this practice, you create a physical standby database.
Note: Be sure to verify the information you enter into fields in Oracle Net Manager
before proceeding to the next page.
1) On your primary database system, use Oracle Net Manager to create an Oracle Net
service name for your physical standby database.
a) Launch Net Manager.
[oracle@edt3r17p0-pc00prmy labs]$ netmgr

b) Expand Local. Select Service Naming and click the green plus sign in the left
navigation bar.

c) Enter pc<nn>sby1 in the Net Service Name field and click Next.
Note: For the value of nn, enter the number of the PC to which you are assigned.

d) Select TCP/IP (Internet Protocol) and click Next.

Oracle Database 11g: Data Guard Administration A - 12


Practice 2-2: Creating the Physical Standby Database
(continued)
e) Enter the fully qualified host name of the machine on which you are creating your
physical standby database and 12001 in the port number field. Click Next. Note:
edt3r17p2.us.oracle.com is used only as an example.

f) Enter pc<nn>sby1.us.oracle.com in the Service Name field and click


Next.

g) Click Finish.

Oracle Database 11g: Data Guard Administration A - 13


Practice 2-2: Creating the Physical Standby Database
(continued)
h) Select File > Save Network Configuration to save the information to the
tnsnames.ora file. Your tnsnames.ora file should have entries similar to
the following:
PC00PRMY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p0.us.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pc00prmy.us.oracle.com)
)
)

PC00SBY1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p2.us.oracle.com)(PORT = 12001))
)
(CONNECT_DATA =
(SERVICE_NAME = pc00sby1.us.oracle.com)
)
)
i) Exit Oracle Net Manager.
2) Open a terminal window and use telnet to connect to the machine on which your
physical standby database will be created. Log in as the oracle user with a
password of oracle.
[oracle@edt3r17p0-pc00prmy labs]$ xhost +
[oracle@edt3r17p0-pc00prmy labs]$ telnet <standby host>

3) Launch Oracle Net Manager to configure an entry for your standby database in the
listener.ora file.
a) Expand Local.
b) Expand Listeners.
c) Select LISTENER1.
d) Select Database Services in the list.
e) Click Add Database.
f) Enter pc<nn>sby1.us.oracle.com in the Global Database Name field.
Accept the default for the Oracle Home Directory. Enter pc<nn>sby1 in the
SID field.

Oracle Database 11g: Data Guard Administration A - 14


Practice 2-2: Creating the Physical Standby Database
(continued)

g) Select File > Save Network Configuration.


h) Select File > Exit.
4) On the same machine (the one on which you are creating your standby database),
invoke the listener control utility to start the LISTENER1 listener.

[oracle@edt3r17p2-pc02prmy ~]$ lsnrctl start listener1

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 19-OCT-


2007 14:32:25

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

Starting /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr:
please wait...

TNSLSNR for Linux: Version 11.1.0.6.0 - Production


System parameter file is
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Log messages written to
/u01/app/oracle/diag/tnslsnr/edt3r17p2/listener1/alert/log.xml

Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edt3r17p2.us.oracle.
com)(PORT=12001)))
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC12001)))
STATUS of the LISTENER
------------------------
Alias LISTENER1
Version TNSLSNR for Linux: Version
11.1.0.6.0 - Production
Start Date 19-OCT-2007 14:32:25
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF

Oracle Database 11g: Data Guard Administration A - 15


Practice 2-2: Creating the Physical Standby Database
(continued)
Listener Parameter File
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/edt3r17p2/listener1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC12001)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edt3r17p2.us.oracle.
com)(PORT=12001)))
Services Summary...
Service "pc00sby1.us.oracle.com" has 1 instance(s).
Instance "pc00sby1", status UNKNOWN, has 1 handler(s) for
this service...
The command completed successfully
[oracle@edt3r17p2-pc02prmy ~]$
5) Return to the terminal window for your primary database system. Change to the
$ORACLE_HOME/dbs directory and view the contents of the directory.
[oracle@edt3r17p0-pc00prmy ~]$ cd $ORACLE_HOME/dbs
[oracle@edt3r17p0-pc00prmy dbs]$ ls
hc_pc00db11.dat init.ora orapwpc00db11
spfilepc00db11.ora
hc_pc00prmy.dat lkPC00DB11 orapwpc00prmy
spfilepc00prmy.ora
initdw.ora lkPC00PRMY snapcf_pc00prmy.f
[oracle@edt3r17p0-pc00prmy dbs]$
6) FTP to the host where your standby database will be created. Specify a username of
oracle and a password of oracle to log on.
[oracle@edt3r17p0-pc00prmy dbs]$ ftp edt3r17p2
Connected to edt3r17p2.us.oracle.com.
220 edt3r17p2.us.oracle.com FTP server (Version wu-2.6.1-20)
ready.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (edt3r17p2:oracle): oracle
331 Password required for oracle.
Password:
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
7) FTP your primary database password file to the standby database system. Exit the
FTP session.
ftp> put orapwpc00prmy
local: orapwpc00prmy remote: orapwpc00prmy
227 Entering Passive Mode (10,150,21,130,31,89)

Oracle Database 11g: Data Guard Administration A - 16


Practice 2-2: Creating the Physical Standby Database
(continued)
150 Opening BINARY mode data connection for orapwpc00prmy.
226 Transfer complete.
2048 bytes sent in 6e-05 seconds (3.3e+04 Kbytes/s)
ftp> quit

8) Return to your standby database system window. Rename the password file you
copied from your primary database system so that it can be used for your physical
standby database. Also relocate it to the $ORACLE_HOME/dbs directory. Verify that
you have successfully moved it and named it correctly.
[oracle@edt3r17p2-pc02prmy ~]$ ls
agent_installmedia Desktop diary labs oradiag_oracle
orapwpc00prmy
[oracle@edt3r17p2-pc02prmy ~]$ mv orapwpc00prmy
$ORACLE_HOME/dbs/orapwpc00sby1
[oracle@edt3r17p2-pc02prmy ~]$ cd $ORACLE_HOME/dbs
[oracle@edt3r17p2-pc02prmy dbs]$ ls
hc_pc02db11.dat init.ora orapwpc00sby1 snapcf_pc02prmy.f
hc_pc02prmy.dat lkPC02DB11 orapwpc02db11 spfilepc02db11.ora
initdw.ora lkPC02PRMY orapwpc02prmy spfilepc02prmy.ora
9) On the standby database host, create an initialization parameter file named
initpc<nn>sby1.ora containing a single parameter: DB_NAME=pc<nn>sby1.
[oracle@edt3r17p2-pc02prmy dbs]$ vi initpc00sby1.ora
[oracle@edt3r17p2-pc02prmy dbs]$ more initpc00sby1.ora
DB_NAME=pc00sby1
[oracle@edt3r17p2-pc02prmy dbs]$

10) On the standby database host, change to the /u01/app/oracle/admin directory.


Create the pc<nn>sby1 directory.
[oracle@edt3r17p2-pc02prmy ~]$ cd /u01/app/oracle/admin
[oracle@edt3r17p2-pc02prmy admin]$ ls
pc02db11 pc02prmy
[oracle@edt3r17p2-pc02prmy admin]$ mkdir pc00sby1

11) Change to the pc<nn>sby1 directory and create the adump directory.
[oracle@edt3r17p2-pc02prmy admin]$ cd pc00sby1
[oracle@edt3r17p2-pc02prmy pc00sby1]$ mkdir adump

12) On the standby host, create the pc<nn>sby1 directory in


$ORACLE_BASE/oradata for the data files.
[oracle@edt3r17p2-pc02prmy pc00sby1]$ cd $ORACLE_BASE/oradata
[oracle@edt3r17p2-pc02prmy oradata]$ mkdir pc00sby1

13) On the standby host, set the ORACLE_SID environment variable to pc<nn>sby1
and start the instance in NOMOUNT mode with the text initialization parameter file.
Exit SQL*Plus.

Oracle Database 11g: Data Guard Administration A - 17


Practice 2-2: Creating the Physical Standby Database
(continued)
[oracle@edt3r17p2-pc02prmy oradata]$ export
ORACLE_SID=pc00sby1
[oracle@edt3r17p2-pc00sby1 oradata]$ echo $ORACLE_SID
pc00sby1
[oracle@edt3r17p2-pc00sby1 oradata]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Oct 31


03:30:31 2007

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

Connected to an idle instance.

SQL> startup nomount pfile=$ORACLE_HOME/dbs/initpc00sby1.ora


ORACLE instance started.

Total System Global Area 150667264 bytes


Fixed Size 1298472 bytes
Variable Size 92278744 bytes
Database Buffers 50331648 bytes
Redo Buffers 6758400 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
[oracle@edt3r17p2-pc00sby1 oradata]$ exit

14) On the primary database host, verify that the ORACLE_SID environment variable is
set to pc<nn>prmy.
[oracle@edt3r17p0-pc00prmy dbs]$ echo $ORACLE_SID
pc00prmy
[oracle@edt3r17p0-pc00prmy dbs]$

15) On the primary database host, change to the $HOME/labs directory. Verify that the
cr_phys_sby1.txt script contains the correct values for your primary and
standby databases.
16) Invoke RMAN and connect as SYSDBA to the target database. Connect to the
auxiliary database.
[oracle@edt3r17p0-pc00prmy labs]$ rman

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Oct


31 10:09:51 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.

RMAN> connect target sys/oracle

Oracle Database 11g: Data Guard Administration A - 18


Practice 2-2: Creating the Physical Standby Database
(continued)

connected to target database: PC00PRMY (DBID=3303427449)

RMAN> connect auxiliary sys/oracle@pc00sby1

connected to auxiliary database: PC00SBY1 (not mounted)

RMAN>
17) Execute the cr_phys_sby1.txt script.
RMAN> @cr_phys_sby1.txt

RMAN> run {
2> allocate channel prmy1 type disk;
3> allocate channel prmy2 type disk;
4> allocate channel prmy3 type disk;
5> allocate channel prmy4 type disk;
6> allocate auxiliary channel stby type disk;
7> duplicate target database for standby from active
database
8> spfile
9> parameter_value_convert 'pc00prmy','pc00sby1'
10> set db_unique_name='pc00sby1'
11> set db_file_name_convert='/pc00prmy/','/pc00sby1/'
12> set log_file_name_convert='/pc00prmy/','/pc00sby1/'
13> set
control_files='/u01/app/oracle/oradata/pc00sby1.ctl'
14> set log_archive_max_processes='5'
15> set fal_client='pc00sby1'
16> set fal_server='pc00prmy'
17> set standby_file_management='AUTO'
18> set
log_archive_config='dg_config=(pc00prmy,pc00sby1)'
19> set log_archive_dest_1='service=pc00prmy ASYNC
20> valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE)
db_unique_name=pc00prmy'
21> ;
22> }
using target database control file instead of recovery catalog
allocated channel: prmy1
channel prmy1: SID=123 device type=DISK

allocated channel: prmy2


channel prmy2: SID=126 device type=DISK

allocated channel: prmy3


channel prmy3: SID=113 device type=DISK

allocated channel: prmy4


channel prmy4: SID=116 device type=DISK

Oracle Database 11g: Data Guard Administration A - 19


Practice 2-2: Creating the Physical Standby Database
(continued)

allocated channel: stby


channel stby: SID=98 device type=DISK

Starting Duplicate Db at 31-OCT-07


contents of Memory Script:
{
backup as copy reuse
file
'/u01/app/oracle/product/11.1.0/db_1/dbs/orapwpc00prmy'
auxiliary format
'/u01/app/oracle/product/11.1.0/db_1/dbs/orapwpc00sby1'
file
'/u01/app/oracle/product/11.1.0/db_1/dbs/spfilepc00prmy.ora'
auxiliary format
'/u01/app/oracle/product/11.1.0/db_1/dbs/spfilepc00sby1.ora'
;
sql clone "alter system set spfile=
''/u01/app/oracle/product/11.1.0/db_1/dbs/spfilepc00sby1.ora''
";
}
executing Memory Script

Starting backup at 31-OCT-07


Finished backup at 31-OCT-07

sql statement: alter system set spfile=


''/u01/app/oracle/product/11.1.0/db_1/dbs/spfilepc00sby1.ora''
contents of Memory Script:
{
sql clone "alter system set audit_file_dest =
''/u01/app/oracle/admin/pc00sby1/adump'' comment=
'''' scope=spfile";
sql clone "alter system set dispatchers =
''(PROTOCOL=TCP) (SERVICE=pc00sby1XDB)'' comment=
'''' scope=spfile";
sql clone "alter system set db_unique_name =
''pc00sby1'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/pc00prmy/'', ''/pc00sby1/'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/pc00prmy/'', ''/pc00sby1/'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''/u01/app/oracle/oradata/pc00sby1.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_max_processes =
5 comment=

Oracle Database 11g: Data Guard Administration A - 20


Practice 2-2: Creating the Physical Standby Database
(continued)
'''' scope=spfile";
sql clone "alter system set fal_client =
''pc00sby1'' comment=
'''' scope=spfile";
sql clone "alter system set fal_server =
''pc00prmy'' comment=
'''' scope=spfile";
sql clone "alter system set standby_file_management =
''AUTO'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_config =
''dg_config=(pc00prmy,pc00sby1)'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_1 =
''service=pc00prmy ASYNC
valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE)
db_unique_name=pc00prmy'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount ;
}
executing Memory Script

sql statement: alter system set audit_file_dest =


''/u01/app/oracle/admin/pc00sby1/adump'' comment= ''''
scope=spfile

sql statement: alter system set dispatchers =


''(PROTOCOL=TCP) (SERVICE=pc00sby1XDB)'' comment= ''''
scope=spfile

sql statement: alter system set db_unique_name =


''pc00sby1'' comment= '''' scope=spfile

sql statement: alter system set db_file_name_convert =


''/pc00prmy/'', ''/pc00sby1/'' comment= '''' scope=spfile

sql statement: alter system set log_file_name_convert =


''/pc00prmy/'', ''/pc00sby1/'' comment= '''' scope=spfile

sql statement: alter system set control_files =


''/u01/app/oracle/oradata/pc00sby1.ctl'' comment= ''''
scope=spfile

sql statement: alter system set log_archive_max_processes =


5 comment= '''' scope=spfile
sql statement: alter system set fal_client = ''pc00sby1''
comment= '''' scope=spfile

Oracle Database 11g: Data Guard Administration A - 21


Practice 2-2: Creating the Physical Standby Database
(continued)
sql statement: alter system set fal_server = ''pc00prmy''
comment= '''' scope=spfile

sql statement: alter system set standby_file_management =


''AUTO'' comment= '''' scope=spfile

sql statement: alter system set log_archive_config =


''dg_config=(pc00prmy,pc00sby1)'' comment= '''' scope=spfile

sql statement: alter system set log_archive_dest_1 =


''service=pc00prmy ASYNC
valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE)
db_unique_name=pc00prmy'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)


Oracle instance started
Total System Global Area 627732480 bytes

Fixed Size 1301728 bytes


Variable Size 364905248 bytes
Database Buffers 255852544 bytes
Redo Buffers 5672960 bytes

contents of Memory Script:


{
backup as copy current controlfile for standby auxiliary
format '/u01/app/oracle/oradata/pc00sby1.ctl';
sql clone 'alter database mount standby database';
}
executing Memory Script

Starting backup at 31-OCT-07


channel prmy1: starting datafile copy
copying standby control file
output file
name=/u01/app/oracle/product/11.1.0/db_1/dbs/snapcf_pc00prmy.f
tag=TAG20071031T144257 RECID=5 STAMP=637465377
channel prmy1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 31-OCT-07

sql statement: alter database mount standby database

contents of Memory Script:


{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to

Oracle Database 11g: Data Guard Administration A - 22


Practice 2-2: Creating the Physical Standby Database
(continued)
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/users01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/example01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/system01.dbf"
datafile
2 auxiliary format
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/sysaux01.dbf"
datafile
3 auxiliary format
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/undotbs01.dbf"
datafile
4 auxiliary format
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/users01.dbf"
datafile
5 auxiliary format
"/u01/app/oracle/oradata/pc00sby1/pc00prmy/example01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to
/u01/app/oracle/oradata/pc00sby1/pc00prmy/temp01.dbf in
control file
executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 31-OCT-07


channel prmy1: starting datafile copy
input datafile file number=00001
name=/u01/app/oracle/oradata/pc00prmy/pc00prmy/system01.dbf
channel prmy2: starting datafile copy
input datafile file number=00002
name=/u01/app/oracle/oradata/pc00prmy/pc00prmy/sysaux01.dbf

Oracle Database 11g: Data Guard Administration A - 23


Practice 2-2: Creating the Physical Standby Database
(continued)
channel prmy3: starting datafile copy
input datafile file number=00003
name=/u01/app/oracle/oradata/pc00prmy/pc00prmy/undotbs01.dbf
channel prmy4: starting datafile copy
input datafile file number=00005
name=/u01/app/oracle/oradata/pc00prmy/pc00prmy/example01.dbf
output file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/example01.dbf
tag=TAG20071031T144312 RECID=0 STAMP=0
channel prmy4: datafile copy complete, elapsed time: 00:00:45
channel prmy4: starting datafile copy
input datafile file number=00004
name=/u01/app/oracle/oradata/pc00prmy/pc00prmy/users01.dbf
output file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/users01.dbf
tag=TAG20071031T144312 RECID=0 STAMP=0
channel prmy4: datafile copy complete, elapsed time: 00:00:03
output file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/undotbs01.dbf
tag=TAG20071031T144312 RECID=0 STAMP=0
channel prmy3: datafile copy complete, elapsed time: 00:01:15
output file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/sysaux01.dbf
tag=TAG20071031T144312 RECID=0 STAMP=0
channel prmy2: datafile copy complete, elapsed time: 00:03:13
output file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/system01.dbf
tag=TAG20071031T144312 RECID=0 STAMP=0
channel prmy1: datafile copy complete, elapsed time: 00:03:30
Finished backup at 31-OCT-07

sql statement: alter system archive log current

contents of Memory Script:


{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy


input datafile copy RECID=5 STAMP=637426012 file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=637426012 file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=637426012 file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/undotbs01.dbf
datafile 4 switched to datafile copy

Oracle Database 11g: Data Guard Administration A - 24


Practice 2-2: Creating the Physical Standby Database
(continued)
input datafile copy RECID=8 STAMP=637426012 file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=9 STAMP=637426012 file
name=/u01/app/oracle/oradata/pc00sby1/pc00prmy/example01.dbf
Finished Duplicate Db at 31-OCT-07
released channel: prmy1
released channel: prmy2
released channel: prmy3
released channel: prmy4

RMAN> **end-of-file**

RMAN>
18) Exit your RMAN session and log in to SQL*Plus on your primary database system.
RMAN> exit

Recovery Manager complete.


[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Oct 31


15:46:35 2007

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

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

SQL>
19) Perform a log switch on the primary database.
SQL> alter system switch logfile;

System altered.

SQL>
20) Open a terminal window for the system that your physical standby database is on. Set
the ORACLE_SID environment variable to pc<nn>sby1. Change to the labs
directory. Log in to SQL*Plus as the SYSDBA user. Start Redo Apply.
[oracle@edt3r17p2-pc02prmy oradata]$ export
ORACLE_SID=pc00sby1
[oracle@edt3r17p2-pc00sby1 oradata]$ echo $ORACLE_SID

Oracle Database 11g: Data Guard Administration A - 25


Practice 2-2: Creating the Physical Standby Database
(continued)
pc00sby1
[oracle@edt3r17p2-pc00sby1 oradata]$ cd $HOME/labs
[oracle@edt3r17p2-pc00sby1 labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Oct 31


15:52:54 2007

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
SQL> alter database recover managed standby database
2 using current logfile disconnect;

Database altered.

Oracle Database 11g: Data Guard Administration A - 26


Practice 2-3: Verifying That the Physical Standby Database Is
Performing Correctly
In this practice, you verify that the standby database is performing correctly.
1) On the standby database, identify the existing archived redo log files. Use the
query_archived_log.sql file.
SQL> @query_archived_log

SQL> SELECT sequence#, first_time, next_time


2 FROM v$archived_log
3 ORDER BY sequence#
4 /

SEQUENCE# FIRST_TIM NEXT_TIME


---------- --------- ---------
12 31-OCT-07 01-NOV-07
13 01-NOV-07 01-NOV-07
2) On the primary database, perform a few log switches.
SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.
3) On the standby database, verify that the new redo data was received and archived.
SQL> @query_archived_log
SQL> SELECT sequence#, first_time, next_time
2 FROM v$archived_log
3 ORDER BY sequence#
4 /

SEQUENCE# FIRST_TIM NEXT_TIME


---------- --------- ---------
12 31-OCT-07 01-NOV-07
13 01-NOV-07 01-NOV-07
14 01-NOV-07 01-NOV-07
15 01-NOV-07 01-NOV-07
16 01-NOV-07 01-NOV-07

Oracle Database 11g: Data Guard Administration A - 27


Practice 2-3: Verifying That the Physical Standby Database Is
Performing Correctly (continued)
4) On the standby database, verify that the new archived redo log files were applied.
You can use the query_applied_log.sql file.
SQL> @query_applied_log
SQL> SELECT sequence#, applied
2 FROM v$archived_log
3* ORDER BY sequence#;

SEQUENCE# APP
---------- ---
12 YES
13 YES
14 YES
15 YES
16 YES

Oracle Database 11g: Data Guard Administration A - 28


Practices for Lesson 3: Oracle Data Guard Broker:
Overview
There are no practices for Lesson 3, “Oracle Data Guard Broker: Overview.”

Oracle Database 11g: Data Guard Administration A - 29


Practices for Lesson 4: Creating a Data Guard Broker
Configuration
In the practices for Lesson 4, “Creating a Data Guard Broker Configuration,” you create a
broker configuration.

Oracle Database 11g: Data Guard Administration A - 30


Practice 4-1: Setting the DG_BROKER_START Initialization
Parameter
In this practice, you set the DG_BROKER_START initialization parameter to TRUE for
your primary database and physical standby database.
1) Invoke SQL*Plus on your primary database system. Connect to your primary
database as the SYSDBA user and check the value of DG_BROKER_START.
[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Oct 31


16:12:04 2007

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

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

SQL> show parameter dg_broker_start

NAME TYPE VALUE


------------------------------------ ----------- -------------
dg_broker_start boolean FALSE

2) Set the DG_BROKER_START parameter to TRUE.


SQL> alter system set dg_broker_start=true;

System altered.

SQL> show parameter dg_broker_start

NAME TYPE VALUE


------------------------------------ ----------- -------------
dg_broker_start boolean TRUE
3) Open a terminal window for the system that your standby database is on. Set the
ORACLE_SID environment variable to pc<nn>sby1. Invoke SQL*Plus on your
standby database system. Connect to your physical standby database as the SYSDBA
user and check the value of DG_BROKER_START.
[oracle@edt3r17p2-pc00sby1 labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Oct 31


16:13:54 2007

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

Oracle Database 11g: Data Guard Administration A - 31


Practice 4-1: Setting the DG_BROKER_START Initialization
Parameter (continued)

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
SQL> show parameter dg_broker_start

NAME TYPE VALUE


------------------------------------ ----------- -------------
dg_broker_start boolean FALSE
SQL>

4) Set the value of DG_BROKER_START to TRUE in your standby database.


SQL> alter system set dg_broker_start=true;

System altered.

SQL> show parameter dg_broker_start

NAME TYPE VALUE


------------------------------------ ----------- -------------
dg_broker_start boolean TRUE

Oracle Database 11g: Data Guard Administration A - 32


Practice 4-2: Creating a Listener Service for the Primary
Database
In this practice, you define a listener service for the primary database that includes the
db_unique_name_DGMGRL.db_domain values for the GLOBAL_DBNAME.
Note: Be sure to verify the information that you enter into fields in Oracle Net Manager
before proceeding to the next page.
1) Open a terminal window to the system that your primary database is on. Launch
Oracle Net Manager.
[oracle@edt3r17p0-pc00prmy labs]$ netmgr

2) Expand Local.
3) Expand Listeners.
4) Select LISTENER.
5) Select Database Services in the list.
6) Click Add Database.
7) Enter pc<nn>prmy_DGMGRL.us.oracle.com in the Global Database Name
field. Accept the default value for the Oracle Home Directory. Enter pc<nn>prmy
in the SID field.

8) Select File > Save Network Configuration.


9) Select File > Exit.
10) Shut down the LISTENER listener. Restart the LISTENER listener.
[oracle@edt3r17p0-pc00prmy labs]$ lsnrctl stop

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 20-NOV-


2007 01:52:55

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

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@edt3r17p0-pc00prmy labs]$ lsnrctl start

Oracle Database 11g: Data Guard Administration A - 33


Practice 4-2: Creating a Listener Service for the Primary
Database (continued)

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 20-NOV-


2007 02:03:38

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

Starting /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr:
please wait...

TNSLSNR for Linux: Version 11.1.0.6.0 - Production


System parameter file is
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Log messages written to
/u01/app/oracle/diag/tnslsnr/edt3r17p0/listener/alert/log.xml
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edt3r17p0.us.oracle.
com)(PORT=1521)))
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version
11.1.0.6.0 - Production
Start Date 20-NOV-2007 02:03:38
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/edt3r17p0/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edt3r17p0.us.oracle.
com)(PORT=1521)))
Services Summary...
Service "pc00prmy_DGMGRL.us.oracle.com" has 1 instance(s).
Instance "pc00prmy", status UNKNOWN, has 1 handler(s) for
this service...
The command completed successfully

Oracle Database 11g: Data Guard Administration A - 34


Practice 4-2: Creating a Listener Service for the Primary
Database (continued)
11) Ensure that your listener.ora file contains entries similar to the following:
[oracle@edt3r17p0-pc00prmy labs]$ more
$ORACLE_HOME/network/admin/listener.ora
# listener.ora Network Configuration File:
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = pc00prmy_DGMGRL.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/11.1.0/db_1)
(SID_NAME = pc00prmy)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p0.us.oracle.com)(PORT = 1521))
)
)

Oracle Database 11g: Data Guard Administration A - 35


Practice 4-3: Creating a Listener Service for the Standby
Database
In this practice, you define a listener service for the standby database that includes the
db_unique_name_DGMGRL.db_domain value for the GLOBAL_DBNAME.
Note: Be sure to verify the information you enter into fields in Oracle Net Manager
before proceeding to the next page.
1) Open a terminal window to the system that your standby database is on. Launch
Oracle Net Manager.
[oracle@edt3r17p2-pc00sby1 labs]$ netmgr

2) Expand Local.
3) Expand Listeners.
4) Select LISTENER1.
5) Select Database Services in the list.
6) Click Add Database.
7) Enter pc<nn>sby1_DGMGRL.us.oracle.com in the Global Database Name
field. Accept the default value for the Oracle Home Directory. Enter pc<nn>sby1
in the SID field.

8) Select File > Save Network Configuration.


9) Select File > Exit.
10) Shut down the LISTENER1 listener. Restart the LISTENER1 listener.
[oracle@edt3r17p2-pc00sby1 labs]$ lsnrctl stop listener1

Oracle Database 11g: Data Guard Administration A - 36


Practice 4-3: Creating a Listener Service for the Standby
Database (continued)
LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 31-OCT-
2007 16:27:32

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

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC12001)))
The command completed successfully
[oracle@edt3r17p2-pc00sby1 labs]$
[oracle@edt3r17p2-pc00sby1 labs]$ lsnrctl start listener1

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 31-OCT-


2007 16:33:49

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

Starting /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr:
please wait...

TNSLSNR for Linux: Version 11.1.0.6.0 - Production


System parameter file is
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Log messages written to
/u01/app/oracle/diag/tnslsnr/edt3r17p2/listener1/alert/log.xml

Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edt3r17p2.us.oracle.
com)(PORT=12001)))
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC12001)))
STATUS of the LISTENER
------------------------
Alias LISTENER1
Version TNSLSNR for Linux: Version
11.1.0.6.0 - Production
Start Date 31-OCT-2007 16:33:49
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
/u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/edt3r17p2/listener1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC12001)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=edt3r17p2.us.oracle.
com)(PORT=12001)))
Services Summary...

Oracle Database 11g: Data Guard Administration A - 37


Practice 4-3: Creating a Listener Service for the Standby
Database (continued)
Service "pc00sby1.us.oracle.com" has 1 instance(s).
Instance "pc00sby1", status UNKNOWN, has 1 handler(s) for
this service...
Service "pc00sby1_DGMGRL.us.oracle.com" has 1 instance(s).
Instance "pc00sby1", status UNKNOWN, has 1 handler(s) for
this service...
The command completed successfully
[oracle@edt3r17p2-pc00sby1 labs]$

11) Ensure that your listener.ora file (in $ORACLE_HOME/network/admin)


contains entries similar to the following:
[oracle@edt3r17p2-pc00sby1 admin]$ more listener.ora
LISTENER1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt317p2.us.oracle.com)(PORT = 12001))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = pc02prmy_DGMGRL.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/11.1.0/db_1)
(SID_NAME = pc02prmy)
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = pc00sby1.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/11.1.0/db_1)
(SID_NAME = pc00sby1)
)
(SID_DESC =
(GLOBAL_DBNAME = pc00sby1_DGMGRL.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/11.1.0/db_1)
(SID_NAME = pc00sby1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt317p2.us.oracle.com)(PORT = 1521))
)
)

Oracle Database 11g: Data Guard Administration A - 38


Practice 4-4: Creating an Oracle Net Service Name for the
Primary Database
In this practice, you define an Oracle Net service name for the primary database on the
system on which your physical standby database is created.
Note: Be sure to verify the information you enter into fields in Oracle Net Manager
before proceeding to the next page.
1) On the system on which your physical standby database is created, invoke Oracle Net
Manager.
2) Expand Local. Select Service Naming and click the green plus sign in the left
navigation pane.
3) Enter pc<nn>prmy in the Net Service Name field and click Next.

4) Select TCP/IP (Internet Protocol) and click Next.


5) Enter the fully qualified host name of the machine that your primary database is on
and click Next. The screenshot shows an example. Be sure to enter the host name that
you are using.

Oracle Database 11g: Data Guard Administration A - 39


Practice 4-4: Creating an Oracle Net Service Name for the
Primary Database (continued)

6) Enter pc<nn>prmy.us.oracle.com in the Service Name field and click Next.

7) Click Finish.
8) Select File > Save Network Configuration to save the information to the
tnsnames.ora file.
9) Exit Oracle Net Manager.

Oracle Database 11g: Data Guard Administration A - 40


Practice 4-4: Creating an Oracle Net Service Name for the
Primary Database (continued)
10) Ensure that your tnsnames.ora file has entries similar to the following:
PC02PRMY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p2.us.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pc02prmy.us.oracle.com)
)
)

PC00PRMY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p0.us.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = pc00prmy.us.oracle.com)
)
)

Oracle Database 11g: Data Guard Administration A - 41


Practice 4-5: Creating an Oracle Net Service Name for the
Standby Database
In this practice, you define an Oracle Net service name for the standby database on the
system on which the standby database is created.
Note: Be sure to verify the information you enter into fields in Oracle Net Manager
before proceeding to the next page.
1) On the system on which your physical standby database is created, invoke Oracle Net
Manager.
2) Expand Local. Select Service Naming and click the green plus sign.
3) Enter pc<nn>sby1 in the Net Service Name field and click Next.

4) Select TCP/IP (Internet Protocol) and click Next.


5) Enter the fully qualified host name of the machine that your physical standby
database is on. Change the port number to 12001. Click Next.

Oracle Database 11g: Data Guard Administration A - 42


Practice 4-5: Creating an Oracle Net Service Name for the
Standby Database (continued)

6) Enter pc<nn>sby1.us.oracle.com in the Service Name field and click Next.

7) Click Finish.
8) Select File > Save Network Configuration to save the information to the
tnsnames.ora file.
9) Exit Oracle Net Manager.

Oracle Database 11g: Data Guard Administration A - 43


Practice 4-5: Creating an Oracle Net Service Name for the
Standby Database (continued)
10) Ensure that your tnsnames.ora file has entries similar to the following:
PC00PRMY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p0.us.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = pc00prmy.us.oracle.com)
)
)

PC00SBY1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p2.us.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = pc00sby1.us.oracle.com)
)
)

11) Invoke SQL*Plus for your physical standby database and set the LOCAL_LISTENER
parameter to pc<nn>sby1. Be sure to set the ORACLE_SID environment variable
to pc<nn>sby1 before invoking SQL*Plus.
SQL> alter system set local_listener=pc00sby1;

System altered.

Oracle Database 11g: Data Guard Administration A - 44


Practice 4-6: Creating the Broker Configuration
In this practice, you create a Data Guard broker configuration.
1) On your primary database system, invoke DGMGRL and connect to your primary
database.
[oracle@edt3r17p0-pc00prmy labs]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
DGMGRL>

2) Create a broker configuration named DGConfig1 and include a profile for the
primary database.
DGMGRL> create configuration 'DGConfig1' as
> primary database is 'pc00prmy'
> connect identifier is pc00prmy;
Configuration "DGConfig1" created with primary database
"pc00prmy"
DGMGRL>
3) Display information about the configuration.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: NO
Protection Mode: MaxPerformance
Databases:
pc00prmy - Primary database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


DISABLED

DGMGRL>
4) Add your physical standby database to the broker configuration.
DGMGRL> add database 'pc00sby1' as
> connect identifier is pc00sby1;
Database "pc00sby1" added
DGMGRL>

Oracle Database 11g: Data Guard Administration A - 45


Practice 4-6: Creating the Broker Configuration (continued)
5) Verify that the pc<nn>sby1 database was added to the configuration.
DGMGRL> show configuration;

Configuration
Name: DGConfig1
Enabled: NO
Protection Mode: MaxPerformance
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


DISABLED

DGMGRL>

Oracle Database 11g: Data Guard Administration A - 46


Practice 4-7: Enabling the Broker Configuration
In this practice, you enable the broker configuration.
1) Enable the entire configuration.
DGMGRL> enable configuration;
Enabled.
2) Verify that the configuration was successfully enabled. If you receive a warning
message (WARNING: ORA-16610 Set Property in Progress) or
(WARNING: ORA-16610 Command "Broken automatic health
check" in Progress), wait a few minutes and issue the SHOW
CONFIGURATION command again.

DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxPerformance
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

DGMGRL>

Note: If you receive one of the following messages Warning: ORA-16607: one
or more databases have failed or Warning: ORA-16792:
configurable property value is inconsistent with database
setting, you may need to restart one or both of your database instances. Discuss your
situation with your course instructor.

Oracle Database 11g: Data Guard Administration A - 47


Practices for Lesson 5: Creating a Physical Standby
Database by Using Enterprise Manager Grid Control
In the practices for Lesson 5, “Creating a Physical Standby Database by Using Enterprise
Manager Grid Control,” you use Enterprise Manager Grid Control to create a physical
standby database.

Oracle Database 11g: Data Guard Administration A - 48


Practice 5-1: Installing the Oracle Management Agent
In this practice, you install the Oracle Management Agent so that you can use Enterprise
Manager Grid Control.

Your instructor will provide the name of the machine that Enterprise Manager Grid
Control is installed on. Record the name of the machine here and in step 7:
______________________________________________________________________
1) On your primary database host machine, open a terminal window and log on as the
oracle user with a password of oracle.
2) Oracle Enterprise Manager Grid Control software is staged in the
$HOME/agent_installmedia directory. Change to the
agent_installmedia/Disk1/linux/agent directory.
[oracle@edt3r17p0-pc00prmy ~]$ cd
agent_installmedia/Disk1/linux/agent
3) Invoke the Oracle Universal Installer.
[oracle@edt3r17p2-pc00prmy agent]$ ./runInstaller
Starting Oracle Universal Installer...

Checking installer requirements...

Checking operating system version: must be redhat-3, redhat-4


or SuSE-9
Passed

All installer requirements met.

Preparing to launch Oracle Universal Installer from


/tmp/OraInstall2008-01-22_11-26-41AM. Please wait ...

Oracle Database 11g: Data Guard Administration A - 49


Practice 5-1: Installing the Oracle Management Agent
(continued)

4) On the Specify Installation Type page, select Additional Management Agent and
click Next.

Oracle Database 11g: Data Guard Administration A - 50


Practice 5-1: Installing the Oracle Management Agent
(continued)

5) Accept the default location for the parent directory and click Next.

Oracle Database 11g: Data Guard Administration A - 51


Practice 5-1: Installing the Oracle Management Agent
(continued)

6) The Product-Specific Prerequisite Checks page is displayed. Click Next to continue.

Oracle Database 11g: Data Guard Administration A - 52


Practice 5-1: Installing the Oracle Management Agent
(continued)

7) Enterprise Manager Grid Control host machine: ____________________________


On the Specify Oracle Management Service Location page, provide the name of the
host machine as provided by your instructor. Click Next.

Oracle Database 11g: Data Guard Administration A - 53


Practice 5-1: Installing the Oracle Management Agent
(continued)

8) On the Specify Agent Registration Password page, enter oracle1 in the Password
field. Click Next. Be sure you have entered the password of oracle1 before
clicking Next.

Oracle Database 11g: Data Guard Administration A - 54


Practice 5-1: Installing the Oracle Management Agent
(continued)

9) On the Oracle Configuration Manager Registration page, click Next.

Oracle Database 11g: Data Guard Administration A - 55


Practice 5-1: Installing the Oracle Management Agent
(continued)

10) Click Install on the Summary page.

Oracle Database 11g: Data Guard Administration A - 56


Practice 5-1: Installing the Oracle Management Agent
(continued)

11) Note that the Install page shows the progress of the installation.

Oracle Database 11g: Data Guard Administration A - 57


Practice 5-1: Installing the Oracle Management Agent
(continued)

12) The “Execute Configuration scripts” dialog box appears. Open a terminal window
and switch to the root user. In the Oracle University classroom, the password of the
root user is oracle.

13) Execute the script as instructed in the dialog box. Accept the default values when
prompted.
[oracle@edt3r17p0-pc00prmy ~]$ su -
Password:
[root@edt3r17p0 ~]# cd /u01/app/oracle/OracleHomes/agent10g
[root@edt3r17p0 agent10g]# ./root.sh
Running Oracle10 root.sh script...

The following environment variables are set as:


ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/OracleHomes/agent10g

Enter the full pathname of the local bin directory:


[/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite
it? (y/n)
[n]:
The file "oraenv" already exists in /usr/local/bin. Overwrite
it? (y/n)
[n]:

Oracle Database 11g: Data Guard Administration A - 58


Practice 5-1: Installing the Oracle Management Agent
(continued)
The file "coraenv" already exists in /usr/local/bin.
Overwrite it? (y/n)
[n]:

Entries will be added to the /etc/oratab file as needed by


Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
[root@edt3r17p0 agent10g]#
14) After the script is completed, return to the Execute Configuration scripts dialog box
and click OK. The Configuration Assistants page appears.

15) The End of Installation page appears. Click Exit to exit the Oracle Universal Installer.
Click Yes to confirm.

Oracle Database 11g: Data Guard Administration A - 59


Practice 5-1: Installing the Oracle Management Agent
(continued)

Oracle Database 11g: Data Guard Administration A - 60


Practice 5-2: Configuring Monitoring Credentials for Your
Primary Database
In this practice, you configure monitoring credentials for your primary database.
1) Open your browser and invoke Enterprise Manager by entering the following URL:
http://<oms_host>:4889/em
2) Log in to Enterprise Manager Grid Control with a username of sysman and
password of oracle1.
3) The Grid Control home page appears. Click the Targets tab.
4) The Hosts page appears. Ensure that your primary database host appears in the list.
Click Databases.
5) The Databases page appears. Select your primary database from the list of databases
(by clicking the option button) and click Configure.
6) Select SYSDBA in the Role list. Enter sys in the Monitor Username field. Enter
oracle in the Monitor Password field. Click Test Connection.
7) After you receive a message that the connection test was successful, click Next.
8) The Configure Database Instance: Review page appears. Click Submit on this page.
9) A page displays the message “Target saving is in progress.”
10) You receive a message that the properties were updated. Click OK.
11) The Databases page is updated with the status for your configured database. Ensure
that the status for your database is “Up” before proceeding to the next practice.

Oracle Database 11g: Data Guard Administration A - 61


Practice 5-3: Configuring Monitoring Credentials for Your
Standby Database
In this practice, you configure credentials for monitoring your standby database.

Note: Before beginning this practice, you must confirm that the Oracle Management
Agent is successfully installed on your standby database host.
1) On the Databases page, select your standby database (by clicking the option button)
and click Configure.
2) Select SYSDBA in the Role list. Enter sys in the Monitor Username field and
oracle in the Monitor Password field. Enter 12001 in the Port field
3) Click Test Connection. You should receive a message indicating that the connection
test was successful. Click Next.
4) On the Configure Database Instance: Review page, click Submit. A page displays the
message “Target saving is in progress.”
5) The Database Instance Configuration Result page appears. Click OK.
6) You are returned to the Databases page. Ensure that the status for your database is
“Up” before proceeding to the next practice.”

Oracle Database 11g: Data Guard Administration A - 62


Practice 5-4: Adding a Physical Standby Database to Your
Configuration
In this practice, you add a new physical standby database to your configuration by using
Enterprise Manager Grid Control.
1) Select your primary database by clicking the link on the Databases page.
2) Click Maintenance. Select Setup and Manage in the Data Guard section of the
Maintenance page.
3) Enter database login credentials (SYS as SYSDBA) if requested.
4) Click Add Standby Database.

5) On the Add Standby Database page, select Create a new physical standby database
and click Continue.

Oracle Database 11g: Data Guard Administration A - 63


Practice 5-4: Adding a Physical Standby Database to Your
Configuration (continued)

6) On the Add Standby Database: Backup Type page, select Perform a live backup of
the primary database and click Next.

7) On the Add Standby Database: Backup Options page, accept the default location for
the backup files directory. Accept the default option to delete the files after the
standby database creation. Enter the host credentials (Username: oracle and
Password: oracle) and select Save as Preferred Credential. Click Next.

Oracle Database 11g: Data Guard Administration A - 64


Practice 5-4: Adding a Physical Standby Database to Your
Configuration (continued)

8) On the Add Standby Database: Database Location page, enter pc<nn>sby2 in the
Instance Name field. Select the same host that you used for your other physical
standby database. Click Next.

Oracle Database 11g: Data Guard Administration A - 65


Practice 5-4: Adding a Physical Standby Database to Your
Configuration (continued)

9) On the Add Standby Database: File Locations page, accept the default to transfer
files. Scroll down the page.

10) In the Standby Database File Locations section, select Keep file names and
locations the same as the primary database and click Customize.

Oracle Database 11g: Data Guard Administration A - 66


Practice 5-4: Adding a Physical Standby Database to Your
Configuration (continued)

11) On the File Locations: Customize Tablespace Storage page, change the directory
location to pc<nn>sby2 for all file locations, in all sections (Datafiles, Tempfiles,
Log Files, Control Files, and Directory Objects) as necessary. Click OK.

12) On the Warning page, click Yes.

13) You are returned to the Add Standby Database: File Locations page. Click Next.
14) On the Add Standby Database Configuration page, enter pc<nn>sby2 in the
Database Unique Name and Target Name fields. Accept the default for the Standby
Archive Location. Click Next.

Oracle Database 11g: Data Guard Administration A - 67


Practice 5-4: Adding a Physical Standby Database to Your
Configuration (continued)

Oracle Database 11g: Data Guard Administration A - 68


Practice 5-4: Adding a Physical Standby Database to Your
Configuration (continued)

15) On the Add Standby Database Review page, review the information about the
standby database to be created. If you are satisfied with the configuration information,
click Finish or click Back to make changes. The Processing: Add Standby Database
page appears.

Note: If Enterprise Manager remains on this page for more than 10 minutes, click the
Jobs tab to verify that the job is started.

Oracle Database 11g: Data Guard Administration A - 69


Practice 5-4: Adding a Physical Standby Database to Your
Configuration (continued)

16) You are returned to the Data Guard Overview page. Select Real Time: 1 Minute
Refresh in the View Data list to easily view the progress of standby database
creation. You can also click the Creation in progress link to monitor standby
database creation.

Oracle Database 11g: Data Guard Administration A - 70


Practice 5-4: Adding a Physical Standby Database to Your
Configuration (continued)

17) After the standby database creation is completed, not that the new physical standby
database is listed in the Standby Databases section.

Oracle Database 11g: Data Guard Administration A - 71


Practice 5-5: Verifying the Broker Configuration
In this practice, you use Enterprise Manager Grid Control to verify your configuration.
1) In the Additional Administration section of the Data Guard Overview page, click
Verify Configuration. The Processing: Verify page is displayed. The Processing:
Verify Completed page displays the results of the verify operation.

Oracle Database 11g: Data Guard Administration A - 72


Practice 5-5: Verifying the Broker Configuration (continued)

2) Click OK to return to the Data Guard Overview page.


3) As indicated in the Detailed Results pane, you must execute the Verify a second time.
Click Verify Configuration.
4) Click OK to create the recommended standby redo logs. After the standby redo logs
are created, you are returned to the Data Guard Overview page.

Oracle Database 11g: Data Guard Administration A - 73


Practice 5-5: Verifying the Broker Configuration (continued)

Oracle Database 11g: Data Guard Administration A - 74


Practice 5-6: Deleting the Database
In this practice, you delete the pc<nn>sby2 database in preparation for later practices.

1) Select your pc<nn>sby2 database (by clicking the option button) on the Data
Guard Overview page and click Remove to remove your pc<nn>sby2 database
from Data Guard broker control.

2) On the Confirmation page, click Yes. You receive a confirmation message that the
database has been removed from the Data Guard configuration.

3) Click the Databases tab to return to the Databases page.


4) Click the link for your pc<nn>sby2 database.
5) The database home page is displayed. Click the Shutdown button to shut down your
pc<nn>sby2 database instance.
6) Enter the host credentials and the database credentials. Click OK.

Oracle Database 11g: Data Guard Administration A - 75


Practice 5-6: Deleting the Database (continued)
7) On the Startup/Shutdown: Specify Operation page, select Shutdown the database
and click Continue.

8) Click Yes to confirm the shutdown operation. The Startup/Shutdown: Activity


Information page is displayed.
9) When the shutdown operation is complete, you are returned to the database home
page. You receive a message that your database has been shut down. Click the
Databases tab to return to the Databases page.
10) Select your pc<nn>sby2 database on the Databases page and click Remove to
remove it from Enterprise Manager Grid Control.
11) Click Yes to confirm. You receive a confirmation message.

Oracle Database 11g: Data Guard Administration A - 76


Practices for Lesson 6: Creating a Logical Standby
Database

In the practices for Lesson 6, “Creating a Logical Standby Database,” you use Enterprise
Manager Grid Control to create a logical standby database.

Oracle Database 11g: Data Guard Administration A - 77


Practice 6-1: Creating a Logical Standby Database
In this practice, you create a logical standby database and add it to your configuration.
1) Select your primary database on the Databases pages.
2) Select Setup and Manage in the Data Guard section of the Maintenance page.
3) Click Add Standby Database.
4) On the Add Standby Database page, select Create a new logical standby database
and click Continue.

5) In the Add Standby Database: Backup Type section, accept the default of “Perform a
live backup of the primary database.” In the SQL Apply Unsupported Tables section,
select Table Columns and Data Types in the list and click Go to see the
unsupported tables.
6) For this practice, you can accept the unsupported columns. Click Next.

Oracle Database 11g: Data Guard Administration A - 78


Practice 6-1: Creating a Logical Standby Database (continued)

7) On the Add Standby Database: Backup Options page, accept the default location for
the backup files directory. Accept the default option to delete the files after standby
database creation. Enter the host credentials and select Save as Preferred
Credential. Click Next.
8) On the Add Standby Database: Database Location page, enter pc<nn>sby3 in the
Instance Name field. Select the same host that you used for your physical standby
databases. Click Next.
9) On the Add Standby Database: File Locations page, accept the default to transfer
files.
10) In the Standby Database File Locations section, select Keep file names and
locations the same as the primary database and click Customize.
11) On the File Locations: Customize Tablespace Storage page, change the directory
location to pc<nn>sby3 for all file locations on the page as necessary. Click OK.
12) On the Warning page, click Yes.
13) You are returned to the Add Standby Database: File Locations page. Click Next.
14) On the Add Standby Database Configuration page, enter pc<nn>sby3 in the
Database Name, Database Unique Name, and Target Name fields. Accept the default
for the Standby Archive Location. Click Next.

Oracle Database 11g: Data Guard Administration A - 79


Practice 6-1: Creating a Logical Standby Database (continued)

15) On the Add Standby Database Review page, review the information about the logical
standby database to be created. If you are satisfied with the configuration information,
click Finish. Otherwise, click Back to make changes. The Processing: Add Standby
Database page appears.

16) You are returned to the Data Guard Overview page. Select Real Time: 1 Minute
Refresh in the View Data list to easily view the progress of the logical standby
database creation.

Oracle Database 11g: Data Guard Administration A - 80


Practice 6-1: Creating a Logical Standby Database (continued)
17) After the standby database creation is completed, the new logical standby database is
listed in the Standby Databases section. Proceed to the next step when the status for
your logical standby database is Normal.

18) Verify your configuration by clicking Verify Configuration.


19) Click OK to return to the Data Guard page.

Oracle Database 11g: Data Guard Administration A - 81


Practice 6-2: Implementing SQL Apply Filtering
Practice 6-2: Implementing SQL Apply Filtering
In this practice, you test SQL Apply filtering. Because the users want to use some tables
in the logical standby database to report against for historical purposes, you need to
configure SQL Apply so that certain DML statements are not executed against those
tables on the logical standby database. You decide to test this feature by creating a new
table on the primary database.
1) Open a terminal window for your primary database and change to the labs
directory.
[oracle@edt3r17p0-pc00prmy agent]$ cd $HOME/labs
[oracle@edt3r17p0-pc00prmy labs]$

2) Invoke SQL*Plus and connect as the SYSDBA user.


[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Tue Feb 12


03:53:43 2008

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

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

SQL>

3) Unlock the HR user account and set the password to hr. (lowercase)
SQL> ALTER USER hr IDENTIFIED BY hr ACCOUNT UNLOCK;

User altered.
4) Connect as the HR user with a password of hr.
SQL> connect hr/hr
Connected.

5) Execute the cr_emp_name.sql script to create a table named HR.EMP_NAME.


You use this table to test the SQL Apply filtering feature. Exit SQL*Plus.
SQL> set echo on
SQL> @cr_emp_name
SQL> CREATE TABLE hr.emp_name
2 AS SELECT first_name, last_name
3 FROM hr.employees
4 WHERE 1=2
5 /

Oracle Database 11g: Data Guard Administration A - 82


Practice 6-2: Implementing SQL Apply Filtering

Table created.
6) Return to Enterprise Manager Grid Control and navigate to the Data Guard page.
7) Select your logical standby database and click Edit.
8) Click Standby Role Properties.
9) Expand Show Advanced Properties.

10) Click Add in the Skip Table Entries section.

11) Enter information as shown in the following screen so that SQL Apply does not
execute DML statements for the HR.EMP_NAME table:

12) Click OK.

Oracle Database 11g: Data Guard Administration A - 83


Practice 6-2: Implementing SQL Apply Filtering
13) Verify the information in the Skip Table Entries section and click Apply. A success
message is displayed.

14) In your primary database session, log in to DGMGRL as the SYS user.
15) Verify the setting of the LsbyASkipCfgPr property. Exit DGMGRL.
DGMGRL> show database pc00sby3 LsbyAskipCfgPr;
LsbyASkipCfgPr = ''DML', 'HR', 'EMP_NAME', null'
16) In your primary database session, log in to SQL*Plus as the HR user again. Execute
the ins_emp_name.sql script to insert two rows in the HR.EMP_NAME table.
SQL> @ins_emp_name
SQL> INSERT INTO hr.emp_name
2 VALUES ('Don', 'Miller')
3 /

1 row created.

SQL> INSERT INTO hr.emp_name


2 VALUES ('Sally', 'Hebert')
3 /

1 row created.

SQL> COMMIT
2 /

Commit complete.

17) Connect to your primary database as the SYSDBA user.


SQL> connect / as sysdba
Connected.
18) Force a log switch on your primary database.
SQL> alter system switch logfile;

System altered.

19) Open a terminal window and telnet to the machine that your standby database is on.
Log in as the oracle user with a password of oracle.

Oracle Database 11g: Data Guard Administration A - 84


Practice 6-2: Implementing SQL Apply Filtering
20) Change to the labs directory. Set the ORACLE_SID environment variable to
pc<nn>sby3.
[oracle@edt3r17p2-pc00sby1 labs]$ export ORACLE_SID=pc00sby3

21) Invoke SQL*Plus on your logical standby database and log in as the HR user.
[oracle@edt3r17p2-pc00sby3 labs]$ sqlplus hr/hr

SQL*Plus: Release 11.1.0.6.0 - Production on Tue Feb 12


04:19:45 2008

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

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

22) Query the HR.EMP_NAME table to verify that no rows were inserted in the table.
SQL> SELECT count(*) FROM emp_name;

COUNT(*)
----------
0
23) Exit SQL*Plus on your standby database.

Oracle Database 11g: Data Guard Administration A - 85


Practices for Lesson 7: Configuring Data
Protection Modes
In the practices for Lesson 7, “Configuring Data Protection Modes,” you configure
protection modes based on specific business requirements.

Oracle Database 11g: Data Guard Administration A - 86


Practice 7-1: Setting the Data Protection Mode by Using
DGMGRL
In this practice, you set the data protection mode as appropriate to the business
requirements.
Maximum performance is the default protection mode and provides the highest level of
data protection that is possible without affecting the performance of the primary database.
This is accomplished by allowing a transaction to commit as soon as the redo data needed
to recover that transaction is written to the local online redo log.
You have determined that you need to change the data protection mode to ensure that the
redo data needed to recover each transaction is written to both the local online redo log
and the standby redo log on at least one standby database before the transaction commits.
You also want to configure the protection mode so that the primary database does not
shut down if a fault prevents it from writing its redo stream to a remote standby redo log.
Change the protection mode to maximum availability so that your configuration meets
these requirements.
1) Invoke DGMGRL on your primary database host and connect to your primary
database.
[oracle@edt3r17p0-pc00prmy admin]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.

2) Use the SHOW CONFIGURATION command to check the current protection mode for
your configuration.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxPerformance
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
pc00sby3 – Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 87


Practice 7-1: Setting the Data Protection Mode by Using
DGMGRL (continued)
3) Use the SHOW DATABASE command to view the current setting for the
LogXptMode database property for your physical standby database.
DGMGRL> show database pc00sby1 LogXptMode;
LogXptMode = 'ASYNC'
4) Open another terminal window on your primary database host. Invoke SQL*Plus and
log in as the SYS user. Use the SHOW PARAMETER command to view the value of
LOG_ARCHIVE_DEST_1.
SQL> show parameter log_archive_dest_1

NAME TYPE VALUE


--------------------- ------- ----------------------------
log_archive_dest_1 string service="pc00sby1",LGWR ASYNC
NOAFFIRM delay=0 OPTIONAL
compression=DISABLE
max_failure=0 max_connections=1
reopen=300
db_unique_name="pc00sby1"
net_timeout=30
valid_for=
(online_logfile,primary_role)
log_archive_dest_10 string location=
"USE_DB_RECOVERY_FILE_DEST",
valid_for=
(ALL_LOGFILES,ALL_ROLES)

5) Return to your DGMGRL window and set the LogXptMode database property to
SYNC for your pc<nn>sby1 database.
DGMGRL> edit database 'pc00sby1' set property
'LogXptMode'='SYNC';
Property "LogXptMode" updated
DGMGRL>

6) In your DGMGRL window, change the protection mode to MAXAVAILABILITY.


DGMGRL> edit configuration set protection mode as
maxavailability;
Succeeded.
DGMGRL>

7) Use the SHOW CONFIGURATION command to verify your change to the protection
mode.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability

Oracle Database 11g: Data Guard Administration A - 88


Practice 7-1: Setting the Data Protection Mode by Using
DGMGRL (continued)
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
pc00sby3 – Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS
8) Return to your SQL*Plus window and check the value of LOG_ARCHIVE_DEST_1
again. Note the changes made by the Data Guard broker.
SQL> show parameter log_archive_dest_1

NAME TYPE VALUE


--------------------- ------- ----------------------------
log_archive_dest_1 string service="pc00sby1",LGWR SYNC
AFFIRM delay=0 OPTIONAL
compression=DISABLE
max_failure=0 max_connections=1
reopen=300
db_unique_name="pc00sby1"
net_timeout=30 valid_for=
(online_logfile,primary_role)
log_archive_dest_10 string location=
"USE_DB_RECOVERY_FILE_DEST",
valid_for=
(ALL_LOGFILES,ALL_ROLES)
9) Return to your DGMGRL window. In preparation for the next practice, set the
protection mode back to MAXPERFORMANCE.
DGMGRL> edit configuration set protection mode as
maxperformance;
Succeeded.
10) Set the LogXptMode back to ASYNC.
DGMGRL> edit database pc00sby1 set property
'LogXptMode'='ASYNC';
Property "LogXptMode" updated
11) Use the SHOW CONFIGURATION command to verify your change to the protection
mode.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxPerformance
Databases:

Oracle Database 11g: Data Guard Administration A - 89


Practice 7-1: Setting the Data Protection Mode by Using
DGMGRL (continued)
pc00prmy - Primary database
pc00sby1 - Physical standby database
pc00sby3 – Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 90


Practice 7-2: Setting the Data Protection Mode by Using
Enterprise Manager Grid Control
In this practice, you set the protection mode to maximum availability by using Enterprise
Manager Grid Control.
1) Invoke Enterprise Manager Grid Control and log on as the SYSMAN user.
2) Access the Databases page and select your primary database.
3) Click the Primary link in the High Availability section of your database home page
to access the Data Guard Overview page.
4) On the Data Guard Overview page, select your physical standby database and click
Edit.

Oracle Database 11g: Data Guard Administration A - 91


Practice 7-2: Setting the Data Protection Mode by Using
Enterprise Manager Grid Control (continued)

5) Click the Standby Role Properties tab. Expand Show Advanced Properties. Note
the Log Transport Mode setting: __________________________

6) Click the Data Guard link to return to the Data Guard Overview page.

Oracle Database 11g: Data Guard Administration A - 92


Practice 7-2: Setting the Data Protection Mode by Using
Enterprise Manager Grid Control (continued)

7) On the Data Guard Overview page, click the Protection Mode link.

8) On the Change Protection Mode: Select Mode page, select Maximum Availability
and click Continue.

9) On the Change Protection Mode: Standby Databases and Standby Redo Log Files
page, review the information and click Continue.

Oracle Database 11g: Data Guard Administration A - 93


Practice 7-2: Setting the Data Protection Mode by Using
Enterprise Manager Grid Control (continued)

10) On the Confirmation: Change Protection Mode page, click Yes. The Processing:
Change Protection Mode page is displayed.

11) After the processing is completed, you are returned to the Data Guard Overview page
and receive a confirmation message. Select your physical standby database and click
Edit.
12) Click the Standby Role Properties tab. Expand Show Advanced Properties. Note
that the Log Transport Mode setting has changed.

Oracle Database 11g: Data Guard Administration A - 94


Practice 7-2: Setting the Data Protection Mode by Using
Enterprise Manager Grid Control (continued)

13) Click the Data Guard link to return to the Data Guard Overview page.

Oracle Database 11g: Data Guard Administration A - 95


Practices for Lesson 8: Monitoring a Data Guard
Broker Configuration
In the practices for Lesson 8, “Monitoring a Data Guard Broker Configuration,” you use
various techniques to monitor your Data Guard configuration. In later practices, you use
these techniques to resolve issues in your configuration.

Oracle Database 11g: Data Guard Administration A - 96


Practice 8-1: Viewing Log File Details

Practice 8-1: Viewing Log File Details


In this practice, you use Enterprise Manager Grid Control to view information about Log
Transport and Log Apply services.
1) On the Data Guard Overview page, click Log File Details in the Performance
section.

2) The Log File Details page is displayed. Note the state of Log Transport and Log
Apply services in your configuration.

3) Invoke DGMGRL on your primary database host and log in as sys with a password
of oracle.
[oracle@edt3r17p0-pc00prmy admin]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.

Oracle Database 11g: Data Guard Administration A - 97


Practice 8-1: Viewing Log File Details
4) Set the state of your physical standby database to APPLY-OFF.
DGMGRL> edit database 'pc00sby1'
> set state='APPLY-OFF';
Succeeded.
5) Exit DGMGRL.
6) Invoke SQL*Plus on your primary database host and log in as sys with a password
of oracle.
[oracle@edt3r17p0-pc00prmy admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Nov 14


22:11:41 2007

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
7) Perform a log switch.
SQL> alter system switch logfile;

System altered.
8) Exit SQL*Plus.
9) Return to Enterprise Manager Grid Control and refresh your page. Note the status for
Log Apply Services and the status of the log files. (Your results may vary slightly
from what is shown.)

Oracle Database 11g: Data Guard Administration A - 98


Practice 8-1: Viewing Log File Details

10) Invoke DGMGRL again on your primary database host and log in as sys with the
password of oracle.
11) Set the state of your physical standby database to APPLY-ON.
DGMGRL> edit database 'pc00sby1'
> set state='APPLY-ON';
Succeeded.
12) Exit DGMGRL.

Oracle Database 11g: Data Guard Administration A - 99


Practice 8-1: Viewing Log File Details

13) Return to Enterprise Manager Grid Control and refresh your page. Note the status of
Log Apply Services. All logs should have been received and applied.

Oracle Database 11g: Data Guard Administration A - 100


Practice 8-2: Using DGMGRL to Monitor the Configuration
In this practice, you use DGMGRL to monitor your configuration.
1) Invoke DGMGRL on your primary database host and connect as sys with the
password of oracle.
[oracle@edt3r17p0-pc00prmy admin]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.

2) Execute the SHOW CONFIGURATION command to check your configuration status.


DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
pc00sby3 – Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS
3) Open a terminal window for your standby database system host. Set the
ORACLE_SID environment variable to pc<nn>sby1. Log in to SQL*Plus as the
SYS user. Stop the Redo Apply process for the purpose of evaluating the impact on
your configuration.
[oracle@edt3r17p2-pc00sby1 labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 13


03:27:54 2008

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


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

SQL> alter database recover managed standby database cancel;

Oracle Database 11g: Data Guard Administration A - 101


Practice 8-2: Using DGMGRL to Monitor the Configuration
(continued)

Database altered.
4) Return to your primary database window and check your configuration status.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
pc00sby3 – Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


Warning: ORA-16607: one or more databases have failed

5) Execute the SHOW DATABASE command to further investigate the status of your
configuration by checking your primary database.
DGMGRL> show database pc00prmy

Database
Name: pc00prmy
OEM Name: pc00prmy.us.oracle.com
Role: PRIMARY
Enabled: YES
Intended State: TRANSPORT-ON
Instance(s):
pc00prmy

Current status for "pc00prmy":


SUCCESS
6) Check the status of your physical standby database.
DGMGRL> show database pc00sby1

Database
Name: pc00sby1
OEM Name: pc00sby1.us.oracle.com
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: APPLY-ON
Instance(s):
pc00sby1

Current status for "pc00sby1":

Oracle Database 11g: Data Guard Administration A - 102


Practice 8-2: Using DGMGRL to Monitor the Configuration
(continued)
Error: ORA-16766: Redo Apply is stopped
7) Now check the status of your Data Guard configuration by navigating to the Data
Guard Overview page.

8) Click the ORA-16766: Redo Apply is stopped link in the Data Guard Status column.
9) Click the Reset button to restart Redo Apply.

Oracle Database 11g: Data Guard Administration A - 103


Practice 8-2: Using DGMGRL to Monitor the Configuration
(continued)

10) You receive a message that the reset was successful. Click the Data Guard link to
return to the Data Guard Overview page. The Status for the physical standby database
now is Normal.

Oracle Database 11g: Data Guard Administration A - 104


Practice 8-2: Using DGMGRL to Monitor the Configuration
(continued)
11) Return to your DGMGRL session and execute the SHOW CONFIGURATION
command again.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
pc00sby3 – Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 105


Practices for Lesson 9: Optimizing a Data Guard
Configuration
In the practice for Lesson 9, “Optimizing a Data Guard Configuration,” you configure
network compression of redo data.

Oracle Database 11g: Data Guard Administration A - 106


Practice 9-1: Configuring Network Compression of Redo Data
In this practice, you set the RedoCompression property to configure network
compression of redo data.
1) Invoke SQL*Plus on your primary database and determine if redo compression is
enabled by querying V$ARCHIVE_DEST.
SQL> col dest_name format a30
SQL> select dest_name, compression
2 from v$archive_dest;

DEST_NAME COMPRES
------------------------------ -------
LOG_ARCHIVE_DEST_1 DISABLE
LOG_ARCHIVE_DEST_2 DISABLE
LOG_ARCHIVE_DEST_3 DISABLE
LOG_ARCHIVE_DEST_4 DISABLE
LOG_ARCHIVE_DEST_5 DISABLE
LOG_ARCHIVE_DEST_6 DISABLE
LOG_ARCHIVE_DEST_7 DISABLE
LOG_ARCHIVE_DEST_8 DISABLE
LOG_ARCHIVE_DEST_9 DISABLE
LOG_ARCHIVE_DEST_10 DISABLE

10 rows selected.
2) Invoke DGMGRL on your primary database host.
[oracle@edt3r17p0-pc00prmy pc00prmy]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
3) Enable redo compression by setting the RedoCompression property for your
standby database.
DGMGRL> edit database pc00sby1
> set property 'RedoCompression'='ENABLE';
Property "RedoCompression" updated

4) Return to your SQL*Plus session and query V$ARCHIVE_DEST again. Note that
compression is set for LOG_ARCHIVE_DEST_1.
SQL> select dest_name, compression
2 from v$archive_dest;

DEST_NAME COMPRES
------------------------------ -------
LOG_ARCHIVE_DEST_1 ENABLE

Oracle Database 11g: Data Guard Administration A - 107


Practice 9-1: Configuring Network Compression of Redo Data
(continued)
LOG_ARCHIVE_DEST_2 DISABLE
LOG_ARCHIVE_DEST_3 DISABLE
LOG_ARCHIVE_DEST_4 DISABLE
LOG_ARCHIVE_DEST_5 DISABLE
LOG_ARCHIVE_DEST_6 DISABLE
LOG_ARCHIVE_DEST_7 DISABLE
LOG_ARCHIVE_DEST_8 DISABLE
LOG_ARCHIVE_DEST_9 DISABLE
LOG_ARCHIVE_DEST_10 DISABLE

10 rows selected.

Oracle Database 11g: Data Guard Administration A - 108


Practices for Lesson 10: Using Flashback Database in a
Data Guard Configuration
In the practices for Lesson 10, “Using Flashback Database in a Data Guard
Configuration,” you configure Flashback Database on your primary database and your
physical standby database.

Oracle Database 11g: Data Guard Administration A - 109


Practice 10-1: Configuring Flashback Database on the Primary
Database
In this practice, you configure Flashback Database on your primary database.
1) Invoke SQL*Plus and log in as the SYSDBA user.
2) Verify that your database is in ARCHIVELOG mode.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 138
Next log sequence to archive 140
Current log sequence 140

3) Shut down your primary database instance and restart it in MOUNT mode.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 422670336 bytes


Fixed Size 1300352 bytes
Variable Size 373295232 bytes
Database Buffers 41943040 bytes
Redo Buffers 6131712 bytes
Database mounted.

4) Execute the ALTER DATABASE FLASHBACK ON command to enable the flashback


database.
SQL> alter database flashback on;

Database altered.
5) Open the database.
SQL> alter database open;

Database altered.

6) Verify that the Flash Recovery Area size is 5 GB.


SQL> show parameter db_recovery_file_dest_size

NAME TYPE VALUE


------------------------------------ ----------- -------------
db_recovery_file_dest_size big integer 5G

Oracle Database 11g: Data Guard Administration A - 110


Practice 10-2: Configuring Flashback Database on the Standby
Database
In this practice, you configure Flashback Database on your physical standby database.
1) Invoke DGMGRL and connect as the SYS user with a password of oracle. Disable
Redo Apply (the MRP process). Exit from DGMGRL.
DGMGRL> connect sys/oracle
Connected.
DGMGRL> edit database 'pc00sby1' set state='apply-off';
Succeeded.
DGMGRL> exit

2) Invoke SQL*Plus and connect as SYSDBA. Execute the ALTER DATABASE


FLASHBACK ON command to enable Flashback Database. Exit from SQL*Plus.

SQL> alter database flashback on;

Database altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
[oracle@edt3r17p2-pc00sby1 ~]$
3) Invoke DGMGRL again and restart Redo Apply.
DGMGRL> edit database 'pc00sby1' set state='apply-on';
Succeeded.
DGMGRL> exit

Oracle Database 11g: Data Guard Administration A - 111


Practices for Lesson 11: Performing Role Transitions
In the practices for Lesson 11, “Performing Role Transitions,” you perform a switchover
operation by using DGMGRL and Enterprise Manager Grid Control.

Oracle Database 11g: Data Guard Administration A - 112


Practice 11-1: Performing Switchover by Using DGMGRL
In this practice, you perform a switchover operation by using DGMGRL.
1) Invoke SQL*Plus on your primary database and connect as the HR user.
[oracle@edt3r17p0-pc00prmy labs]$ sqlplus hr/hr

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Nov 28


03:20:54 2007

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

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

2) Execute the cr_emp_hist.sql script to create a new table named


HR.EMP_HIST.
SQL> set echo on
SQL> @cr_emp_hist
SQL> create table emp_hist
2 as select * from employees
3 /

Table created.

3) Connect to your database as the SYSDBA user and perform a log switch on your
primary database. Exit SQL*Plus.
SQL> connect / as sysdba
Connected.
SQL> alter system switch logfile;

System altered.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options

4) Invoke DGMGRL on your primary database host and connect as the SYS user with
the password oracle.
[oracle@edt3r17p0-pc00prmy labs]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Oracle Database 11g: Data Guard Administration A - 113


Practice 11-1: Performing Switchover by Using DGMGRL
(continued)

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
5) Check the state, health, and properties of the primary database by using the SHOW
DATABASE VERBOSE command.
DGMGRL> show database verbose 'pc00prmy';

Database
Name: pc00prmy
OEM Name: pc00prmy.us.oracle.com
Role: PRIMARY
Enabled: YES
Intended State: TRANSPORT-ON
Instance(s):
pc00prmy
Properties:
DGConnectIdentifier = 'pc00prmy'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'MANUAL'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '4'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = ''
LogFileNameConvert = ''
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName =
'edt3r17p0.us.oracle.com'
SidName = 'pc00prmy'
StandbyArchiveLocation =
'USE_DB_RECOVERY_FILE_DEST'

Oracle Database 11g: Data Guard Administration A - 114


Practice 11-1: Performing Switchover by Using DGMGRL
(continued)
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
LatestLog = '(monitor)'
TopWaitEvents = '(monitor)'

Current status for "pc00prmy":


SUCCESS

6) Edit your primary database to set the DbFileNameConvert and


LogFileNameConvert database properties. Be sure to set them to the values for
your primary and standby databases: pc<nn>prmy and pc<nn>sby1.
DGMGRL> edit database 'pc00prmy'
> set property DbFileNameConvert='/pc00sby1/, /pc00prmy/';
Property "dbfilenameconvert" updated
DGMGRL> edit database 'pc00prmy'
> set property LogFileNameConvert='/pc00sby1/, /pc00prmy/';
Property "logfilenameconvert" updated
7) Check the state, health, and properties of the physical standby database by using the
SHOW DATABASE VERBOSE command.
DGMGRL> show database verbose 'pc00sby1';

Database
Name: pc00sby1
OEM Name: pc00sby1.us.oracle.com
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: APPLY-ON
Instance(s):
pc00sby1

Properties:
DGConnectIdentifier = 'pc00sby1'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'

Oracle Database 11g: Data Guard Administration A - 115


Practice 11-1: Performing Switchover by Using DGMGRL
(continued)
LogArchiveMaxProcesses = '5'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = '/pc00prmy/, /pc00sby1/'
LogFileNameConvert = '/pc00prmy/, /pc00sby1/'
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName =
'edt3r17p2.us.oracle.com'
SidName = 'pc00sby1'
StandbyArchiveLocation =
'USE_DB_RECOVERY_FILE_DEST'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
LatestLog = '(monitor)'
TopWaitEvents = '(monitor)'

Current status for "pc00sby1":


SUCCESS

8) Execute the switchover command to make your physical standby database your
primary database.
DGMGRL> switchover to pc00sby1
Performing switchover NOW, please wait...
New primary database "pc00sby1" is opening...
Operation requires shutdown of instance "pc00prmy" on database
"pc00prmy"
Shutting down instance "pc00prmy"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pc00prmy" on database
"pc00prmy"
Starting instance "pc00prmy"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "pc00sby1"

Oracle Database 11g: Data Guard Administration A - 116


Practice 11-1: Performing Switchover by Using DGMGRL
(continued)
9) Execute the SHOW CONFIGURATION command to verify the status of the
configuration:
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxPerformance
Databases:
pc00sby1 - Primary database
pc00prmy - Physical standby database
pc00sby3 – Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

Note: If you receive a Warning: ORA-16608: one or more databases


have warnings message, wait a few minutes and execute the command again. If you
receive a Warning: ORA-16607: one or more databases have failed
message, it may be necessary to shut down and restart your logical standby database.
10) Open a terminal window to the system that your new primary database is on (the
system that your standby database had been on). Set the ORACLE_SID environment
variable for your new primary database (pc<nn>sby1). Invoke SQL*Plus on your
new primary database host. Verify that the HR.EMP_HIST table exists. Exit
SQL*Plus.
[oracle@edt3r17p2-pc00sby1 ~]$ sqlplus hr/hr

SQL*Plus: Release 11.1.0.6.0 - Production on Sat Nov 17


04:34:47 2007

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

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

SQL> select count(*) from emp_hist;

COUNT(*)
----------
107

Oracle Database 11g: Data Guard Administration A - 117


Practice 11-1: Performing Switchover by Using DGMGRL
(continued)
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options

Oracle Database 11g: Data Guard Administration A - 118


Practice 11-2: Performing Switchover by Using Enterprise
Manager
In this practice, you perform another switchover by using Enterprise Manager Database
Control to return to your original configuration.
1) Invoke Enterprise Manager Grid Control and log in as the sysman user with the
password oracle1.
2) Navigate to the Databases page and select your new primary database
(pc<nn>sby1) by clicking the appropriate Name link.

3) Click the Primary link in the High Availability section of the database home page.

4) Select your new physical standby database (pc<nn>prmy) and click Switchover.

5) Provide your host login credentials and click Continue.

Oracle Database 11g: Data Guard Administration A - 119


Practice 11-2: Performing Switchover by Using Enterprise
Manager (continued)
6) Click Yes on the Confirmation page. The Processing: Switchover page is displayed.

7) Note that the Data Guard page displays a message indicating that the switchover
operation was completed successfully.

Oracle Database 11g: Data Guard Administration A - 120


Practices for Lesson 12: Enabling Fast-Start Failover
In the practices for Lesson 12, “Enabling Fast-Start Failover,” you enable fast-start
failover and test your implementation.

Oracle Database 11g: Data Guard Administration A - 121


Practice 12-1: Enabling Fast-Start Failover
In this practice, you set fast-start failover properties and enable fast-start failover.
1) On your primary database host, invoke DGMGRL and connect as the SYS user. Set
the FastStartFailoverTarget database property on the primary database and
your chosen target standby database (pc<nn>sby1).
DGMGRL> edit database pc00prmy
> set property FastStartFailoverTarget = pc00sby1;
Property "faststartfailovertarget" updated
DGMGRL> edit database pc00sby1
> set property FastStartFailoverTarget = pc00prmy;
Property "faststartfailovertarget" updated
2) Verify that the protection mode is set to maximum availability.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
pc00sby3 - Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

3) Verify that the LogXptMode property is set to SYNC for the primary database and
the physical standby database.
DGMGRL> show database pc00prmy LogXptMode
LogXptMode = 'SYNC'
DGMGRL> show database pc00sby1 LogXptMode
LogXptMode = 'SYNC'

4) Set the fast-start failover threshold to 90 seconds.


DGMGRL> edit configuration
> set property FastStartFailoverThreshold=90;
Property "faststartfailoverthreshold" updated
5) Set the lag-time limit to 60 seconds by setting the
FastStartFailoverLagLimit broker property.
DGMGRL> edit configuration
> set property FastStartFailoverLagLimit=60;
Property "faststartfailoverlaglimit" updated
6) Enable fast-start failover.

Oracle Database 11g: Data Guard Administration A - 122


Practice 12-1: Enabling Fast-Start Failover (continued)
DGMGRL> enable fast_start failover;
Enabled.

7) Check the status of the configuration by executing the SHOW CONFIGURATION


VERBOSE command.
DGMGRL> show configuration verbose

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
- Fast-Start Failover target
pc00sby3 - Logical standby database

Fast-Start Failover: ENABLED


Threshold: 90 seconds
Target: pc00sby1
Observer: (none)
Lag Limit: 60 seconds
Shutdown Primary: TRUE
Auto-reinstate: TRUE

Current status for "DGConfig1":


Warning: ORA-16608: one or more databases have warnings

8) Investigate the warning by displaying information about the databases in the


configuration.
DGMGRL> show database pc00prmy

Database
Name: pc00prmy
Role: PRIMARY
Enabled: YES
Intended State: TRANSPORT-ON
Instance(s):
pc00prmy

Current status for "pc00prmy":


Warning: ORA-16819: fast-start failover observer not started

You start the observer in the next practice.

Oracle Database 11g: Data Guard Administration A - 123


Practice 12-2: Starting the Observer
In this practice, you start the observer. Note that, for this exercise, you start the observer
on the same system that your standby database is on. In a real-world situation, the
observer should be started on another system, separate from the primary database and
standby database.
1) Invoke DGMGRL on the system that your physical standby database is located on
and connect to your physical standby database. Be sure to set the ORACLE_SID
environment variable to pc<nn>sby1.
[oracle@edt3r17p2-pc00sby1 ~]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
2) Start the observer. Remember that control is not returned after starting the observer.
DGMGRL> start observer
Observer started
3) Return to your DGMGRL session on your primary database system and verify the
status of your configuration.
DGMGRL> show configuration verbose

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
- Fast-Start Failover target
pc00sby3 - Logical standby database

Fast-Start Failover: ENABLED


Threshold: 90 seconds
Target: pc00sby1
Observer: edt3r17p2.us.oracle.com
Lag Limit: 60 seconds
Shutdown Primary: TRUE
Auto-reinstate: TRUE

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 124


Practice 12-2: Starting the Observer (continued)
4) Use the SHOW FAST_START FAILOVER command to further verify your
configuration.
DGMGRL> show fast_start failover;

Fast-Start Failover: ENABLED


Threshold: 90 seconds
Target: pc00sby1
Observer: edt3r17p2.us.oracle.com
Lag Limit: 60 seconds
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)

Oracle Database 11g: Data Guard Administration A - 125


Practice 12-3: Testing Fast-Start Failover
In this practice, you test fast-start failover.
1) On the computer that your primary database is on, invoke SQL*Plus and log in as the
SYSDBA user.
[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Nov 30


11:28:00 2007

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
2) To simulate a failure of the primary database, shut down your primary database
instance with the ABORT option.
SQL> shutdown abort
ORACLE instance shut down.
3) Return to the window on your physical standby database system where you started
the observer. View the actions. The failover make take a few minutes.
11:30:34.98 Friday, November 30, 2007
Initiating Fast-Start Failover to database "pc00sby1"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "pc00sby1"
11:31:12.88 Friday, November 30, 2007
4) Open another terminal window for the system that your physical standby database is
on. Set the ORACLE_SID environment variable to pc<nn>sby1. Invoke DGMGRL
and connect as the SYS user.
[oracle@edt3r17p2-pc00sby1 ~]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
5) Verify the status of your configuration.
DGMGRL> show configuration

Configuration

Oracle Database 11g: Data Guard Administration A - 126


Practice 12-3: Testing Fast-Start Failover (continued)
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00sby1 - Primary database
pc00prmy - Physical standby database (disabled)
- Fast-Start Failover target
pc00sby3 - Logical standby database

Fast-Start Failover: ENABLED

Current status for "DGConfig1":


Warning: ORA-16608: one or more databases have warnings
6) Further investigate the configuration.
DGMGRL> show database pc00sby1

Database
Name: pc00sby1
Role: PRIMARY
Enabled: YES
Intended State: TRANSPORT-ON
Instance(s):
pc00sby1

Current status for "pc00sby1":


Warning: ORA-16817: unsynchronized fast-start failover
configuration
7) Investigate the status of your new standby database.
DGMGRL> show database pc00prmy

Database
Name: pc00prmy
Role: PHYSICAL STANDBY
Enabled: NO
Intended State: APPLY-ON
Instance(s):
pc00prmy

Current status for "pc00prmy":


Error: ORA-16661: the standby database needs to be reinstated

8) Invoke SQL*Plus on the system that your pc<nn>prmy database is on and connect
as the SYSDBA user.
[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Nov 30


11:46:03 2007

Oracle Database 11g: Data Guard Administration A - 127


Practice 12-3: Testing Fast-Start Failover (continued)
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to an idle instance.

9) Start the instance and MOUNT the database. Note that you may see messages in the
observer window.
SQL> startup mount
ORACLE instance started.

Total System Global Area 422670336 bytes


Fixed Size 1300352 bytes
Variable Size 369100928 bytes
Database Buffers 46137344 bytes
Redo Buffers 6131712 bytes
Database mounted.
SQL>

10) Return to the DGMGRL session for your pc<nn>sby1 database and reinstate the
pc<nn>prmy database if needed. You receive an error if it is already reinstated.
DGMGRL> REINSTATE DATABASE ‘pc00prmy’;
Reinstating database "pc00prmy", please wait...
Error: ORA-16657: reinstatement of database in progress

Failed.
Database reinstatement for "pc00prmy" in progress.
11) Monitor the window that you started the observer in and note that the broker is
reinstating the database for you.
11:31:12.88 Friday, November 30, 2007

11:46:49.17 Friday, November 30, 2007


Initiating reinstatement for database "pc00prmy"...
Reinstating database "pc00prmy", please wait...
Operation requires shutdown of instance "pc00prmy" on database
"pc00prmy"
Shutting down instance "pc00prmy"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pc00prmy" on database
"pc00prmy"
Starting instance "pc00prmy"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "pc00prmy" ...
Reinstatement of database "pc00prmy" succeeded
11:47:53.45 Friday, November 30, 2007

Oracle Database 11g: Data Guard Administration A - 128


Practice 12-3: Testing Fast-Start Failover (continued)
12) Verify the status of your configuration.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00sby1 - Primary database
pc00prmy - Physical standby database
- Fast-Start Failover target
pc00sby3 - Logical standby database

Fast-Start Failover: ENABLED

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 129


Practice 12-4: Switching Back to Your Primary Database
In this practice, you perform a switchover to reestablish your original primary database in
preparation for later practices.
1) In a DGMGRL session, while you are connected to your pc<nn>sby1 database,
verify the status of your configuration.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00sby1 - Primary database
pc00prmy - Physical standby database
- Fast-Start Failover target
pc00sby3 - Logical standby database

Fast-Start Failover: ENABLED

Current status for "DGConfig1":


SUCCESS
2) Perform a switchover to your pc<nn>prmy database.
DGMGRL> switchover to pc00prmy;
Performing switchover NOW, please wait...
New primary database "pc00prmy" is opening...
Operation requires shutdown of instance "pc00sby1" on database
"pc00sby1"
Shutting down instance "pc00sby1"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pc00sby1" on database
"pc00sby1"
Starting instance "pc00sby1"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "pc00prmy"
3) Verify the status of your configuration.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database

Oracle Database 11g: Data Guard Administration A - 130


Practice 12-4: Switching Back to Your Primary Database
(continued)
pc00sby1 - Physical standby database
- Fast-Start Failover target
pc00sby3 - Logical standby database

Fast-Start Failover: ENABLED

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 131


Practice 12-5: Stopping the Observer and Disabling Fast-Start
Failover
In this practice, you stop the observer and disable fast-start failover in preparation for
later practices.
1) Invoke DGMGRL and connect to your primary database.
[oracle@edt3r17p0-pc00prmy labs]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
2) Stop the observer.
DGMGRL> stop observer
Done.
3) Note what happens to the DGMGRL session that you used to start the observer.
Observer stopped
[oracle@edt3r17p2-pc00sby1 admin]$
4) Check the status of fast-start failover.
DGMGRL> show fast_start failover

Fast-Start Failover: ENABLED


Threshold: 90 seconds
Target: pc00sby1
Observer: (none)
Lag Limit: 60 seconds
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)
5) Disable fast-start failover.
DGMGRL> disable fast_start failover;
Disabled.

Oracle Database 11g: Data Guard Administration A - 132


Practice 12-5: Stopping the Observer and Disabling Fast-Start
Failover (continued)
6) Check the status of fast-start failover.
DGMGRL> show fast_start failover

Fast-Start Failover: DISABLED


Threshold: 90 seconds
Target: (none)
Observer: (none)
Lag Limit: 60 seconds
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)

Oracle Database 11g: Data Guard Administration A - 133


Practices for Lesson 13: Creating and Managing a
Snapshot Standby Database
In the practices for Lesson 13, “Creating and Managing a Snapshot Standby Database,”
you create a snapshot standby database.

Oracle Database 11g: Data Guard Administration A - 134


Practice 13-1: Verifying Flashback Database on the Physical
Standby Database
In this practice, you verify that Flashback Database is configured on your physical
standby database.
1) On the system that your physical standby database is on, invoke SQL*Plus and
connect as the SYSDBA user.
[oracle@edt3r17p2-pc00sby1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Sat Dec 1


13:37:15 2007

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
2) Determine if Flashback Database is enabled for the physical standby database by
querying V$DATABASE. Exit SQL*Plus.
SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

3) If Flashback Database is enabled, proceed to Practice 13-2.


4) If Flashback Database is not enabled for the physical standby database, enable it by
using the ALTER DATABASE command.
a) Invoke DGMGRL and connect as user sys with password oracle. Disable
Redo Apply (the MRP process).
DGMGRL> connect sys/oracle
Connected.
DGMGRL> edit database 'pc00sby1' set state='apply-off';
Succeeded.
DGMGRL> exit

b) Invoke SQL*Plus and connect as SYSDBA. Execute the ALTER DATABASE


command to enable Flashback Database.
[oracle@edt3r17p0-orclsby1 labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Sat Dec 1


13:37:15 2007

Oracle Database 11g: Data Guard Administration A - 135


Practice 13-1: Verifying Flashback Database on the Physical
Standby Database (continued)

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

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

SQL> alter database flashback on;

Database altered.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
c) Invoke DGMGRL again and restart the MRP process.
[oracle@edt3r17p0-orclsby1 labs]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
DGMGRL> edit database 'pc00sby1' set state='apply-on';
Succeeded.
DGMGRL> exit

Oracle Database 11g: Data Guard Administration A - 136


Practice 13-2: Converting the Physical Standby Database to a
Snapshot Standby Database
In this practice, you convert your physical standby database to a snapshot standby
database.
1) Invoke DGMGRL in your primary database window and connect to the primary
database.
[oracle@edt3r17p0-pc00prmy labs]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
2) Convert the physical standby database to a snapshot standby database by executing
the CONVERT DATABASE TO SNAPSHOT STANDBY DATABASE DGMGRL
command.
DGMGRL> convert database pc00sby1 to snapshot standby;
Converting database "pc00sby1" to a Snapshot Standby database,
please wait...
Database "pc00sby1" converted successfully
3) Verify that the database was successfully converted by executing the SHOW
CONFIGURATION command.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Snapshot standby database
pc00sby3 - Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 137


Practice 13-3: Updating the Databases and Verifying Redo
Shipment
In this practice, you update your database and verify the shipment of redo data.
1) Open a terminal window for the system that your snapshot standby database is on. Set
the ORACLE_SID environment variable to pc<nn>sby1. Log in to SQL*Plus as
the SYSDBA user. To demonstrate that redo data is being received by the standby
database, query V$MANAGED_STANDBY on the snapshot standby database and
record the value in the BLOCK# column: __________________________
SQL> select status, sequence#, block#
2 from v$managed_standby
3 where client_process='LGWR';

STATUS SEQUENCE# BLOCK#


------------ ---------- ----------
IDLE 13 664
2) Invoke SQL*Plus in your primary database window and connect as SYSDBA. Insert a
row in the HR.REGIONS table on the primary database as follows. Exit SQL*Plus.
[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Sat Dec 1


13:52:52 2007

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

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

SQL> INSERT INTO hr.regions


2 values (10, 'Australia');

1 row created.

SQL> commit;

Commit complete.
3) Return to your SQL*Plus session in your standby database window. Insert a row in
the HR.REGIONS table on the snapshot standby database:
SQL> insert into hr.regions
2 values (20, 'Australia');
1 row created.
SQL> commit;

Oracle Database 11g: Data Guard Administration A - 138


Practice 13-3: Updating the Databases and Verifying Redo
Shipment (continued)

Commit complete.
4) Query the HR.REGIONS table in your snapshot standby database.
SQL> select * from hr.regions;

REGION_ID REGION_NAME
---------- -------------------------
20 Australia
1 Europe
2 Americas
3 Asia
4 Middle East and Africa
5) On the standby database, verify that redo data is being shipped to the snapshot
standby database by again querying V$MANAGED_STANDBY. Record the value in the
BLOCK# column: __________________ Exit SQL*Plus.
SQL> select status, sequence#, block#
2 from v$managed_standby
3 where client_process='LGWR';

STATUS SEQUENCE# BLOCK#


------------ ---------- ----------
IDLE 13 2057

Oracle Database 11g: Data Guard Administration A - 139


Practice 13-4: Converting the Snapshot Standby Database to a
Physical Standby Database
In this practice, you convert the snapshot standby database back to a physical standby
database.
1) Invoke DGMGRL on your primary database system and connect as user sys with
password oracle.
[oracle@edt3r17p0-pc00prmy labs]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected
2) Convert the snapshot standby database back to a physical standby database.
DGMGRL> convert database pc00sby1 to physical standby;
Converting database "pc00sby1" to a Physical Standby database,
please wait...
Operation requires shutdown of instance "pc00sby1" on database
"pc00sby1"
Shutting down instance "pc00sby1"...
Database closed.
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pc00sby1" on database
"pc00sby1"
Starting instance "pc00sby1"...
ORACLE instance started.
Database mounted.
Continuing to convert database "pc00sby1" ...
Operation requires shutdown of instance "pc00sby1" on database
"pc00sby1"
Shutting down instance "pc00sby1"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pc00sby1" on database
"pc00sby1"
Starting instance "pc00sby1"...
ORACLE instance started.
Database mounted.
Database "pc00sby1" converted successfully
DGMGRL>

3) Verify the status of the standby database by executing the SHOW CONFIGURATION
command.

Oracle Database 11g: Data Guard Administration A - 140


Practice 13-4: Converting the Snapshot Standby Database to a
Physical Standby Database (continued)
DGMGRL> show configuration
Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database
pc00sby3 - Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

4) Exit from DGMGRL and invoke SQL*Plus in your primary database window.
[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Sat Dec 1


14:05:39 2007

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
5) Perform a log switch on the primary database.
SQL> alter system switch logfile;

System altered.

6) Check the HR.REGIONS table to verify that the change made to the primary database
was propagated to the physical standby database and to verify that the row inserted in
the HR.REGIONS table when it was a snapshot standby database is no longer in the
table. Invoke DGMGRL in your standby database window and connect as the sys
user.
[oracle@edt3r17p2-pc00sby1 ~]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.

Oracle Database 11g: Data Guard Administration A - 141


Practice 13-4: Converting the Snapshot Standby Database to a
Physical Standby Database (continued)
DGMGRL> connect sys/oracle
Connected.

7) So that you can query the HR.REGIONS table, stop Redo Apply. Exit DGMGRL.
DGMGRL> edit database pc00sby1 set state='apply-off';
Succeeded.
DGMGRL> exit

8) Invoke SQL*Plus in your standby database window and connect as the SYSDBA user.
Open the physical standby database in read-only mode.
[oracle@edt3r17p2-pc00sby1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Sat Dec 1


15:48:46 2007

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

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

SQL> alter database open read only;

Database altered.
9) Query the HR.REGIONS table in your standby database.
Note that the change you made when the database was a snapshot standby database is
not present in the table. Note that the row that you inserted into the HR.REGIONS on
the primary database is present in the table.
SQL> select * from hr.regions;

REGION_ID REGION_NAME
---------- -------------------------
1 Europe
2 Americas
3 Asia
4 Middle East and Africa
10 Australia

10) Shut down the physical standby database and restart it in MOUNT mode. Exit
SQL*Plus.
SQL> shutdown immediate
Database closed.
Database dismounted.

Oracle Database 11g: Data Guard Administration A - 142


Practice 13-4: Converting the Snapshot Standby Database to a
Physical Standby Database (continued)
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 422670336 bytes


Fixed Size 1300352 bytes
Variable Size 348129408 bytes
Database Buffers 67108864 bytes
Redo Buffers 6131712 bytes
Database mounted.
11) Exit from SQL*Plus and invoke DGMGRL on your standby system and connect as
the SYS user.
[oracle@edt3r17p2-pc00sby1 admin]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
12) Start Redo Apply on your physical standby database.
DGMGRL> edit database pc00sby1 set state='apply-on';
Succeeded.
13) Verify that Redo Apply is started.
DGMGRL> show database pc00sby1

Database
Name: pc00sby1
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: APPLY-ON
Instance(s):
pc00sby1

Current status for "pc00sby1":


SUCCESS
14) Verify the status of your configuration.
DGMGRL> show configuration
Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database

Oracle Database 11g: Data Guard Administration A - 143


Practice 13-4: Converting the Snapshot Standby Database to a
Physical Standby Database (continued)
pc00sby3 - Logical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 144


Practices for Lesson 14: Using Oracle Active Data Guard
In the practices for Lesson 14, “Using Oracle Active Data Guard,” you enable Real-Time
Query and perform queries against your physical standby database while Redo Apply is
active. You also enable block change tracking.

Oracle Database 11g: Data Guard Administration A - 145


Practice 14-1: Using Real-Time Query
In this practice, you enable Real-Time Query so that you can perform queries against
your physical standby database while Redo Apply is active.
1) In your standby database window, invoke DGMGRL and connect as the sys user
with a password of oracle.
[oracle@edt3r17p2-pc00sby1 admin]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.

2) Remove your logical standby database, pcnnsby3 from your configuration. You
will be able to use Real-Time Query to query your physical standby database.
DGMGRL> remove database 'pc00sby3';
Removed database "pc00sby3" from the configuration

DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS
3) Disable Redo Apply on your physical standby database.
DGMGRL> edit database 'pc00sby1' set state='apply-off';
Succeeded.
4) Confirm your change. Exit DGMGRL.
DGMGRL> show database pc00sby1

Database
Name: pc00sby1
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: APPLY-OFF
Instance(s):
pc00sby1

Oracle Database 11g: Data Guard Administration A - 146


Practice 14-1: Using Real-Time Query (continued)

Current status for "pc00sby1":


SUCCESS

DGMGRL> exit
[oracle@edt3r17p2-pc00sby1 admin]$

5) In your standby database window, invoke SQL*Plus and connect as SYSDBA.


[oracle@edt3r17p2-pc00sby1 admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Dec 3


14:53:49 2007

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
6) Open your physical standby database in read-only mode. Exit SQL*Plus.
SQL> alter database open read only;

Database altered.

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

7) In your standby database window, invoke DGMGRL and connect as the sys user
with a password of oracle.
[oracle@edt3r17p2-pc00sby1 admin]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
DGMGRL>

Oracle Database 11g: Data Guard Administration A - 147


Practice 14-1: Using Real-Time Query (continued)
8) Restart Redo Apply and confirm your change. Exit DGMGRL.
DGMGRL> edit database 'pc00sby1' set state='apply-on';
Succeeded.
DGMGRL> show database pc00sby1

Database
Name: pc00sby1
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: APPLY-ON
Instance(s):
pc00sby1

Current status for "pc00sby1":


SUCCESS
DGMGRL> exit
[oracle@edt3r17p2-pc00sby1 admin]$

9) In your standby database window, invoke SQL*Plus and connect as SYSDBA. Query
the HR.REGIONS table.
[oracle@edt3r17p2-pc00sby1 labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Dec 3


14:59:47 2007

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

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

SQL> select * from hr.regions;

REGION_ID REGION_NAME
---------- -------------------------
1 Europe
2 Americas
3 Asia
4 Middle East and Africa
10 Australia

SQL>

10) In your primary database window, invoke SQL*Plus and connect as SYSDBA. Insert
a row in the HR.REGIONS table.

Oracle Database 11g: Data Guard Administration A - 148


Practice 14-1: Using Real-Time Query (continued)
[oracle@edt3r17p0-pc00prmy labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Dec 3


15:01:01 2007

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

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

SQL> insert into hr.regions


2 values (20, 'Antarctica');

1 row created.

SQL> commit;

Commit complete.

11) Return to your standby database window and query the HR.REGIONS table again. In
your standby database, you should see the new row that you inserted in the
HR.REGIONS table on your primary database.
SQL> select * from hr.regions;

REGION_ID REGION_NAME
---------- -------------------------
1 Europe
2 Americas
3 Asia
4 Middle East and Africa
10 Australia
20 Antarctica

6 rows selected.

12) Return your physical standby database to MOUNT mode. Exit SQL*Plus.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 422670336 bytes


Fixed Size 1300352 bytes

Oracle Database 11g: Data Guard Administration A - 149


Practice 14-1: Using Real-Time Query (continued)
Variable Size 348129408 bytes
Database Buffers 67108864 bytes
Redo Buffers 6131712 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition
Release 11.1.0.6.0 - Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
[oracle@edt3r17p2-pc00sby1 labs]$
13) Invoke DGMGRL in your primary database window and connect to your primary
database. Verify the status of your configuration.
[oracle@edt3r17p0-pc00prmy labs]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

Oracle Database 11g: Data Guard Administration A - 150


Practice 14-2: Enabling Block Change Tracking
In this practice, you enable block change tracking on your physical standby database for
fast incremental backups.
1) In your physical standby database window, invoke SQL*Plus and connect to your
physical standby database as the SYSDBA user.
[oracle@edt3r17p2-pc00sby1 labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Dec 3


15:21:28 2007

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 -
Production
With the Partitioning, Oracle Label Security, OLAP, Data
Mining
and Real Application Testing options
2) Enable block change tracking and specify
/u01/app/oracle/oradata/pc<nn>sby1/chg_track.chg for the file
name. Be sure to specify your standby database name (pc<nn>sby1) as the
directory name.
SQL> alter database enable block change tracking
2 using file
'/u01/app/oracle/oradata/pc00sby1/chg_track.chg';

Database altered.

3) Query V$BLOCK_CHANGE_TRACKING to confirm that block change tracking is


enabled.
SQL> select filename, status, bytes
2 from v$block_change_tracking;

FILENAME STATUS BYTES


---------------------------------------------- ---------- ----------
/u01/app/oracle/oradata/pc00sby1/chg_track.chg ENABLED 11599872

4) Exit SQL*Plus.

Oracle Database 11g: Data Guard Administration A - 151


Practices for Lesson 15: Backup and Recovery
Considerations in an Oracle Data Guard Configuration
In the practices for Lesson 15, “Backup and Recovery Considerations in an Oracle Data
Guard Configuration,” you create a recovery catalog and register the databases in your
Data Guard configuration. You also configure RMAN parameters on the primary and
standby database. Finally, you create an incremental backup of your physical standby
database.

Oracle Database 11g: Data Guard Administration A - 152


Practice 15-1: Creating the Recovery Catalog
In this practice, you configure the database for the recovery catalog, create the recovery
catalog owner, and create the recovery catalog. In addition to your primary database,
pcnnprmy, there is a database named pcnndb11 that is pre-created on your host
machine. You create the recovery catalog in the pcnndb11 database in this practice.
1) Open a new terminal window on your assigned PC and set the ORACLE_SID
environment variable to pc<nn>db11.
[oracle@edt3r17p0-pc00prmy ~]$ echo $ORACLE_SID
pc00prmy
[oracle@edt3r17p0-pc00prmy ~]$ export ORACLE_SID=pc00db11

2) Change to the labs directory.


[oracle@edt3r17p0-pc00db11 ~]$ cd labs
[oracle@edt3r17p0-pc00db11 labs]$

3) Invoke SQL*Plus and connect as SYSDBA.


[oracle@edt3r17p0-pc00db11 labs]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Tue Dec 4


14:55:41 2007

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

Connected to an idle instance.

4) Start the database instance.


SQL> startup
ORACLE instance started.

Total System Global Area 422670336 bytes


Fixed Size 1300352 bytes
Variable Size 276826240 bytes
Database Buffers 138412032 bytes
Redo Buffers 6131712 bytes
Database mounted.
Database opened.
SQL>

5) Create a tablespace named RCTS to hold the recovery catalog data. Specify a data file
name of ‘/u01/app/oracle/oradata/pcnndb11/rcts.dbf’ and size of
30 MB. You can use the rcts_create.sql script.
SQL> set echo on
SQL> @rcts_create
SQL> create tablespace rcts
2 datafile '/u01/app/oracle/oradata/pc00db11/rcts.dbf' size
30M

Oracle Database 11g: Data Guard Administration A - 153


Practice 15-1: Creating the Recovery Catalog (continued)
3 /

Tablespace created.

SQL>

6) Create the recovery catalog owner user named RCOWNER with a password of
rcpass. The default tablespace for the user is RCTS. Provide unlimited quota on the
RCTS tablespace to the user. You can use the rcowner_create.sql script.
SQL> @rcowner_create
SQL> create user rcowner identified by rcpass
2 default tablespace rcts
3 quota unlimited on rcts
4 /

User created.
7) Grant the RECOVERY_CATALOG_OWNER role to the RCOWNER user. Exit
SQL*Plus.
SQL> grant recovery_catalog_owner to rcowner;

Grant succeeded.

8) Invoke RMAN and connect to the pcnndb11 database as the recovery catalog
owner. Remember that the password for RCOWNER is rcpass.
[oracle@edt3r17p0-pc00db11 labs]$ rman catalog rcowner

Recovery Manager: Release 11.1.0.6.0 - Production on Tue Dec 4


15:21:23 2007

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

recovery catalog database Password:


connected to recovery catalog database

9) Create the recovery catalog.


RMAN> create catalog;

recovery catalog created

RMAN> exit

Recovery Manager complete.


[oracle@edt3r17p0-db11g labs]$

Oracle Database 11g: Data Guard Administration A - 154


Practice 15-2: Registering Your Database in the Recovery
Catalog
In this practice, you register your primary database in the recovery catalog.
1) Open a terminal window and verify that the ORACLE_SID environment variable is
set to pc<nn>prmy.
2) Invoke RMAN and connect to your primary database and the recovery catalog
database. Supply the rcpass password when prompted.
[oracle@edt3r17p0-pc00prmy labs]$ rman target / catalog
rcowner@pc00db11

Recovery Manager: Release 11.1.0.6.0 - Production on Tue Dec 4


16:13:03 2007

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

connected to target database: PC00PRMY (DBID=1159023676)


recovery catalog database Password:
connected to recovery catalog database

RMAN>
3) Register your primary database.
RMAN> register database;

database registered in recovery catalog


starting full resync of recovery catalog
full resync complete

RMAN>

4) Use the LIST DB_UNIQUE_NAME command to verify your registration.


RMAN> list db_unique_name of database;

List of Databases
DB Key DB Name DB ID Database Role Db_unique_name
------- ------- -------------- --------------- --------------
1 PC00PRMY 1159023676 PRIMARY PC00PRMY

5) Use the REPORT SCHEMA FOR DB_UNIQUE_NAME command to verify the files.
RMAN> report schema for db_unique_name pc00prmy;

Report of database schema for database with db_unique_name


PC00PRMY

List of Permanent Datafiles


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

Oracle Database 11g: Data Guard Administration A - 155


Practice 15-2: Registering Your Database in the Recovery
Catalog (continued)
File Size(MB) Tablespace RB segs Datafile Name
---- -------- ------------ ------- ------------------------
1 710 SYSTEM YES
/u01/app/oracle/oradata/pc00prmy/system01.dbf
2 742 SYSAUX NO
/u01/app/oracle/oradata/pc00prmy/sysaux01.dbf
3 200 UNDOTBS1 YES
/u01/app/oracle/oradata/pc00prmy/undotbs01.dbf
4 5 USERS NO
/u01/app/oracle/oradata/pc00prmy/users01.dbf
5 100 EXAMPLE NO
/u01/app/oracle/oradata/pc00prmy/example01.dbf

List of Temporary Files


=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- ------------ ----------- ---------------
1 28 TEMP 32767
/u01/app/oracle/oradata/pc00prmy/temp01.dbf

6) Use the LIST ARCHIVELOG ALL FOR DB_UNIQUE_NAME command to verify that
the archived log files are registered.
RMAN> list archivelog all for db_unique_name pc00prmy;

List of Archived Log Copies for database with db_unique_name


PC00PRMY
==============================================================

Key Thrd Seq S Low Time


------- ---- ------- - ---------
158 1 27 A 27-NOV-07
Name:
/u01/app/oracle/flash_recovery_area/PC00PRMY/archivelog/2007_1
1_27/o1_mf_1_27_3np6w4hc_.arc

159 1 28 A 27-NOV-07
Name:
/u01/app/oracle/flash_recovery_area/PC00PRMY/archivelog/2007_1
1_27/o1_mf_1_28_3np7g0jc_.arc


7) Use the SHOW ALL FOR DB_UNIQUE_NAME command to display the RMAN
configuration parameters for your primary database.
RMAN> show all for db_unique_name pc00prmy;

RMAN configuration parameters for database with db_unique_name


PC00PRMY are:

Oracle Database 11g: Data Guard Administration A - 156


Practice 15-2: Registering Your Database in the Recovery
Catalog (continued)
CONFIGURE RETENTION POLICY TO NONE;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
# default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/app/oracle/product/11.1.0/db_1/dbs/snapcf_pc00prmy.f'; #
default

Oracle Database 11g: Data Guard Administration A - 157


Practice 15-3: Configuring RMAN Parameters
In this practice, you configure RMAN parameters for your primary and physical standby
database.
1) In your RMAN session (connected to your primary database), configure the backup
retention policy to allow for recovery for seven days.
RMAN> configure retention policy to
2> recovery window of 7 days;

old RMAN configuration parameters:


CONFIGURE RETENTION POLICY TO NONE;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
2) Specify that archived redo log files can be deleted after they are applied to the
standby database.
RMAN> configure archivelog deletion policy to
2> applied on all standby;

new RMAN configuration parameters:


CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL
STANDBY;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
3) Configure the connect identifier for your primary database.
RMAN> configure db_unique_name pc00prmy
2> connect identifier 'pc00prmy';

new RMAN configuration parameters:


CONFIGURE DB_UNIQUE_NAME 'pc00prmy' CONNECT IDENTIFIER
'pc00prmy';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>
4) Configure the connect identifier for your physical standby database.
RMAN> configure db_unique_name pc00sby1
2> connect identifier 'pc00sby1';

Oracle Database 11g: Data Guard Administration A - 158


Practice 15-3: Configuring RMAN Parameters (continued)
new RMAN configuration parameters:
CONFIGURE DB_UNIQUE_NAME 'pc00sby1' CONNECT IDENTIFIER
'pc00sby1';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN>

5) Your physical standby database is registered with the recovery catalog. Use the LIST
DB_UNIQUE command to see the registration information about your primary and
standby databases.
RMAN> list db_unique_name of database;

List of Databases
DB Key DB Name DB ID Database Role Db_unique_name
------- ------- ------------- ------------- -------------
1 PC00PRMY 1159023676 PRIMARY PC00PRMY
1 PC00PRMY 1159023676 STANDBY PC00SBY1

RMAN>

6) Use the REPORT SCHEMA command to view additional information about your
physical standby database.
Note: Your output may vary from this example and may not include the actual data
file names.
RMAN> report schema for db_unique_name pc00sby1;

Report of database schema for database with db_unique_name


PC00SBY1

List of Permanent Datafiles


===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- -------------------
1 710 SYSTEM YES
/u01/app/oracle/oradata/pc00sby1/system01.dbf
2 742 SYSAUX NO
/u01/app/oracle/oradata/pc00sby1/sysaux01.dbf
3 200 UNDOTBS1 YES
/u01/app/oracle/oradata/pc00sby1/undotbs01.dbf
4 5 USERS NO
/u01/app/oracle/oradata/pc00sby1/users01.dbf
5 100 EXAMPLE NO
/u01/app/oracle/oradata/pc00sby1/example01.dbf

List of Temporary Files


=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name

Oracle Database 11g: Data Guard Administration A - 159


Practice 15-3: Configuring RMAN Parameters (continued)
---- -------- -------------------- ----------- ---------------
1 28 TEMP 32767
/u01/app/oracle/oradata/pc00sby1/temp01.dbf

RMAN>
7) Exit RMAN.
8) Invoke RMAN again and connect to your physical standby database and the recovery
catalog.
[oracle@edt3r17p0-pc00prmy labs]$ rman target
sys/oracle@pc00sby1 catalog rcowner/rcpass@pc00db11

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Dec 5


10:01:43 2007

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

connected to target database: PC00PRMY (DBID=1159023676, not


open)
connected to recovery catalog database

RMAN>

9) Execute the SHOW ALL command to view the configuration parameters for your
physical standby database.
RMAN> show all for db_unique_name pc00sby1;

RMAN configuration parameters for database with db_unique_name


PC00SBY1 are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
# default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE DB_UNIQUE_NAME 'pc00prmy' CONNECT IDENTIFIER
'pc00prmy';
CONFIGURE DB_UNIQUE_NAME 'pc00sby1' CONNECT IDENTIFIER
'pc00sby1';

Oracle Database 11g: Data Guard Administration A - 160


Practice 15-3: Configuring RMAN Parameters (continued)
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL
STANDBY;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/u01/app/oracle/product/11.1.0/db_1/dbs/snapcf_pc00sby1.f'; #
default

RMAN>
10) Configure automatic backup of the control file and the server parameter file.
RMAN> configure controlfile autobackup on;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN>
11) Configure backup optimization.
RMAN> configure backup optimization on;

new RMAN configuration parameters:


CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored

RMAN>

12) Set the archived log deletion policy to BACKED UP 1 TIMES TO DEVICE TYPE
DISK.
RMAN> configure archivelog deletion policy to backed up 1
times to device type disk;

old RMAN configuration parameters:


CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL
STANDBY;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO
DISK;
new RMAN configuration parameters are successfully stored

RMAN>

Oracle Database 11g: Data Guard Administration A - 161


Practice 15-4: Recovering a Data File in Your Primary Database
In this practice, you recover a data file in your primary database by using a data file from
your physical standby database.
1) In your primary database terminal window, change to the
$ORACLE_BASE/oradata/pc<nn>prmy directory.
[oracle@edt3r17p0-pc00prmy labs]$ cd
$ORACLE_BASE/oradata/pc00prmy
[oracle@edt3r17p0-pc00prmy pc00prmy]$
2) Move the example01.dbf file to example01.sav to simulate a failure in the
primary database.
[oracle@edt3r17p0-pc00prmy pc00prmy]$ mv example01.dbf
example01.sav
[oracle@edt3r17p0-pc00prmy pc00prmy]$

3) Verify that the ORACLE_SID environment variable is set to pc<nn>prmy. Log in


to SQL*Plus as the HR user
[oracle@edt3r17p0-pc00prmy pc00prmy]$ sqlplus hr/hr

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Feb 15


22:01:35 2008

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

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

4) Query the HR.EMPLOYEES table. Because you moved the data file, you receive an
error.
SQL> select count(*) from hr.employees;
select count(*) from hr.employees
*
ERROR at line 1:
ORA-01116: error in opening database file 5
ORA-01110: data file 5:
'/u01/app/oracle/oradata/pc00prmy/example01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
5) Exit SQL*Plus.
6) Invoke RMAN and connect to your physical standby database as the target and your
primary database as the auxiliary database.

Oracle Database 11g: Data Guard Administration A - 162


Practice 15-4: Recovering a Data File in Your Primary Database
(continued)
[oracle@edt3r17p0-pc00prmy pc00prmy]$ rman

Recovery Manager: Release 11.1.0.6.0 - Production on Fri Feb


15 22:03:42 2008

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

RMAN> connect target sys/oracle@pc00sby1

connected to target database: PC00PRMY (DBID=1159023676, not


open)

RMAN> connect auxiliary sys/oracle@pc00prmy

connected to auxiliary database: PC00PRMY (DBID=1159023676)


7) Back up data file 5 from the physical standby database host to a new location named
/u01/app/oracle/oradata/pc<nn>prmy/newex01.dbf on your primary
database host.
RMAN> backup as copy datafile 5
2> auxiliary format
'/u01/app/oracle/oradata/pc00prmy/newex01.dbf';

Starting backup at 15-FEB-08


using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005
name=/u01/app/oracle/oradata/pc00sby1/example01.dbf
output file name=/u01/app/oracle/oradata/pc00prmy/newex01.dbf
tag=TAG20080215T221757 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:15
Finished backup at 15-FEB-08
8) Exit RMAN.
RMAN> exit

Recovery Manager complete.


[oracle@edt3r17p0-pc00prmy pc00prmy]$
9) Invoke RMAN again. Connect to your primary database as the target and to the
recovery catalog.
[oracle@edt3r17p0-pc00prmy pc00prmy]$ rman target / catalog
rcowner/rcpass@pc00db11
Recovery Manager: Release 11.1.0.6.0 - Production on Fri Feb
15 22:23:08 2008

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

Oracle Database 11g: Data Guard Administration A - 163


Practice 15-4: Recovering a Data File in Your Primary Database
(continued)
connected to target database: PC00PRMY (DBID=1159023676)
connected to recovery catalog database
RMAN>
10) Catalog the data file copy that you made in step 7 in the recovery catalog.
RMAN> catalog datafilecopy
'/u01/app/oracle/oradata/pc00prmy/newex01.dbf';

starting full resync of recovery catalog


full resync complete
cataloged datafile copy
datafile copy file
name=/u01/app/oracle/oradata/pc00prmy/newex01.dbf RECID=8
STAMP=646784724

RMAN>

11) Use the RMAN SET NEWNAME and SWITCH DATAFILE commands to update the
data file name in the RMAN repository.
RMAN> run {
2> set newname for datafile 5 to
'/u01/app/oracle/oradata/pc00prmy/newex01.dbf';
3> switch datafile 5;
4> }

executing command: SET NEWNAME

RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03009: failure of switch command on default channel at
02/15/2008 22:27:20
ORA-19623: file 5 is open

12) Take the tablespace offline to perform step 11. Take the EXAMPLE tablespace offline.
RMAN> sql ‘alter tablespace example offline immediate’;

sql statement: alter tablespace example offline immediate

13) Try once again to execute the SET NEWNAME and SWITCH DATAFILE commands.
RMAN> run {
2> set newname for datafile 5 to
'/u01/app/oracle/oradata/pc00prmy/newex01.dbf';
3> switch datafile 5;
4> }

Oracle Database 11g: Data Guard Administration A - 164


Practice 15-4: Recovering a Data File in Your Primary Database
(continued)
executing command: SET NEWNAME

datafile 5 switched to datafile copy


input datafile copy RECID=8 STAMP=646784724 file
name=/u01/app/oracle/oradata/pc00prmy/newex01.dbf
starting full resync of recovery catalog
full resync complete

14) Bring the EXAMPLE tablespace back online.


RMAN> sql ‘alter tablespace example online’;
sql statement: alter tablespace example online
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03009: failure of sql command on default channel at
09/17/2008 22:11:08
RMAN-11003: failure during parse/execution of SQL statement:
alter tablespace example online
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5:
'/u01/app/oracle/oradata/pc02prmy/newex01.dbf'

RMAN>

15) Because you took the tablespace offline with the IMMEDIATE option, you must
recover the tablespace. Recover the EXAMPLE tablespace.
RMAN> recover tablespace example;
Starting recover at 17-SEP-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=115 device type=DISK

starting media recovery


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

Finished recover at 17-SEP-08


RMAN>
16) Again try to bring the EXAMPLE tablespace online. Exit from RMAN.
RMAN> sql ‘alter tablespace example online’;
sql statement: alter tablespace example online

RMAN> exit

Recovery Manager complete.

Oracle Database 11g: Data Guard Administration A - 165


Practice 15-4: Recovering a Data File in Your Primary Database
(continued)
17) Invoke SQL*Plus and connect as the HR user. Query HR.EMPLOYEES again.
SQL> select count(*) from employees;

COUNT(*)
----------
107

Oracle Database 11g: Data Guard Administration A - 166


Practices for Lesson 16: Managing Client Connectivity
In the practices for Lesson 16, “Managing Client Connectivity,” you implement client
failover methods.

Oracle Database 11g: Data Guard Administration A - 167


Practice 16-1: Creating a Service
In this practice, you create a service.
1) Change to the labs directory. Invoke SQL*Plus on your primary database host and
connect as the SYSDBA user.
2) View the value of the SERVICE_NAMES initialization parameter.
SQL> show parameter service_names

NAME TYPE VALUE


-------------- ------- ----------------------
service_names string pc00prmy.us.oracle.com

3) Create a service named PC<nn>PROD by using the


DBMS_SERVICE.CREATE_SERVICE procedure. You can use the
create_service.sql script after verifying that the service_name and
network_name values are set appropriately for your configuration.
SQL> set echo on
SQL> @create_service
SQL> exec DBMS_SERVICE.CREATE_SERVICE( -
> service_name => 'PC00PROD', -
> network_name => 'PC00PROD', -
> failover_method => 'BASIC', -
> failover_type => 'SELECT', -
> failover_retries => 180, -
> failover_delay => 1);

PL/SQL procedure successfully completed.

4) Check to see if the listener knows about the new service by executing the lsnrctl
services command. Although you created the service, you have not yet started it,
so the listener does not know about it.
SQL> host
[oracle@edt3r17p0-pc00prmy labs]$ lsnrctl services

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 18-FEB-


2008 23:21:25

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

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary...
Service "pc00db11.us.oracle.com" has 1 instance(s).
Instance "pc00db11", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready

Oracle Database 11g: Data Guard Administration A - 168


Practice 16-1: Creating a Service (continued)
5) Return to your SQL*Plus session. Start the PC<nn>PROD service by executing the
DBMS_SERVICE.START_SERVICE procedure.
[oracle@edt3r17p0-pc00prmy labs]$ exit
exit

SQL> exec dbms_service.start_service('PC00PROD');

PL/SQL procedure successfully completed.


6) Check the value of the SERVICE_NAMES initialization parameter again.
SQL> show parameter service_names

NAME TYPE VALUE


------------- ------ --------------------------------
service_names string pc00prmy.us.oracle.com, PC00PROD
7) Check again to see if the listener knows about the new service by executing the
lsnrctl services command. The listener now knows about the PC<nn>PROD
service.
SQL> host
[oracle@edt3r17p0-pc00prmy labs]$ lsnrctl services

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 18-FEB-


2008 23:27:51

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

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary...
Service "PC00PROD.us.oracle.com" has 1 instance(s).
Instance "pc00prmy", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:8 refused:0 state:ready
LOCAL SERVER

Oracle Database 11g: Data Guard Administration A - 169


Practice 16-2: Creating an AFTER STARTUP Trigger
In this practice, you create a trigger that executes when the database is opened.
1) In your SQL*Plus session on your primary database host, create an AFTER
STARTUP trigger. You can use the create_trigger.sql script. Be sure to
verify that the service name is correct in the script.
SQL> set echo on
SQL> @create_trigger
SQL> CREATE OR REPLACE TRIGGER manage_service after startup on
database
2 DECLARE
3 role VARCHAR(30);
4 BEGIN
5 SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
6 IF role = 'PRIMARY' THEN
7 DBMS_SERVICE. START_SERVICE ('PC00PROD');
8 ELSE
9 DBMS_SERVICE. STOP_SERVICE ('PC00PROD');
10 END IF;
11 END;
12 /

Trigger created.

SQL>

Oracle Database 11g: Data Guard Administration A - 170


Practice 16-3: Creating an Oracle Net Service Name on Your
Primary Database Host
In this practice, you define a new Oracle Net service name on your primary database
host.
1) Invoke Oracle Net Manager on your primary database system.
2) Expand Local. Select Service Naming and click the green plus sign.
3) Enter pc<nn>prod in the Net Service Name field and click Next.
4) Select TCP/IP (Internet Protocol) and click Next.
5) Enter the fully qualified host name of the machine that your primary database is on.
Click Next.
6) Enter pc<nn>prod.us.oracle.com in the Service Name field and click Next.
7) Click Finish.
8) Click the green plus sign in the Address Configuration section.

9) On the Address 2 tab, enter the fully qualified host of the machine that your physical
standby database is on. Enter 12001 in the Port Number field.

Oracle Database 11g: Data Guard Administration A - 171


Practice 16-3: Creating an Oracle Net Service Name on Your
Primary Database Host (continued)

10) Select File > Save Network Configuration to save the information to the
tnsnames.ora file.
11) Exit Oracle Net Manager.
12) Ensure that your updated $ORACLE_HOME/network/admin/tnsnames.ora
file contains an entry similar to the following for PC<nn>PROD.
PC00PROD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p0.us.oracle.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p2.us.oracle.com)(PORT = 12001))
)
(CONNECT_DATA =
(SERVICE_NAME = pc00prod.us.oracle.com)
)
)

Oracle Database 11g: Data Guard Administration A - 172


Practice 16-4: Creating an Oracle Net Service Name on Your
Standby Database Host
In this practice, you create a new Oracle Net service name on your physical standby
database host.
1) Invoke Oracle Net Manager on your physical standby database system.
2) Expand Local. Select Service Naming and click the green plus sign.
3) Enter pc<nn>prod in the Net Service Name field and click Next.
4) Select TCP/IP (Internet Protocol) and click Next.
5) Enter the fully qualified host name of the machine that your primary database is on.
Click Next.
6) Enter pc<nn>prod.us.oracle.com in the Service Name field and click Next.
7) Click Finish.
8) Click the green plus sign in the Address Configuration section.
9) On the Address 2 tab, enter the fully qualified host of the machine that your physical
standby database is on. Enter 12001 in the port number field.
10) Select File > Save Network Configuration to save the information to the
tnsnames.ora file.
11) Exit Oracle Net Manager.
12) Ensure that your updated $ORACLE_HOME/network/admin/tnsnames.ora
file contains an entry similar to the following for PC<nn>PROD.
PC00PROD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p0.us.oracle.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST =
edt3r17p2.us.oracle.com)(PORT = 12001))
)
(CONNECT_DATA =
(SERVICE_NAME = pc00prod.us.oracle.com)
)
)

Oracle Database 11g: Data Guard Administration A - 173


Practice 16-5: Testing Your Implementation
In this practice, you test your implementation of client failover.
1) In your SQL*Plus session on your primary database host, create a user named
DGTEST with a password of DGTEST. Grant CREATE SESSION and
SELECT_CATALOG_ROLE to DGTEST.
SQL> create user dgtest identified by dgtest;

User created.

SQL> grant create session to dgtest;

Grant succeeded.

SQL> grant select_catalog_role to dgtest;

Grant succeeded.
2) On your physical standby database host, connect to the primary database as the
DGTEST user by using the pc<nn>PROD service.
[oracle@edt3r17p2-pc00sby1 labs]$ sqlplus
dgtest/dgtest@pc00prod

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 20


01:16:21 2008

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

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

3) Query V$INSTANCE to determine which host you are connected to.


SQL> select host_name from v$instance;

HOST_NAME
-----------------------------------------------------------
edt3r17p0.us.oracle.com

4) Query V$SESSION to determine how you are connected. You can use the
query_session.sql script.
SQL> select failover_type, failover_method, failed_over
2 from v$session
3 where username = 'DGTEST';

Oracle Database 11g: Data Guard Administration A - 174


Practice 16-5: Testing Your Implementation (continued)
FAILOVER_TYPE FAILOVER_M FAI
------------- ---------- ---
SELECT BASIC NO

5) Return to your primary database host and invoke DGMGRL. Connect as the SYS user
with a password of ORACLE and perform a switchover to your PC<nn>SBY1
database. Exit from DGMGRL.
[oracle@edt3r17p0-pc00prmy labs]$ dgmgrl
DGMGRL for Linux: Version 11.1.0.6.0 - Production

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

Welcome to DGMGRL, type "help" for information.


DGMGRL> connect sys/oracle
Connected.
DGMGRL> switchover to pc00sby1;
Performing switchover NOW, please wait...
New primary database "pc00sby1" is opening...
Operation requires shutdown of instance "pc00prmy" on database
"pc00prmy"
Shutting down instance "pc00prmy"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pc00prmy" on database
"pc00prmy"
Starting instance "pc00prmy"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "pc00sby1"
DGMGRL> exit

6) On your primary database host, check the listener services again. PC<nn>PROD is no
longer listed.
[oracle@edt3r17p0-pc00prmy labs]$ lsnrctl services

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 20-FEB-


2008 01:49:42

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

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary...
Service "pc00db11.us.oracle.com" has 1 instance(s).
Instance "pc00db11", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready

Oracle Database 11g: Data Guard Administration A - 175


Practice 16-5: Testing Your Implementation (continued)
LOCAL SERVER


7) Return to your (original) physical standby database host. In your existing SQL*Plus
session, query V$INSTANCE to determine what host you are now connected to.
SQL> select host_name from v$instance;

HOST_NAME
-----------------------------------------------------------
edt3r17p2.us.oracle.com

8) Query V$SESSION again. You can use the query_session.sql script.


SQL> select failover_type, failover_method, failed_over
2 from v$session
3 where username = 'DGTEST';

FAILOVER_TYPE FAILOVER_M FAI


------------- ---------- ---
SELECT BASIC YES
9) In the SQL*Plus session on your original physical standby database host, view the
value of the SERVICE_NAMES parameter. Exit SQL*Plus.
SQL> show parameter service

NAME TYPE VALUE


------------- --------- --------------------------------
service_names string pc00sby1.us.oracle.com, PC00PROD

10) Execute the lsnrctl services listener1 command on your original standby
database host. Note that PC00PROD is now started on this host.
[oracle@edt3r17p2-pc00sby1 labs]$ lsnrctl services listener1

LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 20-FEB-


2008 01:58:55

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

Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC12001)))
Services Summary...
Service "PC00PROD.us.oracle.com" has 1 instance(s).
Instance "pc00sby1", status READY, has 1 handler(s) for this
service...
Handler(s):
"DEDICATED" established:18 refused:0 state:ready
LOCAL SERVER
11) Return to your (original) primary database host and log in to SQL*Plus as the
SYSDBA user. View the value of the SERVICE_NAMES parameter.

Oracle Database 11g: Data Guard Administration A - 176


Practice 16-5: Testing Your Implementation (continued)
SQL> show parameter service

NAME TYPE VALUE


------------- ------- --------------------------------
service_names string pc00prmy.us.oracle.com
12) Exit SQL*Plus.
13) On your original standby database host, invoke DGMGRL again and connect as the
user SYS with password oracle. Perform a switchover to restore your
PC<nn>PRMY database as the primary database.
DGMGRL> switchover to pc00prmy;
Performing switchover NOW, please wait...
New primary database "pc00prmy" is opening...
Operation requires shutdown of instance "pc00sby1" on database
"pc00sby1"
Shutting down instance "pc00sby1"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "pc00sby1" on database
"pc00sby1"
Starting instance "pc00sby1"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "pc00prmy"
14) Verify the status of your configuration. Exit DGMGRL.
DGMGRL> show configuration

Configuration
Name: DGConfig1
Enabled: YES
Protection Mode: MaxAvailability
Databases:
pc00prmy - Primary database
pc00sby1 - Physical standby database

Fast-Start Failover: DISABLED

Current status for "DGConfig1":


SUCCESS

DGMGRL> exit
[oracle@edt3r17p2-pc00sby1 labs]$

15) Return to your primary database window. Log in to SQL*Plus as the SYSDBA user.

Oracle Database 11g: Data Guard Administration A - 177


Practice 16-5: Testing Your Implementation (continued)
16) Stop and delete the PC<nn>PROD service.
SQL> exec dbms_service.stop_service('PC00PROD');

PL/SQL procedure successfully completed.

SQL> exec dbms_service.delete_service('PC00PROD');

PL/SQL procedure successfully completed.

17) Drop the DGTEST user.


SQL> drop user dgtest;
User dropped.
18) Drop the MANAGE_SERVICE trigger.
SQL> drop trigger manage_service;
Trigger dropped.

Oracle Database 11g: Data Guard Administration A - 178


Practices for Lesson 17: Patching and Upgrading
Databases in a Data Guard Configuration
There are no practices for Lesson 17, “Patching and Upgrading Databases in a Data
Guard Configuration.”

Oracle Database 11g: Data Guard Administration A - 179


Practice 16-5: Testing Your Implementation (continued)

Oracle Database 11g: Data Guard Administration A - 180

Das könnte Ihnen auch gefallen