Académique Documents
Professionnel Documents
Culture Documents
RMAN Incomplete Recovery ______________ 11 • There is no warranty of any type for the code or
information presented in this document. The editor is
Incomplete Recovery of a Database ________________ 11 not responsible for any loses or damage resulted from
using the information or executing the code in this
document.
RMAN Maintenance _____________________ 11
• If any one wishes to correct a statement or a typing
Cross Checking Backups and Copies ________________ 11 error or add a new piece of information, please send
Deleting Backups and Copies _____________________ 12 the request to ahmed_b72@yahoo.com . If the
modification is acceptable, it will be added to the
Changing the Availability of RMAN Backups and Copies _ 12 document, the version of the document will be
incremented and the modifier name will be listed in
Exempting a Backup or Copy from the Retention Policy _ 12
the version history list.
The CATALOG Command_________________________ 12
The CHANGE … UNCATALOG Command _____________ 12
Version History
Using SQL*Loader______________________ 14
Direct-Load Insert Operations_____________________ 14
Issuing SQL*Loader ____________________________ 14
Control File ___________________________________ 14
Conventional, Direct-Path and External-Path Loads ____ 15
Oracle Net Architecture and Configuration TRACE_FILE_lstname : filename of the trace file
SAVE_CONFIG_ON_STOP_lstname : whether changes
made by LSNRCTL SET command are made permanent
Oracle Net Configuration Files (FLASE)
Following are the configuration files:
o listener.ora
o tnsnames.ora Dynamic Service Registration
o names.ora Configure Registration
o sqlnet.ora The following initialization parameters must be configured:
o ldap.ora o SERVICE_NAMES: specifies one or more names for the
database service to which this instance connects.
Generally Oracle Net searches for those files in the following
o INSTANCE_NAME: the instance name
order:
1. The directory specified by the TNS_ADMIN environment Examples
variable. SERVICE_NAMES=sales.us.oracle.com
2. The ORACLE_HOME\network\admin directory INSTANCE_NAME=salesdb
Other Shared Server Configuration Parameters You must use a dedicated server process when:
o Submitting batch jobs (no idle time)
• MAX_DISPATCHERS o Connecting as sysdba for maintenance
Description: Specifies the maximum number of
dispatcher processes that can run simultaneously. In tnsnames.ora file:
Parameter type: Integer (CONNECT_DATA=(SERVICE_NAME=TEST)(SERVER=DEDICATED
Parameter class: Static )
Default value 5
• SHARED_SERVERS
Description: Specifies the number of server processes Configuring the Database Archiving Mode
created when an instance is started up.
Parameter type: Integer
Setting ARCHIVELOG mode
Parameter class: Dynamic (can use ALTER SYSTEM to
modify) While database in mount mode:
Default value 0 ALTER DATABASE ARCHIVELOG | NOARCHIVELOG
Note: Additional shared servers start automatically when Note: Backup the database before and after
needed and are deallocated automatically if they remain idle
for too long. However, the initial servers always remain
allocated, even if they are idle. View ARCHIVELOG mode of a Database
LOG_ARCHIVE_MIN_SUCCEED_DEST
Parameter Hot or Online Backup
1. Put tablespace in backup mode using the command:
This parameter uses all mandatory destinations plus some
number of optional non-standby destinations to determine ALTER TABLESPACE <tname> BEGIN BACKUP
whether LGWR can overwrite the online log.
2. OS copy tablespace data files
Range of values: 1-10 in method 1 and 1-2 in method 2.
3. End backup mode for the tablespace
Note: It is advisable to copy parameter file, archived logs
Formatting ArchiveLog Filenames and as well.
%s log sequence number Note: database must be in ARCHIVELOG mode
%S log sequence number, zero filled
%t thread number
%T thread number, zero filled Backing up Control Files
LOG_ARCHIVE_FORMAT = "LOG%s_%t.ARC" • Binary copy of the control file
Alter database backup controlfile to '…'
• V$ARCHIVE_PROCESSES
Backing Up the Initialization Parameter File
provides information about the state of the various ARCH
processes for the instance. CREATE PFILE = '/fname.ora' FROM SPFILE;
o DELETE INPUT : useful when backing up archived redo To delete backed up copy of the archived log file
logs, datafile copies or backup sets. BACKUP ARCHIVELOG ALL DELETE INPUT
o FORMAT :%c copy number To delete logs from all enabled archiving destinations.
%p backup piece number BACKUP ARCHIVELOG ALL DELETE ALL INPUT
%s backup set number To specify a range of archived redo logs by time
%d database name BACKUP ARCHIVELOG UNTIL TIME 'SYSDATE-7';
%n database name padded with 8 characters BACKUP ARCHIVELOG FROM TIME 'SYSDATE-30' UNTIL
TIME 'SYSDATE-7';
%t backup set time stamp
%u compressed version of %s and %t To specify a range of archived redo logs by SCN
BACKUP ARCHIVELOG UNTIL SCN = 320
%U (default) equivalent to %u_%p_%c BACKUP ARCHIVELOG SCN BETWEEN 205 AND 320
To make a whole database backup To specify a range of archived redo logs by log sequence
BACKUP DATABASE FORMAT '/tmp/%U' TAG='weekly_bak' number
SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT'; BACKUP ARCHIVELOG UNTIL SEQUENCE = 501
BACKUP ARCHIVELOG FROM SEQUENCE integer
Backing Up Tablespaces
BACKUP TABLESPACE system, users, tools; Using BACKUP ... PLUS ARCHIVELOG:
LIST BACKUP OF TABLESPACE BACKUP DATABASE PLUS ARCHIVELOG;
Backing up Datafiles and Datafile Copies Note: In Oracle9i, Release 2, you can use the NOT BACKED
BACKUP DATAFILE 1,2,3,4, DATAFILECOPY UP integer TIMES clause of the BACKUP ARCHIVELOG
'/tmp/system01.dbf' command to back up only those logs that have not been
LIST BACKUP OF DATAFILE 1,2,3,4; backed up at least integer times.
Note: there is little value in creating multiple copies on the Backup in NOARCHIVELOG Mode
same physical media. For sbt channels, if you use a media
manager that supports Version 2 of the SBT API, then the 1. Shut down cleanly
media manager will automatically put each copy onto a 2. Mount the database.
separate medium.
3. Allocate multiple channels, if not using automatic.
Note: You must set the BACKUP_TAPE_IO_SLAVES initialization 4. Run the BACKUP command.
parameter to TRUE in order to perform duplexed backups to
an sbt device.
Tags for Backups and Image Copies
Image Copies BACKUP .. TAG='tag_name'
• V$COPY_CORRUPTION
Image Copy Parallelization shows which blocks have been found corrupt during an
image copy.
You can parallelize the copy operation by:
• Using the CONFIGURE DEVICE TYPE … PARALLELISM or
• V$DATABASE_BLOCK_CORRUPTION
allocating multiple channels ( required in Oracle8i)
displays information about database blocks that were
• Specifying one COPY command for multiple files
corrupted after the last backup.
CONFIGURE DEVICE TYPE disk parallelism 4;
COPY # 3 files copied in parallel • V$BACKUP_DATAFILE
datafile 1 TO '/BACKUP/df1.dbf', is useful for creating equal-sized backup sets by
datafile 2 TO '/BACKUP/df2.dbf', determining the number of blocks in each datafile. It
datafile 3 TO '/BACKUP/df3.dbf'; can also help you find the number of corrupt blocks for
the datafile.
• V$BACKUP_SET
shows backup sets that have been created. Relocate a Tablespace
RUN{
• V$BACKUP_PIECE SQL "alter tablespace users offline immediate";
shows backup pieces created for backup sets. SET NEWNAME FOR DATAFILE
'/ORADATA/u03/users01.dbf'
TO '/ORADATA/u04/users01.dbf';
RESTORE TABLESPACE users;
Monitoring RMAN Backups
SWITCH datafile 3; # Update the control file and
To correlate a process with a channel during a backup: recovery catalog
RECOVER TABLESPACE users; #Recover the tablespace
1. In each session, set the COMMAND ID to a different value
RUN SQL "alter tablespace tbs1 online";}
{
ALLOCATE CHANNEL c1 TYPE sbt;
SET COMMAND ID TO 'sess1';
BACKUP DATABASE;
} RMAN Incomplete Recovery
2. Query the joined V$SESSION and V$PROCESS views
SELECT SID, SPID, CLIENT_INFO Incomplete Recovery of a Database
FROM V$PROCESS p, V$SESSION s
WHERE p.ADDR = s.PADDR 1. Mount the database.
AND s.CLIENT_INFO LIKE '%id=sess%';
The CLIENT_INFO column displays in the following format: 2. The following steps should be followed:
id=command_id,rman channel=channel_id RUN {
# multiple channels for parallelization
3. Query the V$SESSION_LONGOPS view to get the status of ALLOCATE CHANNEL c1 TYPE DISK;
the backup or copy. ALLOCATE CHANNEL c2 TYPE DISK;
# recover until time, SCN or sequence
SET UNTIL TIME = '2001-12-09:11:44:00';
Detecting Corruption SET UNTIL TIME "to_date('09-05-2004
00:00:20', 'dd-mm-yyyy hh24:mi:ss')" ;
• To view corrupt blocks encountered during backups from SET UNTIL SEQUENCE 120 THREAD 1;#120 not
the control file, view either V$BACKUP_CORRUPTION for included
backup sets or V$COPY_CORRUPTION for image copies. # ALL datafiles must be restored
RESTORE DATABASE;
• RMAN tests data and index blocks for logical corruption and RECOVER DATABASE;
logs any errors in the alert.log and server session trace file. ALTER DATABASE OPEN RESETLOGS; }
By default, error checking for logical corruption is disabled.
3. If using a recovery catalog, register the new incarnation
of the database using the command: RESET DATABASE
Deleting Backups and Copies Defined as Obsolete by RMAN does not touch the specified physical files: it only
the DELETE Command alters the repository records for these files. You can use
DELETE OBSOLETE REDUNDANCY = 3; this command when you have deleted a backup or copy
DELETE OBSOLETE RECOVERY WINDOW OF 7 DAYS; through a means other than RMAN.
CHANGE ARCHIVELOG … UNCATALOG;
Forcing the Deletion of Backups and Copies CHANGE DATAFILECOPY '/DB01/BACKUP/users01.dbf'
DELETE FORCE NOPROMPT BACKUPSET TAG 'weekly_bkup'; UNCATALOG;
4. Create catalog
rman catalog rman_db1/rman_db1@catdb
Exempting a Backup or Copy from the RMAN> create catalog tablespace rman_ts;
Retention Policy
5. Connect to target database as SYSDBA
Use the command CHANGE ... KEEP FOREVER|UNTIL RMAN TARGET SYS/SYS@TEST2 CATALOG
CHANGE BACKUPSET 123 KEEP FOREVER NOLOGS; RMAN/RMAN@TEST1
CHANGE DATAFILECOPY '/DB01/BACKUP/users01.dbf' 6. Register target database
KEEP UNTIL 'SYSDATE+60'; REGISTER DATABASE;
Note: Specify KEEP ... LOGS to save archived logs for a
possible incomplete recovery and KEEP ... NOLOGS not to
save archived logs for a possible incomplete recovery.
• User Mode
Owner=<user_name>
RMAN Catalog Reporting
• Table Mode
• Use REPORT and LIST commands. Tables=<tables_list>
• Alternatively you can use SQL commands to query the You can export tables whose names match specific
RMAN data dictionary views. Examples of those view are patterns:
the following: TABLES=(scott.%P%,blake.%,scott.%S%)
• RC_DATABASE You can export a table with a specified partition:
• RC_DATAFILE TABLES=(emp:m,emp:sp4)
• RC_STORED_SCRIPT
• RC_STORED_SCRIPT_LINE
• RC_TABLESPACE
Stored Scripts
• Stored scripts are created using the CREATE SCRIPT
command
Create Script Level0Backup {
backup incremental level 0
format '/u01/db01/backup/%d_%s_%p'
fileperset 5
(database include current controlfile);
sql 'alter system archive log current';}
Invoking Import
Direct-Load Insert Operations
imp hr/hr TABLES=employees,departments rows=y
file=exp1.dmp Serial: uses one server process to insert data beyond the
high-water mark.
imp system/manager FROMUSER=hr TOUSER=scott INSERT /*+ APPEND */
file=exp2.dmp INTO T1_NEW
NOLOGGING
Note: If the file parameter is not specified, Import looks for
SELECT * FROM T1
the default file expdat.dmp
Issuing SQL*Loader
Invoking Import as SYSDBA
sqlldr test/test control=invoice_header.ctl
• You need to invoke Import as SYSDBA when importing a
transportable tablespace set
imp \'username/password@instance AS SYSDBA\'
Control File
• If either the username or password is omitted, Import will -- Invoice Header Sample Control File
prompt you for it. LOAD DATA
INFILE 'mydata.dat'
BADFILE 'baddata.dat'
Import Process Sequence DISCARDFILE 'skippeddata.dat'
REPLACE
1. New tables are created INTO TABLE invoice_header
2. Data is imported WHEN SLAESPERSON(100)='EDI'
3. Indexes are built FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY
'"'
4. Triggers are imported TRAILING NULLCOLS
5. Integrity constraints are enabled on the new tables ( COMPNO decimal external
6. Any bitmap, functional, and/or domain indexes are built , INV_NO decimal external
, DISCOUNT_RATE decimal external
":discount_rate * .90"
, DUEDATE date "SYYYYMMDDHH24MISS"
Manually Creating Tables Before Importing
, INVDATE date "SYYYYMMDDHH24MISS"
Data , CUST_NO char
When tables are manually created before data is imported, , CUST_CAT char NULLIF cust_cat=BLANKS
the CREATE TABLE statement in the export dump file will fail , CO_OBJ decimal
because the table already exists. To avoid this failure and , SALESMAN char "UPPER(:salesman)"
continue loading data into the table, set the import parameter , CUSTREF char
IGNORE=y. Otherwise, no data will be loaded into the table )
because of the table creation error.