Showing posts with label RMAN. Show all posts
Showing posts with label RMAN. Show all posts

Thursday, March 27, 2014

Create a physical standby database through RMAN duplicate active data files

I have a very small database ( ~ 5GB) called etsdb, which hosts an Oracle APEX application called DBAETS for DBA team internal use.

In the past, as a better-than-nothing backup and disaster recovery strategy, I export it every night and ship the export dump file to a remote server. Now I decide to create a physical standby database at the same remote server for it.

The transaction volumn of this application is typically very low as at any given time there could be just two or three DBAs logged into it to update some info. So it is ideal to use RMAN active database duplication technique to create the physical standby. In this method, RMAN duplicate process copies the active data files of the primary database directly to the remote host through network. RMAN supports two basic types of duplication: active database duplication and backup-based duplication. Oracle online documentation has a section about the considerations  to choose duplication technique.


I describe the steps involved in the following:

1. Prepare the production database to be the primary database

a. Ensure that the database is in archivelog mode

b. Enable force logging

    SQL> ALTER DATABASE FORCE LOGGING;

c. Create standby redologs

     SQL> alter database add standby logfile '/db2st2/u01/oradata/etsdb/stby_redo01.rdo' size 100M;

d. Modify the primary initialization parameter for dataguard on primary,
         
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(etsdb,ettdb)';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=/db2st2/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=etsdalter system set LOG_ARCHIVE_DEST_2='SERVICE=ettdb LGWR ASYNC VALID_FOR=(online_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME=ettdb';
alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;
alter system set FAL_SERVER=ettdb;
alter system set FAL_CLIENT=etsdb;
alter system set DB_FILE_NAME_CONVERT='/db2st2/u01/oradata/etsdb','/db2/u01/oradata/ettdb' scope=spfile;
alter system set LOG_FILE_NAME_CONVERT='/db2st2/u01/oradata/etsdb','/db2/u01/oradata/ettdb', '/db2st2/u02/oradata/etsdb','/db2/u02/oradata/ettdb' scope=spfile;

2. Ensure that the sql*net connectivity is working fine.

Configure the listener in standby and put the following tns entries in tnsnames.ora:
 ettdb =
   (DESCRIPTION =
     (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = standby_server)(PORT = 1523))
     )
     (CONNECT_DATA =
       (SERVICE_NAME = ettdb )
     )
   )
  
 etsdb =
   (DESCRIPTION =
     (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = primary_server)(PORT = 1521))
     )
     (CONNECT_DATA =
       (SERVICE_NAME = etsdb )
     )
   )
Confirm that tnsping ettdb and tnsping etsdb work on both primary and standby sites

3. Create the standby database

a. Copy the password file from the primary $ORACLE_HOME/dbs and rename it to the standby database name.

The username is required to be SYS and the password needs to be the same on the Primary and Standby. The best practice for this is to copy the passwordfile as suggested. The password file name must match the instance name/SID used at the standby site, not the DB_NAME.

orapwetsdb ----> orapwettdb

b. Create a initialization parameter with only one parameter DB_NAME.
  
 -- initettdb.ora 
 DB_NAME=etsdb
 DB_UNIQUE_NAME=ettdb
 DB_BLOCK_SIZE=8192

c. Create the necessary directories in the standby location to place the datafiles and the trace files in the $ADR_HOME.

d. Set the environment variable ORACLE_SID to the standby service and start the standby-instance.
 % export ORACLE_SID=ettdb
 % sqlplus "/ as sysdba"
 SQL> startup nomount pfile=$ORACLE_HOME/dbs/initettdb.ora

e. Verify if the connection 'AS SYSDBA' is working
  sqlplus sys@ettdb as sysdba
  sqlplus sys@etsdb as sysdba

f. On the primary system invoke the RMAN executable and connect to the primary and the auxiliary database ( i.e., the standby)

$ rman target sys/xxx@etsdb auxiliary sys/xxx@ettdb cmdfile=dup.rmn

content of dup.rmn :
duplicate target database for standby from active database
spfile
parameter_value_convert 'etsdb','ettdb'
set db_unique_name='ettdb'
set db_file_name_convert='/db2st2/u01/oradata/etsdb','/db2/u01/oradata/ettdb','/db2st2','/db2'
set log_file_name_convert='/db2st2/u01/oradata/etsdb','/db2/u01/oradata/ettdb', '/db2st2/u02/oradata/etsdb','/db2/u02/oradata/ettdb'
set control_files='/db2/u01/oradata/ettdb/control01.ctl'
set log_archive_dest_1 =  'LOCATION=/db2/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ettdb' 
set log_archive_max_processes='5'
set fal_client='ettdb'
set fal_server='etsdb'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(etsdb,ettdb)'
set log_archive_dest_2='service=etsdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=etsdb'
;

4. Connect to standby using SQL*Plus and start the MRP ( Managed Recovery Process)

-- mount db first if required

alter database recover managed standby database disconnect from session;

5. If licensed and want to use Active Dataguard (ADG), than open the Standby Database in READ ONLY and start the revoer

Enable Active Data Guard using SQL Plus :

SQL> alter database recover managed standby database cancel;
SQL> alter database open read only;
SQL> alter database recover managed standby database disconnect using current logfile;

-- verify
SQL> select name, db_unique_name, database_role, open_mode from v$database;
 
NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE
--------- ------------------------------ ---------------- --------------------
ETSDB     ettdb                          PHYSICAL STANDBY READ ONLY WITH APPLY


testing to confirm that standby db can be read and meanwhile redo logs are being applied:
in standby

create table dbaets.t as select * from all_objects
                                       *
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database open for read-only access
 


in primary

  1* select thread#, max(sequence#) from v$log_history group by thread#
SQL> /
 
   THREAD# MAX(SEQUENCE#)
---------- --------------
         1           1057
 
SQL> create table dbaets.t as select * from all_objects;
 
Table created.
 
SQL> alter system archive log current;
 
System altered.
 
SQL> select thread#, max(sequence#) from v$log_history group by thread#
  2  ;
 
   THREAD# MAX(SEQUENCE#)
---------- --------------
         1           1058


in standby:



SQL> select thread#, max(sequence#) from v$log_history group by thread#;
 
   THREAD# MAX(SEQUENCE#)
---------- --------------
         1           1058


SQL> select count(*) from dbaets.t;
 
  COUNT(*)
----------
     17855

References:

Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE (Doc ID 1075908.1)

RMAN duplicate: http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmdupdb.htm#BRADV298

Wednesday, November 14, 2007

RMAN spool log to example

Never know can do this before in RMAN prompt:


NTBK-/home/Denis/e_oracle/Practise_Oracle/temp>rman

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Nov 14 11:02:04 2007

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

RMAN> connect target

connected to target database: ORCL (DBID=1151466663)

RMAN> spool log to temp.log;
RMAN> show all;
RMAN> exit;
NTBK-/home/Denis/e_oracle/Practise_Oracle/temp>cat temp.log

Spooling started in log file: temp.log

Recovery Manager10.2.0.1.0

RMAN>
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\SE

RMAN>

Recovery Manager complete.

Monday, October 08, 2007

Execute OS command in RMAN

Here are the examples, the key is to use single quotation mark:

RMAN> host 'ls -l';

total 12
-rw-r--r-- 1 Denis None 801 Oct 2 15:24 README
-rw-r--r-- 1 Denis None 176 Sep 23 20:45 flsharea_chk.sql
-rw-r--r-- 1 Denis None 64 Sep 23 13:32 lvl_0_bkup.cmd
-rw-r--r-- 1 Denis None 37 Sep 23 13:42 lvl_0_bkup_nocomp.cmd
-rw-r--r-- 1 Denis None 64 Sep 23 20:02 lvl_1_bkup.cmd
-rwxr-xr-x 1 Denis None 1704 Oct 2 15:14 sqlnet.log
host command complete

RMAN> host 'pwd';

/cygdrive/e/Denis_Files/ORACLE/Practise_Oracle/flash_recv_area_rman10g
host command complete

Sunday, October 07, 2007

RMAN : tablespace point-in-time recovery

I have been asked a question about how to recover a table to a point in the past time using RMAN. I response by saying if in Oracle 10g, we can use Flashback technology. But if using RMAN is only option, we can do tablespace point-in-time recovery(TSPITR). However I was unable to describe the clear conceptual steps about TSPITR. Here I did a test based on the document.

The test case assumes there is only one table: AUTO_TABLE in the tablespace AUTO_TBS.

The situation could be more complicated than what will be shown below if there are other tables in the tablespace that have been updated after the target time to which the tablespace will be recovered.

ref: http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/rcmtspit002.htm#i1010246

1. Information about the auto_table

a. auto_table resides in the AUTO_TBS tablespace

TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
.....
AUTO_TABLE AUTO_TBS


b. Number of rows

scott@ORCL> select count(*) from auto_table;

COUNT(*)
----------
66065

c. Timestamp just before truncate

scott@ORCL> select sysdate from dual;

SYSDATE
--------------------
07-OCT-2007 19:43:11

scott@ORCL> truncate table auto_table;

Table truncated.

The objective is to recover the auto_table to the point before the truncate.

2. Planing and Preparing for TSPITR


2.1 Choosing the Right Target Time for TSPITR
07-OCT-2007 19:43:11


2.2 Determining the Recovery Set: Analyzing Data Relationships

SELECT *
FROM SYS.TS_PITR_CHECK
WHERE (
TS1_NAME IN ('AUTO_TBS')
AND TS2_NAME NOT IN ('AUTO_TBS')
)
OR (
TS1_NAME NOT IN ('AUTO_TBS')
AND TS2_NAME IN ('AUTO_TBS')
);

Note: There are no complications for this case - no dependencies of auto_table on other objects in auto_tbs or other tablespaces

2.3 Identifying and Preserving Objects That Will Be Lost After TSPITR

SELECT OWNER, NAME, TABLESPACE_NAME,
TO_CHAR(CREATION_TIME, 'YYYY-MM-DD:HH24:MI:SS')
FROM TS_PITR_OBJECTS_TO_BE_DROPPED
WHERE TABLESPACE_NAME IN ('AUTO_TBS')
AND CREATION_TIME > TO_DATE('07-OCT-2007 19:43:11','YY-MON-DD:HH24:MI:SS')
ORDER BY TABLESPACE_NAME, CREATION_TIME;

Note:
You can preserve such objects, once they are identified, by exporting them before TSPITR using an Oracle export utility (Data Pump Export or Original Export) and re-importing them afterwards using the corresponding import utility.

In this case, we don't have any such objects.

3. Performing Basic RMAN TSPITR

Three options:

A. Fully automated TSPITR
B. Customized TSPITR with an automatic auxiliary instance
C. TSPITR with your own auxiliary instance

3.1 Take the tablespace AUTO_TBS offline

sys@ORCL> alter tablespace auto_tbs offline;

Tablespace altered.

3.2 Rocover using 'Fully automated TSPITR'

Note: Using an Auxiliary Destination for Automated RMAN TSPITR
e:\auxdest

start the RMAN client, connecting to the target database and, if applicable, a recovery catalog.

The following is the RMAN command:

RMAN> RECOVER TABLESPACE auto_tbs
2> UNTIL TIME '07-OCT-2007 19:43:11'
3> AUXILIARY DESTINATION 'e:\auxdest'
4> ;


Appendix A shows the full RMAN screen output.

3.3 Backing Up Recovered Tablespaces After TSPITR
RMAN> BACKUP TABLESPACE AUTO_TBS

3.4 Bring the tablespaces online, as follows:

RMAN> SQL "ALTER TABLESPACE AUTO_TBS ONLINE";


Appendix A:

===========

RMAN> RECOVER TABLESPACE auto_tbs
2> UNTIL TIME '07-OCT-2007 19:43:11'
3> AUXILIARY DESTINATION 'e:\auxdest'
4> ;
Starting recover at 07-OCT-2007 20:10:36
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time

List of tablespaces expected to have UNDO segments
tablespace SYSTEM
tablespace UNDOTBS1
tablespace UNDO_BATCH

Creating automatic instance, with SID='aFbc'

initialization parameters used for automatic instance:
db_name=ORCL
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_ORCL_aFbc
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=e:\auxdest
control_files=e:\auxdest/cntrl_tspitr_ORCL_aFbc.f


starting up automatic instance ORCL

Oracle instance started

Total System Global Area 201326592 bytes

Fixed Size 1248092 bytes
Variable Size 146801828 bytes
Database Buffers 50331648 bytes
Redo Buffers 2945024 bytes
Automatic instance created

contents of Memory Script:
{
# set the until clause
set until time "07-OCT-2007 19:43:11";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log for tspitr to a resent until time
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script

executing command: SET until clause

Starting restore at 07-OCT-2007 20:12:09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece E:\ORAFLASH\ORCL\BACKUPSET\2007_10_07\O1_MF_NCSN0_TAG2007100
LND6K2_.BKP
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=E:\ORAFLASH\ORCL\BACKUPSET\2007_10_07\O1_MF_NCSN0_TAG20071007T173142_3JLND6K2_.BKP tag=TAG2007100
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:05
output filename=E:\AUXDEST\CNTRL_TSPITR_ORCL_AFBC.F
Finished restore at 07-OCT-2007 20:12:48

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
released channel: ORA_DISK_1
released channel: ORA_AUX_DISK_1

contents of Memory Script:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until time "07-OCT-2007 19:43:11";
# set an omf destination filename for restore
set newname for clone datafile 1 to new;
# set an omf destination filename for restore
set newname for clone datafile 2 to new;
# set an omf destination filename for restore
set newname for clone datafile 8 to new;
# set an omf destination tempfile
set newname for clone tempfile 1 to new;
# set a destination filename for restore
set newname for datafile 6 to
"E:\ORADATA\ORCL\AUTO_TBS_DATA01.DBF";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile 1, 2, 8, 6;
switch clone datafile all;
#online the datafiles restored or flipped
sql clone "alter database datafile 1 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 2 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 8 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 6 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace "AUTO_TBS", "SYSTEM", "UNDOTBS1", "UNDO_BATCH" delete archivelog;
alter clone database open resetlogs;
# PLUG HERE the creation of a temporary tablespace if export fails due to lack
# of temporary space.
# For example in Unix these two lines would do that:
#sql clone "create tablespace aux_tspitr_tmp
# datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K";
}
executing Memory Script
executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed temporary file 1 to E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_TEMP_%U_.TMP in control file

Starting restore at 07-OCT-2007 20:16:10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=39 devtype=DISK

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_SYSTEM_%U_.DBF
restoring datafile 00002 to E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_UNDOTBS1_%U_.DBF
restoring datafile 00008 to E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_UNDO_BAT_%U_.DBF
restoring datafile 00006 to E:\ORADATA\ORCL\AUTO_TBS_DATA01.DBF
channel ORA_AUX_DISK_1: reading from backup piece E:\ORAFLASH\ORCL\BACKUPSET\2007_10_07\O1_MF_NNND0_TAG20071007T173142_3J
LN26F5_.BKP
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=E:\ORAFLASH\ORCL\BACKUPSET\2007_10_07\O1_MF_NNND0_TAG20071007T173142_3JLN26F5_.BKP tag=TAG20071007T173142
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:06:26
Finished restore at 07-OCT-2007 20:23:10

datafile 1 switched to datafile copy
input datafile copy recid=9 stamp=635372617 filename=E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_SYSTEM_3JLXQD89_.DBF
datafile 2 switched to datafile copy
input datafile copy recid=10 stamp=635372617 filename=E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_UNDOTBS1_3JLXQDRW_.DBF
datafile 8 switched to datafile copy
input datafile copy recid=11 stamp=635372618 filename=E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_UNDO_BAT_3JLXQF00_.DBF

sql statement: alter database datafile 1 online

sql statement: alter database datafile 2 online

sql statement: alter database datafile 8 online

sql statement: alter database datafile 6 online

Starting recover at 07-OCT-2007 20:24:23
using channel ORA_AUX_DISK_1
using channel ORA_AUX_DISK_1

starting media recovery

archive log thread 1 sequence 9 is already on disk as file E:\ORAFLASH\ORCL\ARCHIVELOG\2007_10_07\O1_MF_1_9_3JLOS56T_.ARC

archive log thread 1 sequence 10 is already on disk as file E:\ORAFLASH\ORCL\ARCHIVELOG\2007_10_07\O1_MF_1_10_3JLXKK6T_.A
RC
archive log filename=E:\ORAFLASH\ORCL\ARCHIVELOG\2007_10_07\O1_MF_1_9_3JLOS56T_.ARC thread=1 sequence=9
archive log filename=E:\ORAFLASH\ORCL\ARCHIVELOG\2007_10_07\O1_MF_1_10_3JLXKK6T_.ARC thread=1 sequence=10
media recovery complete, elapsed time: 00:00:13
Finished recover at 07-OCT-2007 20:25:37

database opened

