6. backup and recovery - cursuri automatica si...
TRANSCRIPT
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
6. Backup and Recovery
10.01.2010 1Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Outline
• Backup and Recovery Overview
• Instance and Media Recovery Structures
• Configuring the Database Archiving Mode
• Oracle Recovery Manager
10.01.2010 2Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Backup and Recovery Overview
• Describe the basics of database backup, restore and recovery• List the types of failures that may occur in an Oracle environmentList the types of failures that may occur in an Oracle environment• Define a backup and recovery strategy
10.01.2010 3Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Backup and Recovery Issues
• Protect the database from numerous types of failures
I M Ti B t F il (MTBF)• Increase Mean-Time-Between-Failures (MTBF)
• Decrease Mean-Time-To-Recover (MTTR)
• Minimize data loss
10.01.2010 4Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Categories of Failures
• Statement failure• Statement failure
• User process failure
• User error• User error
• Network failure
Instance failure• Instance failure
• Media failure
10.01.2010 5Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Causes of Failure
• System Crashes due to hardware or software errors, resulting in loss of main memoryin loss of main memory.
• Media Failure, such as head crashes or unreadable media, resulting in the loss of parts of secondary storageresulting in the loss of parts of secondary storage.
• Application Software Errors, one or more transactions fail due to the logical error of the program.g p g
• Human Destruction.
10.01.2010 6Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Causes of Statement Failures
• Logic error in an application
Att t t t i lid d t i t th t bl• Attempt to enter invalid data into the table
• Attempt an operation with insufficient privileges
• Attempt to create a table but exceed allocated quota limits
• Attempt an INSERT or UPDATE to a table, causing an extent
to be allocated, but with insufficient free space available in the
tablespace
10.01.2010 7Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Resolutions for Statement Failures
• Correct the logical flow of the program
M dif d i th SQL t t t• Modify and reissue the SQL statement
• Provide the necessary database privileges
• Change the user’s quota limit by using the ALTER USER
command
• Add file space to the tablespace
• Enable resumable space allocation
10.01.2010 8Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Causes of User Process Failures
• The user performed an abnormal disconnect in the session
The user’s session was abnormally terminated• The user s session was abnormally terminated
• The user’s program raised an address exception, which terminated the sessionterminated the session
10.01.2010 9Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Resolution of User Process Failures
• The PMON process detects an abnormally terminated user
processprocess
• PMON rolls back the transaction and releases any resources
d l k b i h ld b itand locks being held by it
10.01.2010 10Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Possible User Errors
SQL> DROP TABLE employees;p y
SQL> TRUNCATE TABLE employees;
SQL> DELETE FROM employees;
SQL> COMMIT;
SQL> UPDATE employeesSQL> UPDATE employees
2> SET salary = salary * 1.5;
SQL> COMMIT;Q ;
10.01.2010 11Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Resolution of User Errors
• Train the database users
R f lid b k• Recover from a valid backup
• Import the table from an export file
• Use LogMiner to determine the time of error
• Recover with a point-in-time recovery
• Use LogMiner to perform object-level recovery
• Use FlashBack to view and repair historical data
10.01.2010 12Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Causes of Instance Failure
InstanceSGAShared PoolUser Server
Redo LogBuffer
Data Dictionary
LibraryCache
process
Server
DatabaseBuffer Cache
User
processPGA
Data DictionaryCache
DBWRSMONPMON CKPTLGWR Others
processPGA
Java Pool Large Poolprocess
146Control
fil
146Datafile 1
146Redo Log
file 1
Password
files file 1
Parameterfile
146Datafile 2
146
146Redo Log
file 2
file DatabaseDatafile 3
10.01.2010 13Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Recovery from Instance Failure
• No special recovery action in needed from DBA• Start the instance• Wait for the “database opened” notification• Notify users• Check the alert log to determine the reason for the failure
SQL> CONNECT / AS sysdbaSQL> CONNECT / AS sysdba
Connected.
SQL> STARTUPQ
...
Database opened.
10.01.2010 14Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Causes of Media Failures
• Head crash on a disk drive
Ph i l bl i di f iti t d t b fil• Physical problem in reading from or writing to database files
• File was accidentally erased
10.01.2010 15Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Resolutions for Media Failures
• The recovery strategy depends on which backup method was
chosen and which files are affectedchosen and which files are affected
• If available, apply archived redo log files to recover data
itt d i th l t b kcommitted since the last backup
10.01.2010 16Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Dumping and Logging
• A dump is a copy of a database that is physically kept away from the database in use (active database)from the database in use (active database).
• A dump is snapshot of a valid database state.
• A log is a journal of the transactions details: ID Operations• A log is a journal of the transactions details: ID, Operations, BFIM (Before Image) and AFIM (After Image) of Data Items, and checkpoint record.p
10.01.2010 17Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Checkpoint
• The point of synchronisation between the database and the transaction log file.and the transaction log file.
• All buffers are force-written to secondary storage. • The process is:p
– Suspend execution of transactions temporarily.– Force-write all update operations of committed
transactions from main memory buffers to disk.– Write a [checkpoint] record to the log, and force-write
the log to diskthe log to disk.– Resume executing transactions.
10.01.2010 18Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Recovery Techniques
• Deferred Update– A transaction cannot change the database until it reaches its commit– A transaction cannot change the database until it reaches its commit
point. So any transaction cannot read the value of an item that is written by an uncommitted transaction, because items remain locked until a t ti h it it i t H di llb k illtransaction reach its commit point. Hence, no cascading rollback will occur.
– A transaction does not reach its commit point until all its update operations are recorded in the log and the log is force-written to disk (There is no BFIM recorded in log because there is no write to the database buffer)database buffer).
– For the recovery, we redo the committed transactions that started since last checkpoint. Any uncommitted transactions are ignored and restarted (therefore, there is no undo needed).
10.01.2010 19Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Example: (Deferred Update Recovery)
[start_transaction, T1][write_item, T1 D, 20][commit T1]
T1[commit, T1][start_transaction, T3][write_item, T3 B, 15][start transaction, T4]
T3
T4[ _ , ][write_item, T4 A, 20][checkpoint][start_transaction T2]
T2
[write_item T2, D, 15][start_transaction, T5][write_item, T5, C, 30][commit T3]
T5
[commit, T3][commit, T2] system crash!
checkpoint t1 system crash
time
10.01.2010 20Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Explanations
• Changes on data items A and C performed by T4 and T5 are ignored because the transactions did not reach their commit points.
• T2 and T3 are redone because their commit points are after the last system checkpoint.the last system checkpoint.
• T4 and T5 are restarted.
What would happen for Immediate Update Recovery?Recovery?
10.01.2010 21Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Recovery Techniques (con’d)
• Immediate UpdateDatabase buffers are updated immediately after the log is– Database buffers are updated immediately after the log is updated. So the database will be physically updated when the buffers are next flushed to the disk.
– During the recover process, all uncommitted transactions need to be undone, and committed transactions need to be redone.
– Cascading redo and undo transactions are possible during a recovery process.
10.01.2010 22Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Recovery Techniques (con’d)
• Shadow PagingDuring the life time of a transaction database buffer pages are– During the life time of a transaction, database buffer pages are maintained by two page tables: current and shadow.
– Shadow page table is never changed and is used for the recovery.p g g y
– When the transaction completes, the current page table becomes the shadow.
10.01.2010 23Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Defining a Backup and Recovery Strategy
• Business requirements
O ti l i t• Operational requirements
• Technical considerations
• Management concurrence
10.01.2010 24Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Business Requirements
• Mean time to recover– Should be reduced– Anticipating the types of failures that can occur and using effective
recovery strategies• Mean time between failureMean time between failure
– Must be increased– Understand the backup and recovery structures within an Oracle
database environment and configure the database so that failuresdatabase environment and configure the database so that failures do not often occur
• Evolutionary process– Strategy evolves as business, operational, and technical
requirements change
10.01.2010 25Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Operational Requirements
• 24-hour operations
P d t b fi ti t t b i ti– Proper database configuration to support business operations
• Testing and validating backups
– A recovery is only a good as the backups that are available
• Database volatility
10.01.2010 26Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Technical Considerations
• Resources: hardware, software, manpower, and time
Ph i l i i f th ti t fil• Physical image copies of the operating system files
• Logical copies of the objects in the database
• Database configuration
• Transaction volume that affects desired frequency of backups
10.01.2010 27Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Disaster Recovery Issues
• How will your business be affected in the event of a major
disaster such as:disaster, such as:
– Earthquake, flood, or fire
C l t l f hi– Complete loss of machine
– Malfunction of storage hardware or software
Loss of key personnel for example the database administrator– Loss of key personnel, for example the database administrator
• Do you have a plan for testing your strategy periodically?
10.01.2010 28Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Oracle Database Backup
• Disk Allocations for an Oracle database• Database Storage Structureg• Logical Backup
– Import/Export utilitiesPh i l B k• Physical Backup– Cold backup– Hot backup
10.01.2010 29Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Disk Allocations - Example
• Disk 1: Oracle Software and OSDisk 2: SYSTEM tablespace Control file 1• Disk 2: SYSTEM tablespace, Control file 1
• Disk 3: ROLLBACK SEGMENT tablespace(1& 2), Control File 2( ),
• Disk 4: DATA tablespace, Control file 3• Disk 5: TEMP tablespace• Disk 6: INDEX tablespace
How many tablespaces?tablespaces?
10.01.2010 30Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Database Storage Structure
Logical
Database Tablespace Segment Extent Data Block
Physical
Data File O/S Block
10.01.2010 31Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Summary
• Evaluate potential failures in your environment
D l t t di t t d b b i ti l d• Develop a strategy dictated by business, operational, and
technical requirements
• Consider a test plan for a backup and recovery strategy
10.01.2010 32Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
I t d M di R St tInstance and Media Recovery Structures
• Describe the Oracle processes memory structures and filesDescribe the Oracle processes, memory structures, and files relating to recovery
• Identify the importance of checkpoints, redo log files, and archived log filesarchived log files
• Describe ways to tune instance recovery10.01.2010 33Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Overview
InstanceSGA Shared Pool
Redo LogB ff Data Dictionary
LibraryCache
Server DatabaseB ff C h
Java Pool Large Pool
User Buffer Data DictionaryCache
DBWnSMON PMON CKPT LGWR ARCn
processPGA
Buffer Cacheprocess
146Control
fil
146Datafile 1
146Redo Log
file 1
Password
Parameterfile
files file 1
146Datafile 2
146
146Redo Log
file 2Archivedlog files
file DatabaseDatafile 3
10.01.2010 34Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Memory structures
Type Description
Database buffer Memory area used to store blocks read from data files. Data is cache
yread into the blocks by server processes and written out by DBWn asynchronously
Log buffer Memory containing before and after image copies of changed data to be written to the redo logsto be written to the redo logs
Large pool An optional area in the SGA that provides large memory allocations for backup and restore operations, I/O server processes, and session memory for the shared server.y
Shared pool Stores parsed versions of SQL statements, PL/SQL procedures, and data dictionary information
Java pool Used in server memory for all session-specific Java code and dataJava pool Used in server memory for all session specific Java code and data within the JVM
10.01.2010 35Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Background Processes
Type Description
Database writer (DBWn) Writes dirty buffers from the data buffer cache to the data files. ( ) yThis activity is asynchronous.
Log writer (LGWR) Writes data from the redo log buffer to the redo log files.
S i (SMON) P f i i R iSystem monitor (SMON) Performs automatic instance recovery. Recovers space in temporary segments when they are no longer in use. Merges contiguous areas of free space depending on parameters that are set.
Process monitor (PMON) Cleans up the connection/server process dedicated to an abnormally terminated user process. Performs rollback and releases the resources held by the failed process.
Checkpoint (CKPT) Synchronizes the headers of the data files and control files withCheckpoint (CKPT) Synchronizes the headers of the data files and control files with the current redo log and checkpoint numbers.
Archiver (ARCn) (optional)
A process that automatically copies redo logs that have been marked for archiving.
10.01.2010 36Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Large Pool
• Can be configured as a separate memory area in the SGA to be used for:– Oracle backup and restore operations– I/O server processes– Session memory for the shared serversSession memory for the shared servers
• Is sized by the LARGE_POOL_SIZE parameter
SQL> SELECT * f $ t tSQL> SELECT * from v$sgastat
2> WHERE pool = ‘large pool’;
POOL NAME BYTESPOOL NAME BYTES
------------ --------------- --------
large pool free memory 4194304large pool free memory 4194304
10.01.2010 37Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Database Buffer Cache, DBWn, and Data files
InstanceSGASGA
Redo Log
Shared Pool
LibraryCache
Database
Java Pool Large Pool
Redo LogBuffer Data Dictionary
Cache
DBW0SMON PMON CKPT LGWR ARCn
Serverprocess
PGA
DatabaseBuffer CacheUser
process
0 C
146C t l
146D t fil 1
146Redo Log
DBW1
Parameterfile
Control files
Datafile 1 Redo Log file 1
146Datafile 2
146
146Redo Log
file 2Archivedlog files
Passwordfile Database
146Datafile 3
10.01.2010 38Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Redo Log Buffer, LGWR, and Redo Log Files
InstanceSGA Shared Pool
LibraryCache
Java Pool Large Pool
Redo LogBuffer Data Dictionary
Cache
DBWSMON PMON CKPT LGWR
Serverprocess
PGA
DatabaseBuffer CacheUser
process
DBW0SMON PMON CKPT LGWR ARCn
146146 146
DBW1
Parameterfile
146Control
files
146Datafile 1 Redo Log
file 1
146Datafile 2
146Redo Log
fil 2Archivedlog files
Passwordfile Database
146Datafile 3
file 2 log files
10.01.2010 39Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Multiplexed Redo Log Files
Group 1 Group 2 Group 3
log1a.rdo log1a.rdo log1a.rdo
p p p
Disk 1(Member a) log1a.rdo log1a.rdo log1a.rdo(Member a)
log1b.rdo log1b.rdo log1b.rdoDisk 2
(Member b)
10.01.2010 Administrarea Bazelor de Date I 40
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
How to relocate a Redo Log file• If the log file is current, perform a log switch by using:
SQL ALTER SYSTEM SWITCH LOGFILE
• Copy the redo log file to the new location
SQL> ALTER SYSTEM SWITCH LOGFILE;
• Use the ALTER DATABASE RENAME FILE to make the change in the control files:
ALTER DATABASE [database]ALTER DATABASE [database]
RENAME FILE ‘filename’[,’filename’]...
TO ‘filename’[ ’filename’]TO filename [, filename ]...
10.01.2010 Administrarea Bazelor de Date I 41
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Database Checkpoints
• Checkpoints are used to determine where recovery should start
• Checkpoint position
– where recovery starts
– all the referenced data blocks prior to that point have already been
written to disk by DBWn
• Checkpoint queue – link list of dirty blocks
10.01.2010 Administrarea Bazelor de Date I 42
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Types of Checkpoints• Full checkpoint
– All dirty buffers are writtenAll dirty buffers are written
– SHUTDOWN NORMAL, IMMEDIATE, or TRANSACTIONAL
– ALTER SYSTEM CHECKPOINT
• Incremental checkpoint (Fast-Start checkpoint)– Periodic writes
– Only write the oldest blocks
• Partial checkpoint – Dirty buffers belonging to the tablespace
– ALTER TABLESPACE BEGIN BACKUP
ALTER TABLESPACE t bl OFFLINE NORMAL– ALTER TABLESPACE tablespace OFFLINE NORMAL
10.01.2010 Administrarea Bazelor de Date I 43
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
CKPT Process
InstanceSGA Shared Pool
Redo Log
Shared Pool
LibraryCache
Server Database
Java Pool Large Pool
User gBuffer Data Dictionary
Cache
DBW0SMON PMON CKPT LGWR ARCn
Serverprocess
PGA
Buffer CacheUserprocess
146Control
146Datafile 1
146Redo Log
fil 1
DBW1
Password
Parameterfile
Control files
Datafile 1 gfile 1
146Datafile 2
146
146Redo Log
file 2Archivedlog files
10.01.2010 Administrarea Bazelor de Date I 44
Passwordfile Database
146Datafile 3
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Multiplexed Control Files
InstanceSGA Shared Pool
Redo Log
Shared Pool
LibraryCache
Server Database
Java Pool Large Pool
User gBuffer Data Dictionary
Cache
DBW0SMON PMON CKPT LGWR ARCn
Serverprocess
PGA
Buffer CacheUserprocess
146Datafile 1
146Redo Log
fil 1
DBW1
Control files
Password
Parameterfile
Datafile 1 gfile 1
146Datafile 2
146
146Redo Log
file 2Archivedlog files
Control files
10.01.2010 Administrarea Bazelor de Date I 45
Passwordfile Database
146Datafile 3
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
How to Multiplex the Control File
1. Shut down the database
2. Make a copy of the existing control file to a different device
3. Edit or add the CONTROL_FILES parameter and specify
names for all the control files
4. Start the database
10.01.2010 Administrarea Bazelor de Date I 46
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
ARCn Process and Archived Log FilesInstance
SGA Shared Pool
Redo LogBuffer Data Dictionary
LibraryCache
Server DatabaseBuffer Cache
Java Pool Large Pool
User Buffer yCache
DBW0SMON PMON CKPT LGWR ARCn
processPGA
Buffer Cacheprocess
DBW1ARC1
146Control
files
146Datafile 1
146Redo Log
file 1
DBW1
Archivedl fil
Password
Parameterfile
files146
Datafile 2146
D t fil 3
146Redo Log
file 2 Archivedlog files
log filesdest 2
10.01.2010 Administrarea Bazelor de Date I 47
file DatabaseDatafile 3g
dest 1
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Database Synchronization
• All datafiles (except offline and read-only) must be
h i d f th d t b tsynchronized for the database to open
• Synchronization is based on the current checkpoint number
• Applying changes recorded in the redo log files synchronizes
datafiles
• Redo log files are automatically requested by the Oracle server
10.01.2010 Administrarea Bazelor de Date I 48
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Phases for Instance Recovery1. Datafiles out-of-synch2. Roll forward (redo)3. Committed and non-
InstanceSGA Shared Pool
J P l L P lcommitted data in files4. Roll back (undo)5. Committed data in files Redo Log
Buffer Data DictionaryC h
LibraryCache
DatabaseBuffer Cache
Java Pool Large Pool
Cache
DBW0SMON PMON CKPT LGWR ARCnServer
processPGA
SQL*Plus
146.5Control
146.5Datafile 1
146.5Redo Log
file 1 CheckpointControl files
Datafile 1 file 1
146.5Datafile 2
146.5
145Redo Log
file 2
Checkpoint
Undo
10.01.2010 Administrarea Bazelor de Date I 4910.01.2010 Administrarea Bazelor de Date I 49
DatabaseDatafile 3
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Tuning Crash and Instance Recovery g yPerformance
• Tuning the duration of instance and crash recovery
• Tuning the phases of instance recoveryg p y
10.01.2010 Administrarea Bazelor de Date I 50
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Tuning the Duration of Instance and Crash RecoveryCrash Recovery
Methods to keep the duration of instance and crash recovery within user-specific bounds:
• Set initialization parameters to influence the number of redo log
records and data blocks involved in recovery
• Size the redo log file to influence checkpointing frequency
• Issue SQL statements to initiate checkpoints
• Parallelize instance recovery operations• Parallelize instance recovery operations
10.01.2010 Administrarea Bazelor de Date I 51
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Initialization Parameters Influencing CheckpointingCheckpointing
Parameter DefinitionParameter Definition
FAST_START_MTTR_TARGET Expected MTTR specified in seconds
LOG CHECKPOINT TIMEOUT Amount of time that has passed since theLOG_CHECKPOINT_TIMEOUT Amount of time that has passed since the
incremental checkpoint at the position where
the last write to the redo log occurred
LOG_CHECKPOINT_INTERVAL Number of redo log file blocks that can exist
between an incremental checkpoint and the
last block written to the redo log
10.01.2010 Administrarea Bazelor de Date I 52
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
V$INSTANCE_RECOVERY
• Used to monitor the mechanisms that are available to limit
I/Orecovery I/O
• Statistics from this view to calculate which parameter has the
greatest influence on checkpointing
10.01.2010 Administrarea Bazelor de Date I 53
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
V$INSTANCE_RECOVERY• RECOVERY_ESTIMATED_IOS
– Number of dirty buffers in the buffer cachey• ACTUAL_REDO_BLKS
– Number of redo blocks required for recoveryTARGET REDO BLKS• TARGET_REDO_BLKS– Number of redo blocks that must be processed for recovery
• LOG_FILE_SIZE_REDO_BLKS• LOG_CHKPT_TIMEOUT_REDO_BLKS• LOG_CHKPT_INTERVAL_REDO_BLKS
FAST START IO TARGET REDO BLKS• FAST_START_IO_TARGET_REDO_BLKS• TARGET_MTTR• ESTIMATED MTTR_• CKPT_BLOCK_WRITES
10.01.2010 Administrarea Bazelor de Date I 54
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Tuning the Phases of Crash and Instance Recovery
Tuning the roll forward phase• Tuning the roll forward phase
• Tuning the rollback phase
10.01.2010 Administrarea Bazelor de Date I 55
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Tuning the Rolling Forward Phase
• Parallel block recovery
• RECOVERY_PARALLELISM specifies the number of
concurrent recovery processes
10.01.2010 Administrarea Bazelor de Date I 56
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Tuning the Rolling Back Phase
• Fast-start on-demand rollback
– Feature that allows new transactions to begin immediately after
the roll forward phase of recovery completes
• Fast-start parallel rollback
10.01.2010 Administrarea Bazelor de Date I 57
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Fast-Start On-Demand Rollback
Server process encountering data to be rolled back performs the
f ll ifollowing:
• Rolls back the block containing the required row
• Hands off further recovery, which may be in parallel, to SMON
I dI dresponseImproved response
10.01.2010 Administrarea Bazelor de Date I 58
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Fast-Start Parallel Rollback
SMON
P000P000
P001
UndoP002
Undosegment Tables
10.01.2010 Administrarea Bazelor de Date I 59
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Controlling Fast-Start Parallel RollbackControlling Fast Start Parallel Rollback
FAST START PARALLEL ROLLBACK t• FAST_START_PARALLEL_ROLLBACK parameter
Value Maximum Parallel Recovery Serversa ue a u a a e eco e y Se e s
FALSE NoneLOW (default) 2 * CPU COUNTO (de au t) C U_COUHIGH 4 * CPU_COUNT
10.01.2010 Administrarea Bazelor de Date I 60
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Monitoring Parallel Rollback
• V$FAST_START_SERVERS
– Provides information about all the recovery slaves performing
parallel transaction recovery
• V$FAST_START_TRANSACTIONS
– Contains information about the progress of the transactions that
Oracle is recovering
10.01.2010 Administrarea Bazelor de Date I 61
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Monitoring Parallel Rollbackg• To monitor the use of parallel query slaves for fast-start parallel
rollback:
SELECT * FROM v$fast_start_servers;
STATE UNDOBLOCKSDONE PIDSTATE UNDOBLOCKSDONE PID
----------- --------------- ----
RECOVERING 99 10RECOVERING 99 10
IDLE 0 11
IDLE 0 12
IDLE 0 13
10.01.2010 Administrarea Bazelor de Date I 62
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Summary• Identify components of the instance and database that are
significant to recovery• Tune crash and instance recovery
10.01.2010 Administrarea Bazelor de Date I 63
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Configuring the Database Archiving ModeConfiguring the Database Archiving Mode
• Describe the differences between ARCHIVELOG and NOARCHIVELOG modes• Configure a database for ARCHIVELOG modeg• Enable automatic archiving• Perform manual archiving of logs• Configure multiple archive processes• Configure multiple destinations, including remote destinations
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Redo Log History
N d hi tLGWR 052
No redo history
054 05305 053
051
052
Redo history
Online red log files052
10.01.2010 Administrarea Bazelor de Date I 65
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
NOARCHIVELOG Mode
• Default when the database is created
• Characteristics:
– Redo log files are used in a circular fashion
– A redo log file can be reused immediately after a checkpoint has
taken place
– After redo logs are overwritten, media recovery is only possible to
the last full backup
10.01.2010 Administrarea Bazelor de Date I 66
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
NOARCHIVELOG Mode
LGWR
No redohistory
052054
053Online redolog files 052
052054
053
10.01.2010 Administrarea Bazelor de Date I 67
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
NOARCHIVELOG Mode• Implications of NOARCHIVELOG Mode:
– If a tablespace becomes unavailable because of a failure, you p ycannot continue to operate the database until the tablespace has been dropped or the entire database has been restored from backups
– You can perform operating system backups of the database only when the database is shut down
– You must back up the entire set of datafiles and control files during each backup
– If the online redo log files have been overwritten, you will lose all data since the last full backup
10.01.2010 Administrarea Bazelor de Date I 68
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
ARCHIVELOG Mode
LGWRLGWRRedo
history
052054
Online redolog files
051
052051
053
052054
053
Archived log file051053054
g053
10.01.2010 Administrarea Bazelor de Date I 69
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
ARCHIVELOG Mode
Implications:Th d t b i t t d f l f d t h di f il• The database is protected from loss of data when media failure
occurs
• You can back up the database while it is online
• When a tablespace other that SYSTEM goes offline as a result
of media failure, the remainder of the database remains
available because tablespaces can be recovered while the
database is open
10.01.2010 Administrarea Bazelor de Date I 70
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Changing the Archiving Mode
SHUTDOWN NORMAL/IMMEDIATE/TRANSACTIONAL1
STARTUP MOUNT2 ALTER DATABASE OPEN4
ControlInit.ora Controlfile
ALTER DATABASE ARCHIVELOG 3 Full database backup5
10.01.2010 71Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Automatic and Manual Archivingg
• Automatic archiving: LOG_ARCHIVE_START=TRUE
053 053ARC0
• Manual archiving: LOG_ARCHIVE_START=FALSE
053 053
DBA
10.01.2010 Administrarea Bazelor de Date I 72
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Specifying Multiple ARCn Processesp y g p
• The dynamic parameter LOG ARCHIVE MAX PROCESSES y p _ _ _
controls the number of archive processes started at instance
startupstartup
• A maximum of ten ARCn processes can be specified
Th b f ARC b h d ith ALTER• The number of ARCn processes can be changed with ALTER
SYSTEM
10.01.2010 Administrarea Bazelor de Date I 73
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Stop or Start Additional Archive PProcesses
LOG ARCHIVE MAX PROCESSES = 2
053053ARC1
_ _ _
053
Online redo logsARC2 Archived redo logs
ALTER SYSTEM SET
LOG_ARCHIVE_MAX_PROCESSES = 3;
10.01.2010 Administrarea Bazelor de Date I 74
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Enabling Automatic Archiving at I t St tInstance Startup
Archived A hi d l fil
051 Archived
C t
Archived log files
052
053
Current 053
Online redo logs053ARC0
LOG_ARCHIVE_START=TRUELOG_ARCHIVE_MAX_PROCESSES=n
10.01.2010 Administrarea Bazelor de Date I 75
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Enabling Automatic Archiving After Instance StartupInstance Startup
1
ALTER SYSTEM ARCHIVE LOG START;
2
051 052
ALTER SYSTEM ARCHIVE LOG START;
051 052
051ARC0Online redo logs 3
10.01.2010 Administrarea Bazelor de Date I 76
05
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Steps…
Step Explanation1 Check the status of the ARCn process:p
SQL> ARCHIVE LOG LIST
2 Enable the archiver processes (ARCn):UNIX:SQL ALTER SYSTEM ARCHIVE LOG START SQL> ALTER SYSTEM ARCHIVE LOG START
TO ‘/ORADATA/ARCHIVE1’;Windows:SQL> ALTER SYSTEM ARCHIVELOG START
‘ 04 l E l ’TO ‘c:\u04\Oracle\TEST\log’;
3 The ARCn processes automatically archive log files as they are filled.
10.01.2010 Administrarea Bazelor de Date I 77
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Disabling Automatic Archiving
2Initializationparameters
ALTER SYSTEM ARCHIVE LOG STOP;
1p
051 052
ALTER SYSTEM ARCHIVE LOG STOP;
051 052
051ARC0Online redo logs
10.01.2010 Administrarea Bazelor de Date I 78
05
052
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Steps…
Step Explanation1 Execute the command to stop the ARCn processes, if ARCnp p ,
processes have been already enabled:SQL> ALTER SYSTEM ARCHIVE LOG STOP;
2 Ensure that automatic archiving is not enabled upon instance t t b tti th i iti li ti tstartup by setting the initialization parameter:
LOG_ARCHIVE_START = FALSE
10.01.2010 Administrarea Bazelor de Date I 79
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Manually Archiving Online Redo Log Files
1
ALTER SYSTEM ARCHIVE LOG CURRENT;
051 052 053
051Server
ProcessServer
Process
Online redo logs
0522
10.01.2010 Administrarea Bazelor de Date I 80
0522
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Steps…
Step Explanationp p1 Execute the ALTER SYSTEM SQL command:
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
2 The server process for the user executing the command performs p g pthe archiving of the online redo log files.
10.01.2010 Administrarea Bazelor de Date I 81
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Specifying the Archive Log Destination
• Use LOG_ARCHIVE_DEST_n to specify up to ten archival
d ti tidestinations
• Use LOG_ARCHIVE_FORMAT to include the log sequence
number and thread number as part of the filename
10.01.2010 Administrarea Bazelor de Date I 82
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Specifying Multiple ArchiveLog DestinationsLog Destinations
• Use LOG_ARCHIVE_DEST_n to specify up to ten archival
destinations, which can be on a:
– Local disk
– Remote standby database
log_archive_dest_1 = “LOCATION=/archive1”
Log_archive_dest_2 = “SERVICE=standby_db1”
The service name is resolved using local tnsnames.ora file
10.01.2010 Administrarea Bazelor de Date I 83
You must specify the LOCATION parameter for at least one destination
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
LOG_ARCHIVE_DEST_n Options
• Set archive location as MANDATORY or OPTIONAL
• Define time before retry in case of failures
log archive dest 1 = “LOCATION=/archive/log_archive_dest_1 LOCATION /archive/
MANDATORY REOPEN”
log archive dest 2 = “SERVICE=standby db1g_ _ _ y_
MANDATORY REOPEN=600”
log_archive_dest_3 = “LOCATION=/archive2/
OPTIONAL”
10.01.2010 Administrarea Bazelor de Date I 84
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
LOG_ARCHIVE_DEST_n Options• MANDATORY
– archiving to this destination must complete successfully before an g p yonline redo log file can be overwritten
• OPTIONAL– Implies that an online redo log file can be reused even if it has notImplies that an online redo log file can be reused, even if it has not
been successfully archived to this destination (default)• REOPEN
D t i d h th hi i t d ti ti t b– Determined whether archiving to a destination must be reattempted in case of failure
– Number specified (in seconds) for how long to attempt retrying– Without reopen a failure is reported and no further attempts are
made
10.01.2010 Administrarea Bazelor de Date I 85
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
LOG_ARCHIVE_DEST_n Options• MANDATORY
– archiving to this destination must complete successfully before an g p yonline redo log file can be overwritten
• OPTIONAL– Implies that an online redo log file can be reused even if it has notImplies that an online redo log file can be reused, even if it has not
been successfully archived to this destination (default)• REOPEN
D t i d h th hi i t d ti ti t b– Determined whether archiving to a destination must be reattempted in case of failure
– Number specified (in seconds) for how long to attempt retrying– Without reopen a failure is reported and no further attempts are
made
10.01.2010 Administrarea Bazelor de Date I 86
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Specifying a Minimum Numberof Local Destinationsof Local Destinations
• LOG_ARCHIVE_MIN_SUCCEED_DEST parameter
LOG_ARCHIVE_MIN_SUCCEED_DEST = 2
• An online redo log group can be reused only if:
A hi i h b d t ll d t l ti– Archiving has been done to all mandatory locations
– The number of local locations archived is greater than or equal to
th l f th LOG ARCHIVE MIN SUCCEED DESTthe value of the LOG_ARCHIVE_MIN_SUCCEED_DEST
parameter
10.01.2010 Administrarea Bazelor de Date I 87
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Controlling Archiving to a Destination• An archival destination can be disabled by using the dynamic
initialization parameter LOG_ARCHIVE_DEST_STATE_n
LOG_ARCHIVE_DEST_STATE_2 = DEFER
ALTER SYSTEM SET log_archive_dest_state_3 =
DEFER;
• Archiving to a destination can be enabled again
LOG_ARCHIVE_DEST_STATE_2 = ENABLE
ALTER SYSTEM SET log_archive_dest_state_3 =
ENABLE
10.01.2010 Administrarea Bazelor de Date I 88
ENABLE
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Specifying the Filename FormatOnline redo logs
Group 1 Group 2
051 051Archived log file
052
ARC0 053
052
/ORADATA/archive/arch%s.arc
LOG_ARCHIVE_DEST_n
10.01.2010 Administrarea Bazelor de Date I 89
LOG_ARCHIVE_FORMAT
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Obtaining Archive Log Information
• Dynamic views:
• V$ARCHIVED_LOG• V$ARCHIVE DEST• V$ARCHIVE_DEST• V$LOG_HISTORY• V$DATABASE• V$ARCHIVE_PROCESSES
C d Li• Command Line:
ARCHIVE LOG LIST
10.01.2010 Administrarea Bazelor de Date I 90
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Example…• All archive log destinations, the current value, mode, and
status:
SELECT destination, binding, target, status
FROM v$archive dest;$ _ ;
DESTINATION BINDING TARGET STATUS
--------------------- --------- -------- --------
/db1/ l /DEMO/ h MANDATORY PRIMARY VALID/db1/oracle/DEMO/arch MANDATORY PRIMARY VALID
/db2/oracle/DEMO/arch OPTIONAL PRIMARY DEFERRED
standbyDEMO OPTIONAL STANDBY ERROR
OPTIONAL PRIMARY INACTIVE
OPTIONAL PRIMARY INACTIVE
10.01.2010 Administrarea Bazelor de Date I 91
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Summary
• Configure a database for ARCHIVELOG mode
• Enable automatic archiving
• Perform manual archiving of logs
• Configure multiple archive processes
• Configure multiple destinationsConfigure multiple destinations
10.01.2010 Administrarea Bazelor de Date I 92
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Oracle Recovery Manager
• Identify the features and components of RMAN• Describe the RMAN repository and control file usage• Describe channel allocation• Describe the Media Management Library interfaceg y• Connect to RMAN without the recovery catalog• Configure the RMAN environment
10.01.2010 93Administrarea Bazelor de Date I
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Recovery Manager Featuresy g
• RMAN provides a flexible way to:
– Back up the database, tablespaces, datafiles, control files, and
archive logs
– Store frequently executed backup and recovery operations
– Perform incremental block-level backup
– Skip unused blocks
– Specify limits for backupsp y p
10.01.2010 Administrarea Bazelor de Date I 94
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Recovery Manager Featuresy g
• RMAN provides a flexible way to:
– Detect corrupted blocks during backup
– Increase performance through:
• Automatic parallelization
• Generation of less redo
• Restricting I/O for backups
• Tape streaming
M b k d t k– Manage backup and recovery tasks
10.01.2010 Administrarea Bazelor de Date I 95
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Recovery Manager Components
Server
Targetdatabase Recovery
Manager
Session(polling) Enterprise
Manager
g(RMAN)
ServerSession(rcvcat)
ServerSession
(channel)
ServerSession
(channel) ServerSession
ServerSession
(channel)
( )
MML (default)
Recoverycatalog DB
Disk Disk
MML
10.01.2010 Administrarea Bazelor de Date I 96
Disk Disk
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
RMAN Repository: Using the Control File
• RMAN repository is metadata about target database and
b k d tibackup and recovery operations
• RMAN repository is always stored in the control file of the
target database
• CONTROL_FILE_RECORD_KEEP_TIME determines the
minimum age in days of a record before it can be overwritten
• The control file can grow in sizeg
10.01.2010 Administrarea Bazelor de Date I 97
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Channel Allocation
Di k
S
Disk
ServerSession
ServerSession
Targetdatabase
Channel (sbt)
Channel (disk)RMAN
Session Channel (sbt)
10.01.2010 Administrarea Bazelor de Date I 98
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Automatic Channel Allocation• Change the default device type:
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO bt
• Configure parallelism for automatic channels:
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt;
• Configure automatic channel options:
RMAN> CONFIGURE DEFAULT TYPE DISK PARALLELISM 3;
Configure automatic channel options:
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK
2> FORMAT = ‘/BACKUP/RMAN/%U’;2> FORMAT /BACKUP/RMAN/%U ;
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK
2> MAXPIECESIZE 2G;
10.01.2010 Administrarea Bazelor de Date I 99
2> MAXPIECESIZE 2G;
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Manual Channel Allocation
• BACKUP, COPY, RESTORE, and RECOVER commands require at least one channelrequire at least one channel.
• Allocating a channel starts a server process on the target database.
• Channels affect the degree of parallelism.• Channels write to different media types.• Channels can be used to impose limitsChannels can be used to impose limits.
RMAN> RUN {
2> ALLOCATE CHANNEL 1 TYPE di k2> ALLOCATE CHANNEL c1 TYPE disk
3> FORMAT = ‘/db01/BACKUP/usr0520.bak’;
4> BACKUP DATAFILE ‘/db01/ORADATA/users01.dbf’
10.01.2010 Administrarea Bazelor de Date I 100
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Media Management
Recovery Oracle server Media managementgManager session ylibrary
Media managementserver software
Tape library org psingle tape
10.01.2010 Administrarea Bazelor de Date I 101
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Types of Connections with RMAN
• Target database
• Recovery catalog database
• Auxiliary database
– Standby database
– Duplicate database
– TSPITR instance (tablespace point-in-time recovery)
10.01.2010 Administrarea Bazelor de Date I 102
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Connecting Without a Recovery CatalogTarget
database
Serverprocess(polling)
Serverprocess(default)
Recoverymanager(RMAN)
• Starting RMAN locally
UNIX: $ ORACLE_SID=DB01; export ORACLE_SID
$ t t / db
• Starting RMAN locally
$ rman target / as sysdba
Windows NT: c:\> set ORACLE_SID=DB01
c:\> rman target / as sysdba
• Starting RMAN remotely
/
10.01.2010 Administrarea Bazelor de Date I 103
rman target sys/target_pwd@DB01
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Additional RMAN CommandLi A tLine Arguments
• Writing RMAN output to a log file:Writing RMAN output to a log file:
$ rman target sys/oracle
log $HOME/ORADATA/u03/rman.log append
• Executing a command file when RMAN is invoked:
g g pp
$ rman target sys/oracle
log $HOME/ORADATA/u03/rman.log append
@’$HOME/STUDENT/LABS/my rman script rcv’@ $HOME/STUDENT/LABS/my_rman_script.rcv
10.01.2010 Administrarea Bazelor de Date I 104
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Recovery Manager Modes
• Interactive mode
– Use it when doing analysis
– Minimize regular usage
– Avoid using with log option
• Batch mode
– Meant for automated jobs
– Minimize operator errors
– Set the log file to obtain information
10.01.2010 Administrarea Bazelor de Date I 105
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
RMAN Commands
RMAN commands are of the following types:CHANGE
• Stand-alone
– Executed only at the RMAN prompt
CONNECTCREATE CATALOGRESYNC CATALOG
CREATE SCRIPTDELETE SCRIPT
– Executed individually
– Cannot appear as subcommands within RUN
DELETE SCRIPTREPLACE SCRIPT
• Job
– Must be within the brackets of RUN
– Executed as a group
10.01.2010 Administrarea Bazelor de Date I 106
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Job Command: Example
RUN command:RUN command:
RMAN> RUN {
backupp
incremental level 0
format ‘/u01/db01/backup/%d_%s_%p’
fil t 5fileperset 5
(database include current controlfile);
sql ‘alter database archive log current’;
}
10.01.2010 Administrarea Bazelor de Date I 107
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
RMAN Configuration Settings
• RMAN is preset with default configuration settings
• Use the CONFIGURE command to:
– Configure automatic channels
– Specify the backup retention policy
– Specify the number of backup copies to be created
– Limit the size of backup sets
– Exempt a tablespace from backup
– Enable and disable backup optimization
10.01.2010 Administrarea Bazelor de Date I 108
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
The CONFIGURE Command
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT
• Configure automatic channels:
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT
‘/db01/BACKUP/%U’;
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY
2> WINDOW OF 7 DAYS;
• Implement retention policy by specifying a recovery window:
2> WINDOW OF 7 DAYS;
• Implement retention policy by specifying redundancy:
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
10.01.2010 Administrarea Bazelor de Date I 109
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
The CONFIGURE Command• Configure duplexed backup sets:
RMAN> CONFIGURE DATAFILE BACKUP COPIES FORRMAN> CONFIGURE DATAFILE BACKUP COPIES FOR
2> DEVICE TYPE disk TO 2;
• Configure backup optimization:
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
• Use the CLEAR option to return to the default:
RMAN> CONFIGURE RETENTION POLICY CLEAR;RMAN> CONFIGURE RETENTION POLICY CLEAR;
RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt CLEAR;
10.01.2010 Administrarea Bazelor de Date I 110
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
The SHOW CommandThe SHOW Command
• Displays a persistent configuration settingsp y p g g• Use the SHOW command to display:
– Automatic channel configuration settingsBackup retention policy settings
SHOW CHANNEL
SHOW DEVICE TYPE– Backup retention policy settings– Number of backup copies to be created– Backup set size limit
SHOW DEVICE TYPE
SHOW RETENTION POLICY– Tablespace excluded fro backups– Backup optimization status
• Use SHOW ALL to display all settings:Use SHOW ALL to display all settings:
RMAN> SHOW ALL;
10.01.2010 Administrarea Bazelor de Date I 111
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
LIST Command Operations
• Lists backup sets and copies of datafiles
• Lists backup sets and copies of any datafile for a specified
tablespace
• Lists backup sets and copies containing archive logs for a
specified range
10.01.2010 Administrarea Bazelor de Date I 112
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
The LIST Command• List backups of all files in the database
RMAN> LIST BACKUP OF DATABASE
• List all backup sets containing the users01.dbf datafile:
RMAN> LIST BACKUP OF DATABASE;
•RMAN> LIST BACKUP OF DATAFILE
2> “/db01/ORADATA/u03/users01.dbf”;
• List all copies of datafiles in the SYSTEM
RMAN> LIST COPY OF TABLESPACE “SYSTEM”;
10.01.2010 Administrarea Bazelor de Date I 113
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
The REPORT Command
• Produces a detailed analysis of the repository
• Produces reports to answer:
– Which files need a backup?
– Which backups can be deleted?
– Which files are unrecoverable?
10.01.2010 Administrarea Bazelor de Date I 114
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
RMAN Usage Considerations
• Resources: Shared memory, more processes
• Privileges given to users:
– Database: SYSDBA
– Operating System: Access to devices
• Remote operations
– Set up the password file
– Ensure that the password file is backed upp p
• Globalization environment variables
• Format used for the time parameters in RMAN commands• Format used for the time parameters in RMAN commands
10.01.2010 Administrarea Bazelor de Date I 115
Universitatea Politehnica Bucureşti - Facultatea de Automatica si Calculatoare
Summary
• Configure the RMAN environment
• Use automatic channel allocation
• Manually allocate channels
• Connect to RMAN without the recovery catalog
• Retrieve information from the RMAN repositoryRetrieve information from the RMAN repository
10.01.2010 Administrarea Bazelor de Date I 116