contents of Memory Script:
{
# export the tablespaces in the recovery set
host 'exp userid =\"/@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=oracle)(ARGV0=oracleaFbc)(ARGS=^'(DESCRIPTION=(LOCAL=Y
ES)(ADDRESS=(PROTOCOL=beq)))^')(ENVS=^'ORACLE_SID=aFbc^'))(CONNECT_DATA=(SID=aFbc))) as sysdba\" point_in_time_recover=y
tablespaces=
AUTO_TBS file=
tspitr_a.dmp';
# shutdown clone before import
shutdown clone immediate
# import the tablespaces in the recovery set
host 'imp userid =\"/@ as sysdba\" point_in_time_recover=y file=
tspitr_a.dmp';
# online/offline the tablespace imported
sql "alter tablespace AUTO_TBS online";
sql "alter tablespace AUTO_TBS offline";
# enable autobackups in case user does open resetlogs from RMAN after TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script


Export: Release 10.2.0.1.0 - Production on Sun Oct 7 20:26:49 2007

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


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
Note: table data (rows) will not be exported

About to export Tablespace Point-in-time Recovery objects...
For tablespace AUTO_TBS ...
. exporting cluster definitions
. exporting table definitions
. . exporting table AUTO_TABLE
. exporting referential integrity constraints
. exporting triggers
. end point-in-time recovery
Export terminated successfully without warnings.
host command complete

database closed
database dismounted
Oracle instance shut down


Import: Release 10.2.0.1.0 - Production on Sun Oct 7 20:30:59 2007

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


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
About to import Tablespace Point-in-time Recovery objects...
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
. importing SYS's objects into SYS
. importing SCOTT's objects into SCOTT
. . importing table "AUTO_TABLE"
. importing SYS's objects into SYS
Import terminated successfully without warnings.
host command complete

sql statement: alter tablespace AUTO_TBS online

sql statement: alter tablespace AUTO_TBS offline

sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;

Removing automatic instance
Automatic instance removed
auxiliary instance file E:\AUXDEST\CNTRL_TSPITR_ORCL_AFBC.F deleted
auxiliary instance file E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_SYSTEM_3JLXQD89_.DBF deleted
auxiliary instance file E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_UNDOTBS1_3JLXQDRW_.DBF deleted
auxiliary instance file E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_UNDO_BAT_3JLXQF00_.DBF deleted
auxiliary instance file E:\AUXDEST\TSPITR_O\DATAFILE\O1_MF_TEMP_3JLY97MK_.TMP deleted
auxiliary instance file E:\AUXDEST\TSPITR_O\ONLINELOG\O1_MF_1_3JLY8G4W_.LOG deleted
auxiliary instance file E:\AUXDEST\TSPITR_O\ONLINELOG\O1_MF_2_3JLY8OX9_.LOG deleted
auxiliary instance file E:\AUXDEST\TSPITR_O\ONLINELOG\O1_MF_3_3JLY8WJM_.LOG deleted
Finished recover at 07-OCT-2007 20:32:10

RMAN>

Tuesday, October 02, 2007

OCP Oracle 10g Admin II - Ch 4: Database Recovery

Chapter 4 - Database Recovery
Review Questions

1. What is another name for RMAN-based database recovery?
A. User-managed recovery
B. Server-managed recovery
C. Traditional recovery
D. Database recovery
--
Ans: B. Server-managed recovery is another name for RMAN recovery because the server
session performs the recovery process as it interacts with the target database.

2. What command is responsible for automating the backup of control files?
A. ALTER DATABASE CONTROLFILE AUTOBACKUP ON
B. ALTER SYSTEM CONTROLFILE AUTOBACKUP ON
C. CONFIGURE CONTROLFILE AUTOBACKUP ON
D. ENABLE CONTROLFILE AUTOBACKUP
---
Ans: C.
The control file autobackup is enabled by setting parameters within RMAN by
using CONFIGURE CONTROLFILE AUTOBACKUP ON.

3. What is the process to recover a control file?
A. Start up database, restore control file, start up mount the database, recover the database, and open the database.
B. Start up mount, restore control file, start up the database, recover the database, and open the database.
C. Start up nomount, restore control file, start up mount the database, recover the database, and open the database.
D. Start up force, restore control file, start up the database, recover the database, and open the database.
---
Ans: C.
The database needs to be started in NOMOUNT mode because there is not a control file available to MOUNT the database. Next, the control file can be restored. Once a restored control file is available, the database can be started in MOUNT mode so that standard database recovery can continue. When recovery is complete, the database can OPEN for normal use.

4. When recovering a control file without the recovery catalog, what special step must be performed to identify the target database? (Choose all that apply.)
A. You must CONNECT TARGET / to the target database within RMAN.
B. You must STARTUP MOUNT the database because the control file is missing.
C. You must SET DBID to the target database so that the target database can be identified without the control file available.
D. You must CONNECT TARGET database name to the target database within RMAN.
---
ANs: A, C.
The target database is not identifiable by database name without the control
file. So you must first use the CONNECT TARGET / command to connect. The target
database needs to be identified by the database identifier (DBID) number with the
command SET DBID database identifier. This database identifier number denotes the
target database. When you are recovering the control file, the target database
identification is not available because it is stored in the control file.

5. After you restore the control file, what must you do before you execute the RECOVER command to apply archive logs?
A. The database must be restored with the RESTORE command.
B. The database must be reconnected with the CONNECT TARGET database name command.
C. The database must be started in MOUNT mode.
D. The database must open for use with ALTER DATABASE OPEN command.
----
Ans: C. The database must be mounted before the RECOVER command can be executed.
You first must restore control so you can MOUNT the database.

6. Which of the following methods should you use for creating a control file?
(Choose all that apply.)
A. Dump the control file information to a trace file.
B. Use the ALTER DATABASE BACKUP CONTROLFILE TO TRACE command.
C. Use the CREATE CONTROLFILE command.
D. None of the above.
---
Ans: A, B.
The ALTER DATABASE BACKUP CONTROL FILE TO TRACE command creates a
user trace file, which stores an ASCII representation of the binary control file.

7. What are the two cases defined in the backup control file? (Choose two.)
A. ALTER DATABASE OPEN
B. ALTER DATABASE OPEN RESETLOGS
C. ALTER DATABASE OPEN NORESETLOGS
D. ALTER DATABASE OPEN NORESET
---
Ans: B, C.
The two cases in the backup control file are opening the database with RESETLOGS or NORESETLOGS.

8. Which files need to be available and in the matching location of the ASCII
control file in order to rebuild the control file? (Choose all that apply.)
A. Server file, PFILE or SPFILE
B. Datafiles
C. Control files
D. Redo logs
---
Ans: A, B.
The server file, SPFILE or PFILE must be available to start the database with the right parameters, and the datafiles must be in the location matching the control file. The redo logs and control file will be rebuilt.

9. Which of the following descriptions best describes incomplete recovery?
(Choose all that apply.)
A. Recovery that stops before the failure
B. Recovery that stops at the point of failure
C. Recovery that is missing transactions
D. Recovery that is not missing transactions
----
Ans: A, C.
Incomplete recovery is a recovery that stops before the failure and a recovery
that is missing transactions. Incomplete recovery is not complete or missing some
data that was previously stored in the database prior to the failure.

10. What are the required steps to perform a RMAN-based incomplete recovery with the SET UNTIL TIME clause?
A. Start up the database in MOUNT mode, verify or set the NLS_DATE_FORMAT environment variable, designate time with the SET
UNTIL TIME time stamp, restore the necessary files with the RESTORE DATABASE command, recover the database with the RECOVER DATABASE command, and then open the database with the ALTER DATABASE OPEN
command.

B. Start up the database in NOMOUNT mode, verify or set the NLS_DATE_FORMAT environment variable, designate the SET UNTIL TIME time stamp, restore the necessary files with the RESTORE DATABASE command, recover the database with the RECOVER DATABASE command, and then open the database with the ALTER DATABASE OPEN
RESETLOGS command.

C. Start up the database in MOUNT mode, designate the SET UNTIL TIME time stamp, restore the necessary files with the RESTORE DATABASE command, recover the database with the RECOVER DATABASE command, and then open the database with ALTER DATABASE OPEN NORESETLOGS command.

D. Start up the database in MOUNT mode, verify or set the NLS_DATE_FORMAT environment variable, designate the SET UNTIL TIME time stamp, restore the necessary files with the RESTORE DATABASE command, recover the database with the RECOVER DATABASE command, and then open the database with ALTER DATABASE OPEN RESETLOGS command.
---
Ans: D.
The proper process of performing a RMAN based incomplete recovery utilizing a
time stamp to determine the point-in-time to complete the recovery process is as
follows: Start up the database in MOUNT mode, verify or set the NLS_DATE_FORMAT
environment variable if not present, designate the SET UNTIL TIME time stamp,
restore the necessary files with the RESTORE DATABASE command, recover the
database with the RECOVER DATABASE command, and then open the database with
ALTER DATABASE OPEN RESETLOGS command.

11. Which command is not a valid RMAN incomplete recovery run block?
A. run
{
set until change 7563633;
restore database;
recover database;
}

B. run
{
set until time '06-SEP-2004 11:25:00';
restore database;
recover database;
}

C. run
{
set until SCN 7563633;
restore database;
recover database;
}


D. run
{
set until sequence 3 thread 1;
restore database;
recover database;
}
---
Ans: A.
The SET UNTIL CHANGE command is not used with RMAN. This command is used during a user-managed incomplete recovery.

12. Which of the following would be a reason for using incomplete recovery?
(Choose all that apply.)
A. Stopping the recovery at a certain redo log sequence before a database corruption point
B. Stopping the recovery at a certain time when database corruption occurred
C. Stopping the recovery before a bad transaction is executed
D. Stopping the recovery only after applying all transactions
---
Ans: A, B, C.
Incomplete recovery is designed to be able to stop at a desired point, before introducing undesired transactions to the database.

13. Which incomplete recovery capability is available to RMAN or user-managed methods?
A. SET UNTIL TIME
B. UNTIL TIME
C. UNTIL SCN
D. UNTIL SEQUENCE
---
Ans: B.
The UNTIL TIME clause is available in both user-managed and RMAN-based incomplete recovery methods.

Note: the question should be 'RMAN and user-managed methods?'

14. When performing incomplete recovery, which command allows you to stop the recovery process at a random point?
A. UNTIL SEQUENCE, when performing a user-managed recovery
B. UNTIL SCN, when performing a RMAN-based recovery
C. UNTIL CANCEL, when performing a RMAN-based recovery
D. UNTIL CANCEL, when performing a user-managed recovery
----
Ans: D.
The UNTIL CANCEL command is available only in user-managed recovery. This command allows you to stop the recovery process at a random point during redo log switches.

15. Which command is required when performing an incomplete recovery?
A. ALTER DATABASE OPEN RESETLOGS
B. ALTER DATABASE OPEN NORESETLOGS
C. UNTIL CANCEL
D. ALTER DATABASE OPEN
----
Ans: A.
The ALTER DATABASE OPEN RESETLOGS command is required with every incomplete recovery. This is because the redo log sequence always needs to be reset.

16. When using EM to perform a whole database incomplete recovery, what sequence of events must occur? (Choose the best answer.)
A. The database must be shut down and started in NOMOUNT mode.
B. The database must be started in MOUNT mode.
C. The database must be shut down and started in MOUNT mode.
D. The database must be shut down and restarted.
--
Ans: C.
When using EM, the database must be shut down and started in MOUNT mode so
that a whole database backup can be performed when you are recovering the same
database EM is connected to.

17. Which credentials are needed to perform a recovery with EM? (Choose all that apply.)
A. Database account with SYSDBA privilege
B. Administrator account in Windows
C. Oracle account in Unix
D. Any Windows account
---
Ans: A, B, C.
You need two credentials when running a recovery with EM: the correct operating system account and the correct database account. The correct operating system account is an account similar to the Oracle account in Unix or the administrator account in Windows. The database account is any account that has SYSDBA privilege.

18. The RESETLOGS clause is required with which of the following types of incomplete recovery?
A. Using the UNTIL CANCEL command and applying almost all the archived redo logs before cancelling recovery
B. Using the UNTIL TIME command and stopping before the current time
C. Using the SET UNTIL SEQUENCE command and stopping before the last redo log sequence
D. All of the above
----
Ans: D.
The RESETLOGS clause is required with all incomplete recovery options. The RESETLOGS clause is required because you are opening the database to a point prior to the existing redo log entries. So the redo logs must be reset when the database is opened.


19. What is required to perform a UNTIL SEQUENCE recovery in RMAN?
A. Identifying the sequence number with V$LOGHISTORY
B. Identifying the sequence number with V$LOG_HISTORY
C. Identifying the SCN number with V$LOG_HISTORY
D. Identifying the SCN number with V$LOGHISTORY
----
Ans: B. You need to know the redo log sequence number and thread to perform an UNTIL SEQUENCE recovery in RMAN. This can be obtained by querying the V$LOG_HISTORY dynamic view.

20. What is required to recover your database through a RESETLOGS recovery from a backup created prior to the RESETLOGS recovery?
A. NORESETLOGS
B. RESETLOGS
C. UNTIL SEQUENCE
D. Nothing, this feature is automatic.
---
Ans: D.
The new feature to recover your database through a prior RESETLOGS recovery is native with Oracle 10g. Oracle will recover the database through the RESETLOGS prior to recovery if necessary.

Sunday, September 23, 2007

Oracle 10gR2 - RAMN Compressed backupset

It has been seen the size of compressed backupset is about 17.3% of
that of normal backupset from the following test.

In Lutz Hartmann's blog, it also stated that compression can reduce
the space needed to one-fifth.


Compressed
-----------

RMAN> backup incremental level 0
2> as compressed backupset database;
Starting backup at 23-SEP-2007 13:33:38
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=127 devtype=DISK
channel ORA_DISK_1: starting compressed incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
input datafile fno=00003 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
input datafile fno=00006 name=E:\ORADATA\ORCL\AUTO_TBS_DATA01.DBF
input datafile fno=00007 name=E:\ORADATA\ORCL\MANUAL_TBS_DATA01.DBF
input datafile fno=00002 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
input datafile fno=00005 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
input datafile fno=00004 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
input datafile fno=00008 name=E:\ORADATA\ORCL\UNDO_DATCH01.DBF
channel ORA_DISK_1: starting piece 1 at 23-SEP-2007 13:33:43
channel ORA_DISK_1: finished piece 1 at 23-SEP-2007 13:37:08
piece handle=E:\ORAFLASH\ORCL\BACKUPSET\2007_09_23\O1_MF_NNND0_TAG20070923T133340_3HF8VSTC_.BKP tag=TAG20070923T133340 co
mment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:28
Finished backup at 23-SEP-2007 13:37:09

Starting Control File and SPFILE Autobackup at 23-SEP-2007 13:37:15
piece handle=E:\ORAFLASH\ORCL\AUTOBACKUP\2007_09_23\O1_MF_S_634052241_3HF92WXS_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 23-SEP-2007 13:37:45

RMAN> **end-of-file**

RMAN> exit


non-compressed
---------------

RMAN> backup incremental level 0 database;
Starting backup at 23-SEP-2007 13:42:39
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=128 devtype=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
input datafile fno=00003 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF
input datafile fno=00006 name=E:\ORADATA\ORCL\AUTO_TBS_DATA01.DBF
input datafile fno=00007 name=E:\ORADATA\ORCL\MANUAL_TBS_DATA01.DBF
input datafile fno=00002 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
input datafile fno=00005 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF
input datafile fno=00004 name=C:\ORACLEXE\APP\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF
input datafile fno=00008 name=E:\ORADATA\ORCL\UNDO_DATCH01.DBF
channel ORA_DISK_1: starting piece 1 at 23-SEP-2007 13:42:43
channel ORA_DISK_1: finished piece 1 at 23-SEP-2007 13:48:59
piece handle=E:\ORAFLASH\ORCL\BACKUPSET\2007_09_23\O1_MF_NNND0_TAG20070923T134241_3HF9DPPG_.BKP tag=TAG20070923T134241 co
mment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:06:17
Finished backup at 23-SEP-2007 13:48:59

Starting Control File and SPFILE Autobackup at 23-SEP-2007 13:49:00
piece handle=E:\ORAFLASH\ORCL\AUTOBACKUP\2007_09_23\O1_MF_S_634052940_3HF9RJ7B_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 23-SEP-2007 13:49:08


$ ls -lh
total 1.7G
-rwxrwx---+ 1 Administrators SYSTEM 265M Sep 23 13:37 O1_MF_NNND0_TAG20070923T133340_3HF8VSTC_.BKP
-rwxrwx---+ 1 Administrators SYSTEM 1.5G Sep 23 13:48 O1_MF_NNND0_TAG20070923T134241_3HF9DPPG_.BKP

Saturday, September 08, 2007

Restore a RMAN backup from disk to a new host with different pathname

We have a requirement to restore an 8 months old GENP RMAN backup from tape. In order to be familiar with the procedure, I tested restoring a recent GENP RMAN backup from disk to a new host with different pathname. The steps are outlined as follows:

 

 

1. Copy init.ora from old host to new host

   edit *dump, controlfile

 

2. Copy current controlfile to the new host

 

 

3. Start the instance and mount the database

    startup mount

 

4. Use rman without catalog

   rman target / nocatalog

 

5. Issue following command:

 

run {

     set until time '08-SEP-2007 05:20:02'; 

     allocate channel ch1 type disk;

     allocate channel ch2 type disk;

     set newname for datafile 1          to '/ora01/orabkup/GEN3S/GENP/genp_system01.dbf';

     set newname for datafile 2          to '/ora01/orabkup/GEN3S/GENP/genp_tools01.dbf';

     ( ...  DS: omit 3 - 50)

 

     set newname for datafile 51         to '/ora01/orabkup/GEN3S/GENP/gen_indx_12.dbf';

     set newname for datafile 52         to '/ora01/orabkup/GEN3S/GENP/gen_data_16.dbf';

 

     restore database;

     switch datafile all;  # points the control file to the renamed datafiles

     recover database;

     alter database open resetlogs;

} 

 

 

6.  Failure at 'alter database open resetlogs'

...

 

RMAN-08515: archivelog filename=/ora01/orabkup/GEN3S/GENP1/arch_GENP_000111585.arc thread=1 sequence=111585

RMAN-08515: archivelog filename=/ora01/orabkup/GEN3S/GENP1/arch_GENP_000111586.arc thread=1 sequence=111586

RMAN-08515: archivelog filename=/ora01/orabkup/GEN3S/GENP1/arch_GENP_000111587.arc thread=1 sequence=111587

RMAN-08515: archivelog filename=/ora01/orabkup/GEN3S/GENP1/arch_GENP_000111588.arc thread=1 sequence=111588

RMAN-08055: media recovery complete

 

RMAN-03022: compiling command: alter db

RMAN-03026: error recovery releasing channel resources

RMAN-08031: released channel: ch1

RMAN-08031: released channel: ch2

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

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

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

RMAN-03002: failure during compilation of command

RMAN-03013: command type: alter db

RMAN-06003: ORACLE error from target database: ORA-00344: unable to re-create online log '/ora01/oradata/GENP/genp_redo01a.log'

ORA-27040: skgfrcre: create error, unable to create file

SVR4 Error: 2: No such file or directory

RMAN-06097: text of failing SQL statement: alter database open resetlogs

RMAN-06099: error occurred in source file: krmk.pc, line: 22291

 

RMAN>

RMAN> **end-of-file**

 

 

7. Move the redo log file

   Issue the following statements, after that  database is opened successfully with resetlogs

 

alter database rename file '/ora01/oradata/GENP/genp_redo01a.log' to '/ora01/orabkup/GEN3S/GENP1/genp_redo01a.log';

alter database rename file '/ora01/oradata/GENP/genp_redo02a.log' to '/ora01/orabkup/GEN3S/GENP1/genp_redo02a.log';

alter database rename file '/ora01/oradata/GENP/genp_redo03a.log' to '/ora01/orabkup/GEN3S/GENP1/genp_redo03a.log';

alter database rename file '/ora01/oradata/GENP/genp_redo04a.log' to '/ora01/orabkup/GEN3S/GENP1/genp_redo04a.log';

alter database rename file '/ora01/oradata/GENP/genp_redo05a.log' to '/ora01/orabkup/GEN3S/GENP1/genp_redo05a.log';

alter database rename file '/ora01/oradata/GENP/genp_redo06a.log' to '/ora01/orabkup/GEN3S/GENP1/genp_redo06a.log';

alter database rename file '/ora02/oradata/GENP/genp_redo01b.log' to '/ora01/orabkup/GEN3S/GENP/genp_redo01b.log';

alter database rename file '/ora02/oradata/GENP/genp_redo02b.log' to '/ora01/orabkup/GEN3S/GENP/genp_redo02b.log';

alter database rename file '/ora02/oradata/GENP/genp_redo03b.log' to '/ora01/orabkup/GEN3S/GENP/genp_redo03b.log';

alter database rename file '/ora02/oradata/GENP/genp_redo04b.log' to '/ora01/orabkup/GEN3S/GENP/genp_redo04b.log';

alter database rename file '/ora02/oradata/GENP/genp_redo05b.log' to '/ora01/orabkup/GEN3S/GENP/genp_redo05b.log';

alter database rename file '/ora02/oradata/GENP/genp_redo06b.log' to '/ora01/orabkup/GEN3S/GENP/genp_redo06b.log';

 

 

 

Note: RMAN backup files have been already ftp'ed to the new host

Friday, July 06, 2007

Exercise - Using the control file autobackup to recover from the lost of all control files - Oracle 10g

Environment: Oracle 10gR2

Summary of the testing steps

1. First, configure RMAN to perform a control file autobackup:
2. Next, perform a backup with the control file autobackup enabled:
3. Next, simulate the missing control files by deleting all the control files.
4. Next, start the database in NOMOUNT mode, which is required because there is no control file to mount.
5. Next, connect to RMAN and the target database. Specify the DBID to identify the database you are connecting to
6. Next, restore the control file from backup:
7. Next, mount the database and begin to recover the database:
8. Finally, open the database with RESETLOGS option for normal operations:

Detailed steps:

1. First, configure RMAN to perform a control file autobackup:

RMAN> connect target
connected to target database: TOY10G (DBID=3330944552)
RMAN> configure controlfile autobackup on;
using target database control file instead of recovery catalog

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

RMAN>
RMAN> show all;
RMAN>

RMAN configuration parameters are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
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 CHANNEL DEVICE TYPE DISK FORMAT '/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/backup/test_%t_%s_%p.dbf';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/backup/snapcf_TOY10G.f';


RMAN>

2. Next, perform a backup with the control file autobackup enabled:


RMAN> run
2> {
3> backup database;
4> backup (archivelog all);
5> }

Starting backup at 06-JUL-2007 14:19:13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=35 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/system01.dbf

input datafile fno=00003 name=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/sysaux01.dbf

input datafile fno=00004 name=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/users01.dbf

input datafile fno=00005 name=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/indx01.dbf

input datafile fno=00002 name=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/undotbs01.dbf

channel ORA_DISK_1: starting piece 1 at 06-JUL-2007 14:19:15

channel ORA_DISK_1: finished piece 1 at 06-JUL-2007 14:19:22

piece handle=/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/backup/test_627229154_17_1.dbf tag=TAG20070706T141914 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
Finished backup at 06-JUL-2007 14:19:22
Starting backup at 06-JUL-2007 14:19:25
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=478 recid=1 stamp=627229166
channel ORA_DISK_1: starting piece 1 at 06-JUL-2007 14:19:27
channel ORA_DISK_1: finished piece 1 at 06-JUL-2007 14:19:28
piece handle=/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/backup/test_627229166_18_1.dbf tag=TAG20070706T141926 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 06-JUL-2007 14:19:28
Starting Control File Autobackup at 06-JUL-2007 14:19:28
piece handle=/ora01/orabkup/GENQ/.temp_toy10g/ora01/orarcv/TOY10G/TOY10G/autobackup/2007_07_06/o1_mf_n_627229168_38x5g116_.bkp comment=NONE
Finished Control File Autobackup at 06-JUL-2007 14:19:30

RMAN>

3. Next, simulate the missing control files by deleting all the control files. (The database will need to be shut down to perform this simulated failure.)

sys@TOY10G> select name from v$controlfile;


NAME
----------------------------------------------------------------------------------------------------
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.001.dbf
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.002.dbf
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.003.dbf


after shutdown, do:

rm /ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.001.dbf
rm /ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.002.dbf
rm /ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.003.dbf


4. Next, start the database in NOMOUNT mode, which is required because there is no control file to mount:


idle> conn / as sysdba

Connected to an idle instance.

idle> startup nomount pfile='/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/pfile/initTOY10G.ora';

ORACLE instance started.


5. Next, connect to RMAN and the target database. Specify the DBID to identify the database you are connecting to, because the control file contains this information and failure causes the control file to be unavailable.

RMAN> connect target

connected to target database: TOY10G (not mounted)

RMAN> set dbid 3330944552

executing command: SET DBID

RMAN>

6. Next, restore the control file from backup:

RMAN> restore controlfile from autobackup;
Starting restore at 06-JUL-2007 14:35:11

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=47 devtype=DISK


recovery area destination: /ora01/orabkup/GENQ/.temp_toy10g/ora01/orarcv/TOY10G

database name (or database unique name) used for search: TOY10G

channel ORA_DISK_1: autobackup found in the recovery area

channel ORA_DISK_1: autobackup found: /ora01/orabkup/GENQ/.temp_toy10g/ora01/orarcv/TOY10G/TOY10G/autobackup/2007_07_06/o1_mf_n_627229168_38x5g116_.bkp

channel ORA_DISK_1: control file restore from autobackup complete

output filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.001.dbf

output filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.002.dbf

output filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/control.003.dbf

Finished restore at 06-JUL-2007 14:35:18



RMAN>


7. Next, mount the database and begin to recover the database:
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> recover database;


Starting recover at 06-JUL-2007 14:44:20
Starting implicit crosscheck backup at 06-JUL-2007 14:44:20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=47 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 06-JUL-2007 14:44:22
Starting implicit crosscheck copy at 06-JUL-2007 14:44:22
using channel ORA_DISK_1
Crosschecked 5 objects
Finished implicit crosscheck copy at 06-JUL-2007 14:44:22


searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
File Name: /ora01/orabkup/GENQ/.temp_toy10g/ora01/orarcv/TOY10G/TOY10G/autobackup/2007_07_06/o1_mf_n_627229168_38x5g116_.bkp
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 479 is already on disk as file /ora01/orabkup/GENQ/.temp_toy10g/ora01/oraredo/TOY10G/redo02.log
archive log filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraredo/TOY10G/redo02.log thread=1 sequence=479
media recovery complete, elapsed time: 00:00:03
Finished recover at 06-JUL-2007 14:44:28

RMAN>

8. Finally, open the database with RESETLOGS option for normal operations:

RMAN> alter database open resetlogs;
database opened
RMAN>

Wednesday, June 27, 2007

Duplicating a Database using RMAN

RMAN duplicate command can be used to create a test database by copying a production database. Production database can be online.

The following webpage describes the steps involved:

http://www.oraclenotes.com/dba/BackupRecovery/rman_duplicate.htm

However, in the step 6, it states:

STARTUP NOMOUNT the Target database.

I think here the term ‘target database’ could be misleading, it actually referred to the auxiliary instance.

In the context of RMAN and duplicate command, the terms should be understood as follows:

Target database – existing database which has RMAN backups and to be duplicated

Auxiliary database – the new database to be created.

I have difficulties to figure out how to deal with the following situation:

Target database – replicated, master definition site database

Auxiliary database – a test database, don’t want any replication stuff.

Previously I have worked out a procedure (see Tuesday, May 22, 2007 Post RMAN Refresh tasks -- Remove Replication ) , however, it seems have problems.

Monday, June 25, 2007

RMAN report shema

Just find that RMAN report schema command can be used to report a database’s structure in the past, for example:
RMAN> report schema at time '04-JUN-2007 01:00:00';
RMAN-03022: compiling command: report
Report of database schema
File K-bytes Tablespace RB segs Name
---- ---------- -------------------- ------- -------------------
1 1835008 SYSTEM YES /ora02/oradata/GENQA/genp_system01.dbf
2 1069056 TOOLS NO /ora01/oradata/GENQA/genp_tools01.dbf
3 2097152 RBS YES /ora02/oradata/GENQA/genp_rbs01.dbf
4 4194304 GEN_REP_DATA NO /ora02/oradata/GENXQA/gen_rep_data_05.dbf
5 131072 USERS NO /ora02/oradata/GENQA/genp_users01.dbf
6 491520 INDX NO /ora01/oradata/GENQA/genp_indx01.dbf
7 2097152 RBS YES /ora01/oradata/GENQA/genp_rbs02.dbf
8 4194304 RBS YES /ora02/oradata/GENXQA/genp_rbs03.dbf
9 2097152 GEN_DATA NO /ora01/oradata/GENXQA/gen_data_01.dbf
10 2097152 GEN_DATA NO /ora02/oradata/GENQA/gen_data_02.dbf
11 2097152 GEN_DATA NO /ora01/oradata/GENXQA/gen_data_03.dbf
12 2097152 GEN_DATA NO /ora01/orabkup/GENQA/oradata/gen_data_04.dbf
13 1024000 GEN_REP_DATA NO /ora01/oradata/GENQA/gen_rep_data_01.dbf
14 1024000 GEN_REP_DATA NO /ora02/oradata/GENQA/gen_rep_data_02.dbf
15 1024000 GEN_REP_DATA NO /ora01/oradata/GENQA/gen_rep_data_03.dbf
16 1048576 GEN_REP_DATA NO /ora02/oradata/GENQA/gen_rep_data_04.dbf
17 2097152 GEN_INDX NO /ora01/oradata/GENQA/gen_indx_01.dbf
18 1441792 GEN_INDX NO /ora02/oradata/GENQA/gen_indx_02.dbf
19 1966080 GEN_INDX NO /ora01/oradata/GENQA/gen_indx_03.dbf
20 1966080 GEN_INDX NO /ora02/oradata/GENQA/gen_indx_04.dbf
21 2097152 GEN_DATA NO /ora01/oradata/GENXQA/gen_data_05.dbf
22 2097152 GEN_DATA NO /ora02/oradata/GENXQA/gen_data_06.dbf
23 29696 AUDIT_DATA NO /ora02/oradata/GENXQA/GENP_audit_rdbs01.dbf
24 41984 REPOMAN_DATA NO /ora01/oradata/GENQA/genp_repoman_data_01.dbf
25 9216 REPOMAN_INDX NO /ora02/oradata/GENQA/genp_repoman_indx_01.dbf
26 1843200 GEN_DATA NO /ora01/oradata/GENXQA/gen_data_07.dbf
27 1536000 GEN_DATA NO /ora02/oradata/GENQA/gen_data_08.dbf
28 1843200 GEN_DATA NO /ora01/oradata/GENXQA/gen_data_09.dbf
29 2097152 GEN_DATA NO /ora02/oradata/GENQA/gen_data_10.dbf
30 1048576 GEN_DATA NO /ora01/oradata/GENQA/gen_data_11.dbf
31 2097152 GEN_DATA NO /ora01/oradata/GENQA/gen_data_12.dbf
32 917504 GEN_INDX NO /ora01/oradata/GENQA/gen_indx_05.dbf
33 917504 GEN_INDX NO /ora02/oradata/GENQA/gen_indx_06.dbf
34 1843200 GEN_INDX NO /ora01/oradata/GENQA/gen_indx_07.dbf
35 1048576 GEN_INDX NO /ora02/oradata/GENQA/gen_indx_08.dbf
36 32768 FOGLIGHT NO /ora02/oradata/GENXQA/foglight_01.dbf
37 2097152 GEN_DATA NO /ora01/orabkup/GENQA/oradata/gen_data_14.dbf
38 2097152 GEN_INDX NO /ora02/oradata/GENXQA/gen_indx_09.dbf
39 819200 GEN_AUDIT_DATA NO /ora01/oradata/GENXQA/GENP_audit_data.dbf
40 524288 GEN_AUDIT_NDX NO /ora01/oradata/GENXQA/GENP_audit_ndx.dbf
41 2097152 GEN_DATA NO /ora01/oradata/GENXQA/gen_data_15.dbf
42 2097152 GEN_DATA NO /ora01/oradata/GENXQA/gen_data_16.dbf
43 2998272 CONV_DATA NO /ora01/oradata/GENXQA/conv_data_01.dbf
44 1048576 CONV_INDX NO /ora01/oradata/GENXQA/conv_indx_01.dbf
45 2097152 GEN_INDX NO /ora01/orabkup/GENQA/oradata/gen_indx_10.dbf
46 2097152 SYSTEM YES /ora01/orabkup/GENQA/oradata/genp_system02.dbf
47 1048576 CONV_DATA NO /ora02/oradata/GENXQA/conv_data_02.dbf
RMAN>

Friday, June 01, 2007

RMAN -- delete expired and crosscheck notes

1. Issue: delete expired backup; -- has errors
================================================

Note: mush allocate channel first

allocate channel for maintenance type disk;
delete expired backup;
release channel;

RMAN> delete expired backup;

RMAN-03022: compiling command: delete expired
RMAN-03023: executing command: delete expired

RMAN-03022: compiling command: delete expired
RMAN-03026: error recovery releasing channel resources
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure during compilation of command
RMAN-03013: command type: delete expired
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20242:
specification does not match any archivelog in the recovery catalog


2. delete expired backup of datafile xx is ok
==============================================

delete expired backup of datafile 1;
delete expired backup of datafile 2;
delete expired backup of datafile 3;
delete expired backup of datafile 4;
delete expired backup of datafile 5;
delete expired backup of datafile 6;
delete expired backup of datafile 7;
delete expired backup of datafile 8;
delete expired backup of datafile 9;
delete expired backup of datafile 10;
delete expired backup of datafile 11;
delete expired backup of datafile 12;
delete expired backup of datafile 13;
delete expired backup of datafile 14;
delete expired backup of datafile 15;
delete expired backup of datafile 16;
delete expired backup of datafile 17;
delete expired backup of datafile 18;
delete expired backup of datafile 19;
delete expired backup of datafile 20;
delete expired backup of datafile 21;
delete expired backup of datafile 22;
delete expired backup of datafile 23;
delete expired backup of datafile 24;
delete expired backup of datafile 25;
delete expired backup of datafile 26;
delete expired backup of datafile 27;
delete expired backup of datafile 28;
delete expired backup of datafile 29;
delete expired backup of datafile 30;
delete expired backup of datafile 31;
delete expired backup of datafile 32;
delete expired backup of datafile 33;
delete expired backup of datafile 34;
delete expired backup of datafile 35;
delete expired backup of datafile 36;
delete expired backup of datafile 37;
delete expired backup of datafile 38;
===


3. tablespace level --this one is ok too
=======================

delete expired backup of tablespace gen_data;
delete expired backup of tablespace system;
delete expired backup of tablespace audit_data;
delete expired backup of tablespace gen_indx;
delete expired backup of tablespace indx;
delete expired backup of tablespace rbs;
delete expired backup of tablespace tools
delete expired backup of tablespace users;
delete expired backup of tablespace gen_rep_data;
delete expired backup of tablespace fog_light;


File K-bytes Tablespace RB segs Name
---- ---------- -------------------- ------- -------------------
1 583680 SYSTEM YES
/ora02/oradata/GEN3S/gen_system01.dbf
2 29696 AUDIT_DATA NO
/ora02/oradata/GEN3S/gen_audit_rdbs01.dbf
3 2097152 GEN_DATA NO
/ora01/oradata/GEN3S/gen_data_01.dbf
4 2097152 GEN_DATA NO
/ora02/oradata/GEN3S/gen_data_02.dbf
5 2097152 GEN_DATA NO
/ora01/oradata/GEN3S/gen_data_03.dbf
6 2097152 GEN_DATA NO
/ora02/oradata/GEN3S/gen_data_04.dbf
7 2097152 GEN_DATA NO
/ora01/oradata/GEN3S/gen_data_05.dbf
8 2097152 GEN_DATA NO
/ora02/oradata/GEN3S/gen_data_06.dbf
9 2096136 GEN_DATA NO
/ora01/oradata/GEN3S/gen_data_07.dbf
10 2097152 GEN_DATA NO
/ora02/oradata/GEN3S/gen_data_08.dbf
11 2074728 GEN_DATA NO
/ora01/oradata/GEN3S/gen_data_09.dbf
12 3211264 GEN_DATA NO
/ora02/oradata/GEN3S/gen_data_10.dbf
13 3211264 GEN_DATA NO
/ora01/oradata/GEN3S/gen_data_11.dbf
14 3211264 GEN_DATA NO
/ora01/oradata/GEN3S/gen_data_12.dbf
15 1835008 GEN_INDX NO
/ora01/oradata/GEN3S/gen_indx_01.dbf
16 1835008 GEN_INDX NO
/ora02/oradata/GEN3S/gen_indx_02.dbf
17 1703936 GEN_INDX NO
/ora01/oradata/GEN3S/gen_indx_03.dbf
18 1835008 GEN_INDX NO
/ora02/oradata/GEN3S/gen_indx_04.dbf
19 1048576 GEN_INDX NO
/ora01/oradata/GEN3S/gen_indx_05.dbf
20 655360 GEN_INDX NO
/ora02/oradata/GEN3S/gen_indx_06.dbf
21 2228224 GEN_INDX NO
/ora01/oradata/GEN3S/gen_indx_07.dbf
22 2232320 GEN_INDX NO
/ora02/oradata/GEN3S/gen_indx_08.dbf
23 65536 INDX NO
/ora01/oradata/GEN3S/gen_indx01.dbf
24 2097152 RBS YES
/ora02/oradata/GEN3S/gen_rbs01.dbf
25 2097152 RBS YES
/ora01/oradata/GEN3S/gen_rbs02.dbf
28 872448 TOOLS NO
/ora01/oradata/GEN3S/gen_tools01.dbf
29 131072 USERS NO
/ora02/oradata/GEN3S/gen_users01.dbf
30 469504 GEN_REP_DATA NO
/ora01/oradata/GEN3S/gen_rep_data_01.dbf
31 468736 GEN_REP_DATA NO
/ora02/oradata/GEN3S/gen_rep_data_02.dbf
32 465152 GEN_REP_DATA NO
/ora01/oradata/GEN3S/gen_rep_data_03.dbf
33 466944 GEN_REP_DATA NO
/ora02/oradata/GEN3S/gen_rep_data_04.dbf
34 32768 FOGLIGHT NO
/ora02/oradata/GEN3S/foglight_01.dbf


4. crosscheck backup has problem too
========================================

RMAN> crosscheck backup;

RMAN-03022: compiling command: XCHECK
RMAN-03026: error recovery releasing channel resources
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure during compilation of command
RMAN-03013: command type: XCHECK
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20242:
specification does not match any archivelog in the recovery catalog


5. crosscheck backup of tablespace system;

RMAN> crosscheck backup of tablespace system;

RMAN-03022: compiling command: XCHECK
RMAN-03023: executing command: XCHECK
RMAN-08074: crosschecked backup piece: found to be 'EXPIRED'
RMAN-08517: backup piece
handle=/oracle/admin/GEN3S/backup/May11bkup_cold_GEN3S_1_14.dbf recid=12
stamp=622309903
RMAN-08074: crosschecked backup piece: found to be 'EXPIRED'
RMAN-08517: backup piece
handle=/oracle/admin/GEN3S/backup/May15bkup_cold_GEN3S_1_25.dbf recid=23
stamp=622644884
RMAN-08074: crosschecked backup piece: found to be 'EXPIRED'
RMAN-08517: backup piece
handle=/oracle/admin/GEN3S/backup/May17bkup_cold_GEN3S_1_27.dbf recid=23
stamp=622832261
RMAN-08074: crosschecked backup piece: found to be 'AVAILABLE'
RMAN-08517: backup piece
handle=/oracle/admin/GEN3S/backup/May21Task38_cold_GEN3S_1_38.dbf
recid=34 stamp=623150216
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete

crosscheck backup of tablespace SYSTEM ;
crosscheck backup of tablespace AUDIT_DATA ;
crosscheck backup of tablespace GEN_DATA ;
crosscheck backup of tablespace GEN_INDX ;
crosscheck backup of tablespace INDX ;
crosscheck backup of tablespace RBS ;
crosscheck backup of tablespace TOOLS ;
crosscheck backup of tablespace USERS ;
crosscheck backup of tablespace GEN_REP_DATA ;
crosscheck backup of tablespace FOGLIGHT ;

delete expired backup of tablespace SYSTEM ;
delete expired backup of tablespace AUDIT_DATA ;
delete expired backup of tablespace GEN_DATA ;
delete expired backup of tablespace GEN_INDX ;
delete expired backup of tablespace INDX ;
delete expired backup of tablespace RBS ;
delete expired backup of tablespace TOOLS ;
delete expired backup of tablespace USERS ;
delete expired backup of tablespace GEN_REP_DATA ;
delete expired backup of tablespace FOGLIGHT ;

Tuesday, May 29, 2007

OCA 10g Ch10 - Implementing Database Backups

Ch10 - Implementing Database Backups

Review Questions

1. Which of the following is the most serious type of redo log file
failure?
A. The loss of an entire redo log file group, but no loss in any other
group
B. The loss of one member of each redo log file group
C. The failure of the ARC0 background process
D. The failure of the LGWR background process
---
Ans: A.
Loss of an entire redo log file group can result in loss of committed
transactions that may not
yet have been written to the database files. Losing all members of a
redo log file group except
for one does not affect database operation and does not result in data
lost. A message is placed
in the alert log file. The failure of LGWR or ARC0 causes an instance
failure, but you do not lose
any committed transaction data.

2. Which of the following tools or options does not ensure that either
no committed transactions
are lost or the MTBF is minimized?
A. Streams
B. Real Application Clusters
C. LogMiner
D. Archived redo logs
E. Standby databases
---
Ans: C.
The LogMiner tool helps you see which transactions have occurred in the
database along
with the DML to reverse the changes, but it does not minimize the MTBF
or reduce the possibility
of committed transaction loss.

3. When the database is in ARCHIVELOG mode, database recovery is
possible up to which event or time?
A. The last redo log file switch
B. The last checkpoint position
C. The last commit
D. The last incremental backup using RMAN
---
Ans: C.
In ARCHIVELOG mode, recovery of the database is possible up to the last
COMMIT statement;
in other words, no uncommitted transactions are lost in ARCHIVELOG mode.

4. From the following, select the true statement regarding image copies
and backup sets.
A. An image copy stores one datafile per image copy, and a backup set
can store all datafiles
in a single file.
B. An image copy stores one datafile per image copy, and a backup set
consists of one file per
datafile backed up.
C. Both image copies and backup sets use a single file to store all
objects to be backed up.
D. A backup set stores each datafile in its own backup file, but an
image copy places all datafiles
into a single output file.
--
Ans: A.
In addition to storing multiple datafiles in a single output file,
backup sets do not contain
unused blocks and can be compressed.


5. The option on the EM Database Control backup scheduling options
screen that allows you to
refresh an image copy on disk with an incremental backup is known as
which new RMAN feature?
A. Incrementally updated backups
B. Incremental level 0 backups
C. Compressed image copy refresh
D. Compressed incremental backups
---
Ans: A.
Incrementally updated backups save time during a recovery operation
because fewer incremental
backups need to be applied to the restored image copy.

6. When should the DBA make a trace copy of the control file using ALTER
DATABASE BACKUP
CONTROLFILE TO TRACE?
A. After every backup
B. After multiplexing the control files
C. Whenever restarting the instance
D. Whenever the physical structure of the database changes
---
Ans: D.
In the rare event that all multiplexed copies of the control file are
lost, having a trace copy
of the control file reduces the possibility of data loss and reduces
downtime during a recovery
operation.

7. Which of the following is not a step in configuring your database to
archive redo log files?
A. Place the database in ARCHIVELOG mode.
B. Multiplex the online redo log files.
C. Specify a destination for archived redo log files.
D. Specify a naming convention for your archived redo log files.
---
Ans: B.
Although it is recommended that you multiplex your online redo log
files, setting up the archival
of your redo log files is not required.


8. Why are online backups known as inconsistent backups?
A. Because not all control files are synchronized to the same SCN until
the database is shut down
B. Because both committed and uncommitted transactions are included in a
backup when the
database is online
C. Because a database failure while an online backup is in progress can
leave the database in an
inconsistent state
D. Because online backups make copies of datafiles while they are not
consistent with the
control files
---
Ans: D.
During an online backup, even if all datafiles are backed up at the same
time, they are rarely,
if ever, in synch with the control file.

9. In the Disk Settings section of the EM Database Control Configure
Backup Settings page, which
of the following backup settings is not configurable?
A. Disk Backup Type
B. Control File Autobackup Format
C. Disk Backup Location
D. Parallelism
---
Ans: B.
Settings such as the control file autobackup filename format and the
snapshot control file destination
filename must be configured using the RMAN command-line interface.

10. Which of the following initialization parameters specifies the
location where the control file
trace backup is sent?
A. USER_DUMP_DEST
B. BACKGROUND_DUMP_DEST
C. LOG_ARCHIVE_DEST
D. CORE_DUMP_DEST
---
Ans: A.
The trace backup is created in the location specified by USER_DUMP_DEST,
and its format is
sid_ora_pid.trc.

11. Which of the following pieces of information is not available in the
control file?
A. Instance name
B. Database name
C. Tablespace names
D. Log sequence number
---
Ans: A.
The instance name is not in the control file. The control file has
information about the physical
database structure.

12. Which data dictionary view shows that the database is in ARCHIVELOG
mode?
A. V$INSTANCE
B. V$LOG
C. V$DATABASE
D. V$THREAD
---
Ans: C.
The V$DATABASE view shows whether the database is in ARCHIVELOG mode or
in
NOARCHIVELOG mode.

13. Which file records all changes made to the database and is used only
when recovering
an instance?
A. Archive log file
B. Redo log file
C. Control file
D. Alert log file
---
Ans: B.
The redo log file records all changes made to the database. The LGWR
process writes the redo
log buffer entries to the redo log files. These entries are used to roll
forward, or to update, the datafiles
during an instance recovery. Archive log files are used for media
recovery.

14. Which initialization parameter contains the value used as the
default for archived log file
destination 10?
A. LOG_ARCHIVE_DEST
B. STANDBY_ARCHIVE_DEST
C. LOG_ARCHIVE_DUPLEX_DEST
D. DB_RECOVERY_FILE_DEST
E. USE_DB_RECOVERY_FILE_DEST
---
Ans D.
DB_RECOVERY_FILE_DEST points to the Flash Recovery area, and this is the
default for
archived log file destination number 10.

15. Which of the following commands is a key step in multiplexing
control files using an SPFILE?
A. ALTER SYSTEM SET CONTROL_FILES= '/u01/oradata/PRD/cntrl01.ctl',
'/u01/
oradata/PRD/cntrl02.ctl' SCOPE=SPFILE;
B. ALTER SYSTEM SET CONTROL_FILES= '/u01/oradata/PRD/cntrl01.ctl',
'/u01/
oradata/PRD/cntrl02.ctl' SCOPE=MEMORY;
C. ALTER SYSTEM SET CONTROL_FILES= '/u01/oradata/PRD/cntrl01.ctl',
'/u01/
oradata/PRD/cntrl02.ctl' SCOPE=BOTH;
D. The number of control files is fixed when the database is created.
---
Ans: A.
The location of the new control files is not valid until an operating
system copy is made of the current
control file to the new location(s) and the instance is restarted. The
SCOPE=SPFILE option specifies
that the parameter change will not take place until a restart.
Specifying either MEMORY or BOTH
causes an error, because the new control file does not yet exist.

16. Which statement adds a member /logs/redo22.log to redo log file
group 2?
A. ALTER DATABASE ADD LOGFILE '/logs/redo22.log' TO GROUP 2;
B. ALTER DATABASE ADD LOGFILE MEMBER '/logs/redo22.log' TO GROUP 2;
C. ALTER DATABASE ADD MEMBER '/logs/redo22.log' TO GROUP 2;
D. ALTER DATABASE ADD LOGFILE '/logs/redo22.log';
---
Ans: B.
When adding log file members, specify the group number, or specify all
the existing group
members.

17. What is the biggest advantage of having the control files on
different disks?
A. Database performance.
B. Guards against failure.
C. Faster archiving.
D. Writes are concurrent, so having control files on different disks
speeds up control
---
Ans: B.
Having the control files on different disks ensures that even if you
lose one disk, you lose only
one control file. If you lose one of the control files, you can shut
down the database, copy a control
file, or change the CONTROL_FILES parameter and restart the database.

18. To place the database into ARCHIVELOG mode, in which state must you
start the database?
A. MOUNT
B. NOMOUNT
C. OPEN
D. SHUTDOWN
E. Any of the above
---
Ans: A.
To put the database into ARCHIVELOG mode, the database must be in the
MOUNT state; the control
files and all datafiles that are not offline must be available to change
the database to
ARCHIVELOG mode.

19. Which of the following commands places the database in ARCHIVELOG
mode?
A. ALTER SYSTEM ARCHIVELOG;
B. ALTER DATABASE ARCHIVELOG;
C. ALTER SYSTEM SET ARCHIVELOG=TRUE;
D. ALTER DATABASE ENABLE ARCHIVELOG MODE;
E. ALTER DATABASE ARCHIVELOG MODE;
---
Ans: B.
You use the ALTER DATABASE ARCHIVELOG command while the database is in
the MOUNT state
to enable archiving of online redo log files.

20. Which of the following substitution variables formats are always
required for specifying the
names of the archived redo log files? (Choose all that apply.)
A. %d
B. %s
C. %r
D. %t
---
Ans: B, C, D.
The substitution variable %d, which represents the database ID, is
required only if multiple
databases share the same archive log destination.

Wednesday, May 23, 2007

RMAN -- Set DBID

Issues -- target database name is ambiguous
=============================================

tx2qdfsdb1> /oracle/admin/GENQA/rman/shell [GENQA] rman target / catalog
rman/xxx@cataprd6

Recovery Manager: Release 8.1.7.4.0 - Production

RMAN-06006: connected to target database: GENQA (not mounted)
RMAN-06008: connected to recovery catalog database

RMAN> list backup;

RMAN-03022: compiling command: list
RMAN-03026: error recovery releasing channel resources
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure during compilation of command
RMAN-03013: command type: list
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20005:
target database name is ambiguous

Solution -- Set DBID -- Must be done when database is down
===========================================================
rman@CATAPRD6> select * from rc_database where name='GENQA';

DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE#
RESETLOGS_TIME
---------- ---------- ---------- -------- -----------------
--------------------
4829855 4829856 525219448 GENQA 3.6278E+10 21-MAY-2007
13:24:35
4766609 4766610 515653788 GENQA 3.6123E+10 27-MAR-2007
23:17:18

==

RMAN> set dbid=525219448;

RMAN-03022: compiling command: CSET
RMAN-03026: error recovery releasing channel resources
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure during compilation of command
RMAN-03013: command type: CSET
RMAN-06188: cannot use command when connected to target database

RMAN> shutdown;

RMAN-06402: Oracle instance shut down

RMAN> set dbid=525219448;

RMAN-03022: compiling command: CSET

RMAN> startup nomount;

RMAN-06193: connected to target database (not started)
RMAN-06196: Oracle instance started

Total System Global Area 2064646304 bytes

Fixed Size 73888 bytes
Variable Size 1005494272 bytes
Database Buffers 1048576000 bytes
Redo Buffers 10502144 bytes