Professional Documents
Culture Documents
Oracle Net configuration Assitant - to configure Listerner names and protocols, naming
methods the client will use to resolve connect identifiers, net services names in a
tnsnames.ora, directory server access.
Oracle Net manager – It is use to configure and manage oracle networking. The
components are Service naming - create or modify network descriptions for database
services in a tnsnames.ora file, directory server, or an oracle names server, Listener –
process on server for communication with client requests, profile – client parameters,
Oracle name server – create modify configuration settings on oracle name server
Oracle Net Connections
Client server Application – Oracle net enables connection between client and server it
resides on client and server it is layered on top of network protocol.
The layer – Client - Client application (OCI), two task common, oracle net foundation
layer, oracle protocol support, network protocol.
Database server – Network protocol, oracle protocol support, oracle net foundation layer
two task common , oracle RDMS, (OPI).
Client application – uses OCI (Oracle call interface) to communicate with the server it
provides an interface between client application and server application (SQL).
Two Task common – it does character set and data type conversion between character set
or formats on the client and server it is in presentation layer.
Oracle Net foundation layer – Responsible for establishing and maintaing connection
between serever and client, location of server, whether one or more connection is
involved, how to handle exception and interrupts.
Oracle Protocol support – TCP/IP, TCP/IP with ssl, Named Pipes, LU6.2, Virtual
Interface
Web client Application connections – web browsers can connect to an oracle server
using JDBC Oracle call interface driver, connect directly by using IIOP and HTTP.
Application Web server Java Application – Java application, JDBC OCI driver, TTC,
Oracle Net foundation Layer, Oracle Protocol stack, Network protocol.
Database Server - Network protocol, Oracle Protocol stack, Oracle Net foundation Layer,
TTC, Oracle RDBMS.
Application Web server Java Applet Client - Java appllet, JDBC thin driver, JavaTTC,
Java net , TCP/IP Network protocol.
Database Server - TCP/IP Network protocol, Oracle Protocol stack, Oracle Net
foundation Layer, TTC, Oracle RDBMS.
Web application connection NO middle tier- Using HTTP and IIOP client can directly
communicate with server. Listener can be configured to accept HTTP and IIOP
connections, HTTP is used to access Oracle Internet File System and IIOP to connections
to Enterprise Java beans and Common object request Broker (CORBA) applications.
Connectivity concepts and terminology - Database services - service name a LOGICAL
representation of a database, the way a database is presented to clients, Connect
Descriptor – Location of the database, name of the database service, Listner – receives
client connection requests, hands request to the database server.
Service registration – database registers information with the listener, service handlers
available for each instance. Service Handlers – connection points or dedicated server
Oracle Net configuration files – ldap.ora Located on the database server and client
parametes to access directory server. Listener.ora located on database server config file
includes, protocol addresses it is accepting connection request, database and nodatabase
services it is listening for, control pramaeters used by the listener. Names.ora located on
names server includes location of domain info and optional config prameters of name
server. Sqlnet.ora located on database and client end. Tnsnames.ora locate don client file
contains net service names mapped to connect descriptors.
Chapter -3 Basic oracle net server side configuration
Listener Process – Listener process can listen for incoming connections on behalf of a
database or a number of databases. It can listen for more than one database, multiple
listeners can listen for one database, It can listen for multiple protocols, the name of the
listener must be unique per listener.ora file.
Connection Methods
Spawn and Bequeth – the listener pass or bequeath the connection to a spawned process,
this is only in deirect server config. Direct Hans-off - Listener will hand off a connection
to a dispatcher when an oracle shared server is used (only shared server). Redirected
(Message) –A connection may be redirected by the listener to a dispatcher if a shared
server is used. Whether the session is bequeathed, handed off or redirected it is
transparent to the user.
Spawn and Bequeath and Direct Hand-off connections – the ability is depended on OS,
when listener forks a dedicated server process and bequeaths connection to the server
process it is called bequeath session
Direct hand-off with oracle shared server – if the OS handles as server connection and
bequeaths the to the server process it si dorect hand-off conencttion.
Redirected session- In redirect client establishes by sending connect packet, the listener
chscks sid and opens a new process to service the new connection, An IPC is established
between the new process. The new process slects a new tcp/ip port and passes to the
listener, the listener inserts this new port int to redirect packet and sends it back to the
client and original TCP socket between client and listener is reset. A new TCP
connection is established to the redirected packet address.. the dedicated process can now
finally accept the incoming sonnection and forward an accept message.
Dedicated – The user process and server process are separate, each user process has its
own server process, the user and server process can run on different machine to take
advantage of distributed processing, ther is one-to-one ration between user and server
processes, when there is no request the dedicated server exists but remain idle.
Oracle Shared server – This config enables shared servers and dedicated servers and
combined users and servers exist with the same instance, Here client user processes
connect to a dispatcher, The PMON process registers the location and load of the
dispatchers with the listeners, enabling the listener to forward the request tot the least
utilized dispatcher. A dispatcher can support multiple client connections concurrently,
every client connections are virtual circuit. A virtual circuit is a piece of shared memory
used by dispatcher for client database connection request and replies. It places the VC in
a common queue, then the shared server picks up the VC from the common queue
services and relinqueses the VC before attempting to retrieve another VC. Dispatchers
can work only on TCP/IP.
Benefits – Reduces the no of processes against an instance, increases the no of possible
users, achieve load balancing, reduces the no of idle server processes, reduce memory
usage and system overhead.
Using a dedicated server with the oracle shared server – when submitting batch jobs or
connecting as sysdba to startup,shutdown, recovery we can use dedicated server. To
request a dedicated server, the clause server=dedicated should be given in Oracle TNS
connection string in tnsnames.ora.
Connecting to an oracle shared server - the listener process waits for any connection
requests from user process, when a request is there, the listener determines whether to
connect the user process to a dispatcher or assign to a dedicated server process. If the user
process is connected to a dispatcher the listener process gives the use process address of
the dispatcher process, if the user process requests a dedicated server the listener creates a
dedicated server process and connects the user process to it. Once the connection has
established either through dispatcher or dedicated the connection is maintained for the
duration of the session.
Processing a request – A user sends a request to its dispatcher, the disp places the req
queue in the SGA, Shared server picks up the request from the request queue and
processes, the shared server places the response on the calling dispatcher response queue,
the response is handed off to dispatcher, the dispatcher returns the response to the user.
Request quqe- One request queue is shaerd by all dispatchers, shared server monitor the
request queue for new one, request are processed in FIFO basis, shared servers place all
completed requests on all calling dispatchers queue, each dispatcher has its own respone
queue in SGA , dispatcher is responsible for sending back to the user, user are connected
to the same dispatcher for the session.
Verifying setup – verify tha the dispatchers has registerd with the listener when the
instance was started by issuing lsnrctl services. Verify that you are connected using
shared servers by making a single connection then query v$circuit view to show one
entry per shared server connection.
Dynamic –view - V$circut, v$shared_server, v$diaptcher, v$shared_server_monitor
(tunning of shared server process), v$queue, v$session.
Chapter – 6 Backup and recovery Issues
Resolutions for Statement failures – Correct the logical flow of the program, Modify and
reissue the SQL statement, Provide the necessary database privileges, change the user
quota limit by using the Alter User command, Add file space to the tablespace, Enable
resumable space allocation.
Causes for User process failures - User performed an abnormal disconnect in the session,
the use session was abnormally terminated, user’s program raised an address exception
which terminated the session.
Resolution of user process failures – The PMON process detects an abnormally
terminated user process, PMON rolls back the transaction and releases any resources and
locks being held by it.
Possible user errors _ User accidentally drops or truncates a table, User deletes all rows in
a table, User commits data, but discovers an error in the committed data.
Resolution of user errors – Train the database users, 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 flash
back to view and repair historical data.
Instance failure – It can happen for lot of reasons, Power outage, Hardare problems,
Oracle server background process. Recovery is automatic, once you start the databse
oracle server will perform both roll forward and roll back phases, we can monitor the
alert log to find the reasons.
Causes of Media failure – Head crash on a disk drive, physical problems in reading from
or writing to database files, file was accidentally erased. Resoultions – Recovery stratergy
depends on which backup method was chosen and which files are affected, If available,
apply archived redo log files to recover data committed since the last backup.
Define a backup and recovery stratergy – Business requirements – ( Mean time to
recover, Mean time between failure, Evolutionary process) , operational requirements
( 24 hour operations, testing and validating backups, database volatility), technical
considerations (Resources – hardware, software, manpower and time, Physical images
copies of the OS files, Logical copuies of the objects in the database, Database
configuration, Transaction volume which affects desired frequency of backup),
management concurrence.
Disaster recovery Issues – how will business be affected in event of major disaster like
eqrthquake, fire or flood- complete loss of machine-malfunction of storage hardware or
software, - loss of key personnel, such as DBA. Planning for DRP.
Chapter – 7 Instance and Media Recovery Structures
Memory Structures
Database Buffer – Memory area used to store blocks read from data files, data is read into
the block by server processes and written out by DBWn asynchronously
Log-buufer – Memory containing before and after image copies oc hanged data to be
written to the redo logs
Large-pool – Optional area in SGA, large memory for backup,restore, I?O operations,
shared memory for shared server.
Shared pool – stores parsed version of sql statements, PL/SQL procedures and DD info.
Java poll- Java code and data within JAVA VM.
Backgorund Processes
Large _ pool – Can be configured as a separate memory area in the SGA , used for Oracle
backup and restore operations, I/O Ptocess, session memory for shared servers, Is sized
by the large_pool_size parameter. RMAN use large pool for backup and rstore, If large
pool is set oracle tries to get memory from shared pool, it does not get buffers from
shared pool, If not able to get memory then it obtains from i/o buffer memory from local
prcess memory and writes in alert file.
Large pool parameters
Large_pool_size if not set ther is no large pool can get details from v$sgastat
Dbwr_io_slaves - it is set above 0 the no of slaves used by Aarcn, lgwr, and recovery
manager process are set to 4.
Backup_tape_io_slaves – it is used to backup,copy or restore data to tape. Value true or
false.
Database Buffer cache – DB cache is an area in SGA is used to store recently used data
blocks, the server process reads tables, indexes, and undo segments from datafiles into
the buffer cache where it makes changes to data blocks when required, It uses LRU
algorithm to determine which can be overwritten to accomadate new blocks.
DBWn background process - Database writer process writes dirty buffers from database
buffers cache to datafiles., it makes sure that sufficient no of free buffers are available in
db cache, the database writer synchronizes db cache and the datfiles, this checkpoint
event triggered in various situations, you can configure multiple dbwn but one is enough.
Datafiles – I contains both system and user data and can contain committed and
uncommitted data.
Tablespaces – It can contain one or more datfiles, It shold have system, temporary, undo,
read-only, index data tablespaces.
Redo Log buffer – It is a circular buffer that hold info about changes made to the
database, It is stored in redo entries., It contains info to redo changes made to the
database by insert,delete,uodate, create, alter, drop, redo entries are copied by oracle
server process from user memory space to redo log buffer.
LGWR – It writes redo entries from redolog buffer to redo log files, when , redo log
buffer is one-third full, when a time-out occurs, there is 1 MB of redo, before dbwn
writes modified blocks in the db cache to datafiles, when a transaction commits.
Redolog files – It stores al changes made to the database, if databse is recovered, to a
pint in time, when it was operational redo logs are used, LGWR writes to redo log files in
circular fashion, two log groups are necessary.
REDO log switches - At log switch current redo log group is assigned a log sequence no
that identifies the info stored in that redo log group, It happens when lgwr stops writing
to one redo log group and begin wrting to another, when it has filled one group, using
alter system we can switch, a checkpoint occurs at logswitch, processing can continue if
at least one group is available.
Dynamic views – V$log (group no, seq no, size of group, no of members, status,
checkpoint change nos,), v$logfiles (list names, status and group of each log file)]
V$log_history (contains log history form control file)
Multiplexed Redo Log files – Redo log file reuires at least 2 redo log members per group,
all members contain identical information,they are updated simultaneously, each group
should have the same no of members of the same size., the oracle server changes only
pointer in control files afte renaming the files. To change the location, switch the log file,
copy the logfile using os to a new location, using alter database rename file to make
chage in control file. We can also add a member by add database add logfile member to
group, we can laod drop by alter database drop logfile member filename, you cannot drop
in current or active redo log group.
Checkpoint – checkpoint are used to determine where recovery should start, checkpoint
position – where recovery styarts, it is the distance between it and the end of the redo log.
Checkpoint queue – a link list of dirty blocks arranged in order by when the block was
first dirtied. Each entry in queue includes identifier of data block and location of redo log
where block was first dirtied called the RBA, the first entry in this identifies the oldest
dirty block in db cache.
Type of checkpoints –
Full checkpoint – All dirty buffers are written, shutdown normal, immediate,
transactional. Alter system checkpoint
Incremental checkpoint – periodic writes, only writes the oldest blocks
Partial checkpoint – Dirty buffers belonging to the tablespace, alter tablespace begin
backup, alter tablespace tablespace offline normal.
CKPT process - It is responsible form making DBWn at checkpoints and updating the
datfils and control files, it does evry 3 seconds and records the rba, rba represents the
point in redlog at which instance recovery is to begin in case of failure, I n case of log
switch it writes the info to the headers of the datafiles.
Multiplexed control files - Control file is a binary file which describes the structure of
the database, It should be always available, ,one file is enough it is recommended to have
atleast 2 files. Control file contents – Database name, time stamp of creation,
synchronization information needed for recovery, names and location of data files and
redolog files, archiving mode of database, current log sequence no, recovery manager
backup meta data. We can query form select name form v$controlfile for name and
location.
ARCn Process and Archived Log files. The ARCn is an optional process it is used
archive redo log files, it is useful in backup and recover where dataset should be
operation 7*24 hrs, It initiates when a log switch occurs and copies one member of the
last edo group to destinations specified., The LGWR waits till the online redo log file is
archived before it will be reused, If one is corrupt another member is used.
Database Synchronization – All data files (except offline and read-only) must be
synchronized for the databse to open, synchronization is based on the current checkpoint
no, applying changes recorded in the redo log files synchronizes datafile, redo log file are
automatically requested by oracle server.
Phases for Instance Recovery - Datafiles out-of synch, roll forward (redo) all chages
recorded in redo log files since the checkpoint are reapplied to datafiles, also regenerates
rollback data, committed and non-committed data files and opens data, roll back (undo)
phase any changes not committed are rolled back, contains only committed data in files.
Tunning crash and instance recovery performance – Tunning duration of instance and
crash recovery, tunning the phases of instance recovery, tunning can be done by
advancing checkpoint by only a few blocks behind the most recent redo log record, but it
may affect performance. Set initialization parameters to influence the no of redo log
records and data blocks involved in recovery, size the redo log file to influence
checkpointing frequency. Issue sql statements to intitiate checkpoints, parallelize instance
recovery operations.
Archivelog mode – It copies from online redo log file to archived log file. The database is
protected from loss of data when media failure occurs, you can backup when it is online,
when other than system tablespace goes off , we can recover while database is open.
Media Recovery options – Can restore a backup copy of the damaged files and use
archived log files to bring datafiles up to date when it is offline or online. You can
recover database at a specific point of time. You can recover database to the end of a
specified archived log file. You can recover to a specific SCN.
A user must have alter system privilege to alter the archivelog mode
To change the mode – shutdown the database in normal,immediate, transactional. Start
the database in mount state so that we can alter in archieve mode startup mount. Set the
database in archieve log mode by using alter database command, alter database
archievelog. Open the database alter database open. Take a full backup of the database.
Form now the old backup will be of no use, the new backup will be used in which future
archieved log file wil apply. This not enable the archieve process.
Setting the archieve mode – Automatic and Manual . In automatic ARCn process are
enabled and they copy redo log files as they are filled, In manual we have to copy the
files. Before deciding on archieve mode you muset set database in archievelog mode,
failure to do this will prevent from copying redo log files, the database should be
shutdown cleanly before enabling archive process.
An archival destination can be disabled by using the dynamic initlization parameter alter
system set log_archive_dest_state_2 = defer and can be enable again by alter system set
log_archive_dest_state_2 = enable.
Recovery manager features - RMAN provides a flexible way in backing up the database,
tablespaces, datafiles, control files and archive logs, stor frequently executed backup and
recovery operations, perform incremental block level backup, skip unused blocks, specify
limits for backups. RMAN is command line utility , OEM provides an graphical
interface, it provides lot of features like storing frequently executed operations as scripts
in database. Using incremental block-level backup feature you can limit backup to only
those blocks that have changed since previous backup, can use rman to manage size of
backup pieces and save time by parallelizing the backup operation, RMAN operations
can be integrated with scheduling of the OS to automate backup operations.
Other features – detect corrupted blocks during backup, increase performance through
automatic parallelization, generation of less redo, restricting I/O for backups, tape
streaming. Manage backup and recovery tasks.
Recovery Manager Components – Recovery manager executable, OREM, server
sessions, target database, rman repository (data used by rman for backup and restore are
called as rman metadata, channel, media management library ( used for reading and
writing in tapes)
RMAN Repository – Using the control file. RMAN is repository is metadata about target
database and backup 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 size, before it grows certain steps are performed free space in control file is used,
entries older than control_file_record_keep_time are overwritten, if no more space is
there the control file grows and reaches till ops max file size.
Media Management – to use tapes for backup storage oracle requires media manager.
This is useful for loading tapes, labels and unloads sequentaial media such as taped drives
for the backup and restore. The oracle call MML routines for this purpose.. MML is not
required if it has to backup to data. Oracle backup solutions program provides a range of
media managements products.
Procedures – 1. Install and configure MM software on the server. 2. Ensure that we can
take normal flat files backup. Obtain and install media management software for other
vendors and install..
MM handles restore as well as abackup operations – The server requests the restor of a
particular file. MM identifies the tape conftaining the file and reads the tape, MM passes
the info back to the oracle server, Oracle session writes the file to the disk.
Type of connections with RMAN – Target database (taget database with sysdba
privileges). Recovery catalog database (Optional database which is configured for
RMAN repository. Auxillary database (It is created by using RMAN Duplicate
command, or it can be temp databae used during tablespace point in time recovery. A
standby database is a copy of your production database that can be used for disaster
recovery.
Connecting to the target database without a catalog
Local connection - Set oracle_sid=orcl , rman target / notalog
Remote connection – rman sys / target_pwd@db01
Connection Process - A user process is created for recovery manager, It creates 2 server
processes, Onec connected to the target database for executing sql commands
resynchronizing the control file and recovery roll forward, One polling process connected
to the target database to locate RPC completions, backup and recovery info is retrieved
from control file.
RMAN Commands –
Stand Alone commands - Executed only at the RMAN Prompt, executed individually,
cannot appear as subcommands within run. Eg. Change, connect , create catalog, resync
catalog, created script, delete script, replace script, report schema.
Job – Must be within brackets of run, executed as a group.
Configuring automatic channels - RMAN> configure channel device type disk format
‘/db01/backup/%u’; Implement retention policy by specifying a recovery windows –
rman > configure retention policy to recovery windows of 7 days; implement retention
policy by specifying redundancy – RMAN > configure retention policy to redundancy 2;
You can implement retention policy in one of the following mutually exclusive ways –
specify a recovery windows, specify a redundancy value.
List command – List backup sets and copies of datafiles, Lists backup set and copies of
any datafile for a specified tablespace, List backup sets and copies containing archive
logs for a specified range.
List backup of all files in database – rman > list backup of database.
List backup sets containing in the user01.dbf – List backup of dtafile ‘/u01/usr01.dbf’;
List all copies of datafiles in the system tablespace – List copy of tablespace “system”;
Report command – Produces a detailed analysis of repository, files need a backup, which
backup files can be deleted, which files are unrecoverable.
RMAN > Report schema; report need backup; report obsolete; report unrecoverable;
Report need backup – Lista all datafile requiring a backup, Assumes most recent backup
is used during a restore, Provides 3 options – incremental,daya, redundancy. Without
option takes into account the configure retention policy.
RMAN> report need backup incremental 3; report need backup days 3; report need
backup redundancy 3;
Recoveyr Manager uses PL?SQL packages as its interfae to : target databases, the
recovery catalog. These packages are dbms_rcvcat – to maintain info in the recvery
catalog, ddms_rcvman – queries the control file or recovery catalog, the 2 packages are
created catproc.sql.
DBMS_backup_restore package is created by dbmsbrks.sql, prvtbkrs.sql called by
catproc.sql –thi spackage is uses to interface with oracle and os to create restore and
recover backup of datafiles and archived redolog files.
Whole Database backup - Target database may be opened or closed, backup of all
datafiles and the control file. Whole database is taken when it is closed by
normal,transactional or immediate. If it is in abort mode the databse is inconsistent so
recover is required for the database. When database is shoule be available 7*24 then we
have to use inconsistent backup and this can be performed only on database running in
Archivelog mode.
Partial Database backups – Tablespace, datafile, control file. Table spaces backup can be
done only in archiovelog mode, because redo entires are required to make it consistent,
Data file backup - Single datafile canbe backed up in archivelog mode in no archive
mode we can do when is reead-only or closed mode.
Control file - we can configure automatically EMAN to copy control file aftear a copy or
backup, It can be backed htroguh sql commands.
User Managed Backup and recovery - Files are backed up with OS commands, Backups
are restored with OS system commands, recovery is done through using sql/plus
commands.. Oracle recommends RMAN
Query Views obtain Database File information
V$datafile (name, status), $controlfile (name), V$logifle, dba_data_files
Backup Methods – OS backup without archiving is used to recover to the point of last
backup after media failure. OS backup with archiving is used to recover to the point of
failure after a media failure.
Consistent whole database backup (closed) – this backup is taken when the database is in
closed mode, It can include, redo log files, parameter files and password file. We need to
ensure that complete pathnames are noted ans used properly when backup and recovery
Advantages of whole database backup – conceptually simple, easy t perform, require
little operator interaction
Performing an consistent whole backup – compile the files need to backed up. Shutdown
oracle in normal, transactional or in immediate mode, backup all dtafiles, control files,
using backup utility , retart oracle instance.
Open database backup - If buiness requires 24*7 then we can have only open backup,
Perform backups of all tablespaces or datafiles while they are online or offline, online
redo files are not required to backup.It has advantages like maintains high databse
availability, can be done at tabelspace or datafile level, supports nonstop business
operations. Considerations – More training is required for the DBA, tested and
automated scripts are recommended for performing open database backups. Open
Database backup requirements – Database is et to archivelog mode, ensuring online redo
log files are archived by ARCn process or by manually archiving redo log files.
Open Database Backup Options – We can enable backup pf all datafiles of a specific
tablespace, or an individual datafile of an tablespace, the database is online and available
for transactions. When datafile is placed in backup mode, more redo log entries can be
generated because logwrtr blocks images of changed blocks of datafile in backup mode
to the redo log instead of row information. This can have effect in performance of log
writer.
Performing an online tablespace backup
1. Set the datafile or tablespace in backup mode by issuing alter tablespace name
begin backup . this prevents sequence no in datafile header from changing, so that
logs are applied in recovery from backup start time. Even in backup mode it is
available for normal transaction.
2. Use an OS command to copy all the datafile in the tablespace to backup storage,
the log sequence in backup files can be different when each tablespace is backed
up sequentially. Copy c:\uers\users01.dbf e:\users\users01.dbf
3. 3. After the datafiles are copied issue the command alter tablespace users end
backup.
4. Archive the unarchived redo logs so that the redo required to recover thee
tablespace backup is archived as follows. Alter system archive log current..
We can do for all tablespace including system and undo tablespaces. The time
between start and end backup command should be minimized. It is required to
perform on tablespace at a time.
Failure during Online tablespace backup - system may crash, databse may be shutdown
or any major events may happen. If any happens then the backup files will be unusable if
the OS did not complete the backup, we need to backup again. The databse files in
online backup will not be synchronized with databse because the header is frozen when
backup starts. The databse will not open because server assumes that file have been
restored form backup. We need to use alter database end backup to take the datafile out
of backup mode. We should use only when you are sure that file were put in backup
mode not restored from backup.
Ending Online backup during failure – query the V$backup to check backup status. Issue
the alter databse command to change the status and unfreeze the header (Alter databse
‘filename’ end backup; or alter databse end backup in 9i. Now we can open the the
database – alter database open.
Read-only tablespace – alter tablespace quer_data read only.
Read-only tablespace operations. – 1. status of tablespace from read-write to read-only by
using alter tablespace query_data read only. 2. Alter tablespace command is issued a
checkpoint is performed for all datafiles associated with the tablespace. The file headers
are frozen with the curren SCN. 3. When we make tablespace read only we must backup
all datafile in the tablespace. 4. DBW0 process writes only to datafiles whose tablespaces
are in read-wrie mode and normal checkpoints occur in these files.
Read-only tablespace backup issues – Only one backup is needed after altering tablespace
to read-only, resume a normal backup schedule for that tablespace after making it read-
write. The control file must correctly identify the tablespace in rad-only mode otherwise
you must recover it. Because no writes are performed on read-only atbelspaces it can be
recovered is when they are damaged.
Manual control file backups – Creating a binary image – alter database backup controlfile
to ‘control1.bkp’; Creating a text trace file Alter database backup controlfile to trace;.
If rman is not used we hould manually take backup of control file. Certain info in control
file like names of database current online redo log file is used by server during instance
or media recovery.
Guidelines – Multiples control file and name them in init.ora file by using control files
parameter. Alter database backup controlfile to trace command creates a script script to
re create control file, the file is located in dir specified in user_dump_dest, It does not
contain rman metadata. We can also backup using alter database backup control file
command, this provides a binary copy o fcontrol file. During full backup shut down
instance and backup the control file.
Backing up Initlization parameter file – Create Pfile form SPFILE. Create PFILE
=’/backup/init.ora’ from spfile; . We can use create pfile command to create backup of
server parameter file, It exports the file in an text format . we can create the file in
default location or in specified location.
Verifying Backups using DBVERFIY utility – This utility enable syou to perform
verification of datafile by checking the structural integrity of data blocks within specified
datafiles, it is external to database. 1. Utility can be used to verify online dtaafiles. 2. can
invoke the utility on a portion of a datafile. 3. Utility can be used to verofy offline
datafiles,. 4. Can direct output of the utility to an error log..
Command line interface – Extenal –command utility. Used to ensure that a backup
database or datafile Is valid before a restore. Can be helpful diagnostic aid when data
corruption problems are encounterd
Eg. Dbv file =/oradata/user01.dbf start=1 end =500 – this checks integrity for user01.dbf
starting form block 1 to block 500.
Dbverify parameters – file (database file name), start (start block size), end (end block
address), blocksize (reqd only if file has block soze greater than 2 KB), logfile (logging
information), feedback (causes to display a single . for n pages verified), help (on-screen
help), parfile (species name of parameter file to use.
Chapter 11 – RMAN Backups
Charaterestics of backup sets – Backup command creates backup sets, backup sets
usually contain more than one file, backup sets can be written to a disk or tape. A rstore
operation is required to extract files form a backup set. Datafile backup sets can be
incremental or full. Backup sets do not include never-used blocks. Archived redo log file
backup sets cannot be incremental.
Backup Piece – A backup piece is a file in a backup set. A backup piece can contain
blocks from more than one datafile. For large database a backup set can exceed one tape
or os file, size of each piece can be limited by maxpiecesize with configure channel ot
allocate channel commands.
Backup piece size can be limited as follows RMAN > Run { allocate chanel t1 type ‘sbt’
maxpiecesize = 4g; backup format ‘df_%t_%s_%p’ filesperset 3 (tablespace users)).
We can control no of backup sets that the server produces as well as the no of file that
RMAN places into a single backup set. When using backup command we must mount or
open the target database, recovery manager allows us to make an inconsistent backup if
the database us un archive log mode, then we should apply redo logs to make it
consistent. Manual allocation is reqd if automatic allocation is not doen for the channel.
We can include control file by using include current controlfile option.
Command Options
Full – copies all blocks, skips blocks not uses. It does not skip blocks when backing
archived logs or conteol files
Incremental level integer - The session copies data blocks that have changed since last
incremental n backup where n is integer form 1 to 4. when incremtal is choosen it checks
for level 0 backup, if incremental is set then parameters like data file, data filecopy,
tablespace or database .
Filesperset integer – It compares filesperset value to a calculated value ( no of files
backed up per channel) and takes the lower of 2 ther by ensuring all channels. If
fileperset is not specified Default is 64 and takes the lower value of the 2
Skip – skip some data files or archived logfiles.
Maxsetsize integer – specifies maximum size of backup set in KB,M,G.
Diskration integer – To assign only dtafiles to backup sets spread across the specified no
of drives , useful when datafile is tripped and stored in different HDD.
Delet input – deletes input file upon successful creation od backup set only on archived
log files and data files.
Include current control file- takes snapshot of current control file.
Format – format of the name of the output
%c – specifies the copy no of backup piece, %P – specified backup piece no within
backup set. %S – specifies backup set no, the number is a counter in control file.
%d – specifes database name
%m – database name padded on right with x xharacters up to 8
%t – specifies backup set time stamp, %u – specifies 8 charater name constituted by
backup set no and time %U – specifies a convenient shothand fo %u_%p_%c guarantees
uniqueness in file name.
Multiplexed Backup Sets. – Multiplexing two or more datafiles into a backup set for tape
streaming. It is controlled by The FILEPERSET parameter on backup command and the
MAXOPENFILES parameter of the allocate channel and configure channel commands.
Parallelization of backup sets – In configure command we can set parallelism it
parallelizes its operation and erites multiple backup sets in parallel, when multiple
backup I screated and allocate multiple channels, it automatically parallelizes. Parallelism
of backup set is achieved by configuring parallelism to greater than 1 or allocating
multiple channels.
Duplexed Backup sets – we can create up to four identical copies of each backup piece by
duplexing the backup set, we can use following commands.
Backup copies, set backup copies , configure … backup copies.
Eg. Eman > backup copies 2 datafile 1, datafile 2 format ‘/backup/%u’,’/backup1/%u’; .
Her it places one copy in backup and backup 1 identical copies. We can also backup of
backup set as an additional way to manage your backups. We can use RMAN backup
backupset command for disk to disk and disk to tape backup.
Archived Redo Log File Backups – Online redo log file switch is automatic, Archived
log failover is performed.
Archived Redo Log Backup sets – Includes only archived redo log files, Are always full
backups. RMAN > Backup Format ‘/disk1/backup/ar_+%t_%s_%p’ archivelog all delete
all input;. Common problem is we don’t know whether an archived log has been
completely copied to the archived log destination before attempting to back it up. RMAN
has access to control file or recovery catalog, so it knowswhcih logs ahs been archived
and can be restored during recovery. We can backup archive files with backup archivelog
command or can include when taking backup of datafiles and control files.
Characteristics pf archived log backup sets - can include archived log files only, are
always full backup.
Backup Constraints – The database must be mounted or open. Online redo log backups
are not supported,. Only clean backups are usable in noarchivelog mode. Only current
datafile backups are usable in archivelog mode. If a recovery catalog is used, the recovery
catalog database must be open.
Image Copies – Image copy contains a single datafile archived redo log file or control
file, An image copy can be created with RMAN copy command or an OS command.
When copy is created the server session validates the blocks in the file and records the
copy in control file.
Characteristics of Image copy – Can be written only to a disk. Can be used for recover
immediately does not need to be restored. Is a physical copy of a single datafile, archived
log or control file. Is most like an OS backup. Can be part of an incremental stratergy. It
can be designated as a level ) backup in cremental backup stratergy no other levels are
possible.
Image copy Example. – Run { allocate channel c1 type disdk;
Copy datafile ‘/oradata/users.dbf ‘ to ‘ /backup/user.dbf’ archivelog ‘arch1.arc’to
‘arch1.bak’;}
Rman copy command writed output file to disk. You can copy datafiles, archived redo
log files, or control files. If whole database is to be backup then we should backup all
datafiles seperatley with a copy command. During copy operation oracle server process
computes a checksum for each block to detect corruption, RMAN verifies the checksum
when restoring the copy. We can sto p this by using nochecksum option. If database
maintains an block checksum then this is of no use. We can alos use check logical option
to test data and index blocks that pass physical corruption checks ofr logical corruption.
With MAXCORUPT we can set an threshold for logical and physical corruptiom. RMAN
completes and populates this value in v$copy_corruption.
Image copy paralleliation – Copy process is serial, but we can parallelize by configure
device type … parallelism or allocating multiple channels, specifying on copy command
for multiple files. One copy caoomand can be used to copy multiple files. Only when one
copy command is completed other copy command will start work.
Copying the whole database – Mount the database for a whole consistent backup. Use the
report schema command to list he files. Use the copy command or make an image copy
of each datafile. Use List copy command to verify the copies. We can include current
control file in copy with current controlfile command. If configure control file
autobackup is on then RMAN automatically back the control file.
Ensure sufficient space for the backup. Shutdown using the normal or immediate clause.
Mount the database. Allocate multiple channels if not using automatic. Run the backup
command. Verify that the backup is finished and cataloged. Open the database for normal
use.
RMAN Control file autobackups – Use the configure controlfile autobackup command to
enable by defaylt it is offutomatically performs a control file autobackup adter backup or
copy commands. Backup is given a default name. RMAN copies control file using format
of %F. We can change this format using configure controlfile autobackup cormat and set
controlfile autobackup format commands. %F variable translates into IIIIIIIIII-
yyyyMMDD-QQ. I stabds form DBID, It is printed in decimal. Y – is time stamp with
date, QQ is sequence in hexadecimal numbethat starts with 00 and ‘FF’
Tags form Backup and Image copies – Tag is a meaningful name that is assigned to
backup set. It provides useful references to backups, It can be use dint LIST, Restore and
switch command. Same tag can be used for multiple backup sets or file copies.
RMAN Dynamic views – V$archived_log : shows which archives have been created
backed up and cleared in database. V$backup_corruption – shows which blocks have
been found corrupt during backup of a backup set. V$copy_corruption – shows block
corruption in image copy. V$backup_datafile – is useful in creating equal-sized by
finding no of blocks in each datafile. It alos has the no of blocks corrupt in datafile.
V$backup_redolog – shows archived logs stored in backup sets. V$backup_set – shows
backup sets that have been created. V$backup_piece – shows backup pieces created for
backup sets.
Monitoring RMAN Backups – Correlate server session with channels with the se
command ID command. Query V$process and V$session to determine which sessions
correspond to which RMAN channel. Query v$session_longops to monitor the progress
of backups and copies. Use an OS utility to monitor the thread or processes
Media Recovery - Use to recover a lost or damaged current datafile or control file.
Requires explicit invocation. File are restored from backups. Redo data is applied to the
restored files from archived redo log files and online redo logs.
Recovery Steps – Damaged or missing files are restored from a backup. Changes from
archived redo log files and online redo log files are applied as necessary. Undo blocks
Are generated, this termed as rolling forward or cache recovery. Database may now
contain committed and uncommitted changes. Unod blocks are used to roll back any
uncommitted changes, known as roolong back. Databse is now in recovered state.
Restoration and datafile Media recovery with user managed procedures – restore files
using OS commands, Recover files using SQL*Plus recover command.
Recovery in NOarchivelog mode with redo log file backups- shutdown and resotre all
oracle data files.
Recovery in NOarchivelog mode without redo log file backups- shutdown the Instance.
Restore the datafiles and control file from the most recent whole database backup.
Perform cancel-based recovery – Recover database until cancel using backup
controlfile_. Open the database with resetlogs option – Alter database open restelogs.
To change archive location use the – Alter system archive log .. command
To apply redo log files automatically – Issue the set autorecovery on command before
starting media recovery. Enter auto when prompted for an archived log file. Use the
Recover Automatic command.
Oracle server automatically applies redo log files, Before redo log file is applied oracle
server suggests log file name to apply. I archive log files are not restored to
log_archive_des directory then it should be notified to the oracle server new directory
path. Specify log : {<ret>=suggested | filename |auto |cancel}
Alter system archive log start to <new location;
Recover from ‘<new location>’ database.
We have one tablespace u01 contains corrupt blocks, the datafile abc is stored, this can be
found by querying v$datafile and V$tablespace views.this datafile belongs to the system
tablespace.
1. Shut down the instance – SHUTDOWN ABORT
2. Restore the file from backup – copy c:\backup\abc.dbf d:\data\
3. Start the Instance – Startup mount – Recover database
4. Whe recovery is over open the database – Alter database open
Database is open and one datafile number 2 has been removed using OS commands. We
can find to which tablespace the datafile belongs to, by using the sql given below
Select file_id f#, file_name, tablespace_name, status from dba_data_files.
1. to determine wether to take datafile 2 offline – select d.file#, d.name, d.status,
h.status from V$datafile d, v$datafile_header h where d.file# = h.file#;
2. when offline we can restore from the backup – copy c:\backup\df2.dbf d:\data\
3. Use recover command to apply the archives and redo logs on the restored datafile
– recover datafile ‘/disk2/backup/df2.dbf’ or recover tablespace user_data
4. When recovery is finished all datfile are synchronized, now datafile can be online
– alter database datafile ‘disk2/data/db2.dbf’ online or alter tablespace user_data
online;
Ond HDD fails, the datafile 2 In the HDD has to be recoverd it is not an system or undo
datafile- it is unavailability will not affect users form running their reports.
1. Mount the database – it will not open because datafile cannot be opened. We need
to take the datafile offline.
2. Alter database datafile ‘d:\data\db2.dbf’ offline. (alter tablespace cannot be used
because database is not yet open
3. Alter database open;
4. Now we have to restore the file in another HDD – copy c:\backup\db2.dbf
e:\data\db2.dbf. then change the location of file in oracle server- alter database
rename file ‘d:\data\db2.dbf’ to ‘e:\data\db2.dbf’
When database is opened and recovery to be done, query to find which tablespace
owns this datafile. Select file_id, file_name, tablespce_name, status form
dba_data_files.
5. Use Recover or Alter database recover command to start applying the archived
redo log files and online redo log files – recover datafile ‘e:\data\db2.dbf’ or
recover tablespace user_data.
6. when recovery is finished all datafiles are synchronized bring the datafile online.-
Alter database datafile ‘e:\data\db2.dbf ‘ online or alter tablespace user_data
online
Datafile is lost that was never backed up – cannot be used when it is a file from system
tablespace. Cannot be used if control file has been recreated.
Recreating Lost datafiels without backup - Used when missing datafile cannot be
resotred because it had never been backed up. Description of missing datafile is still in
data dictionary and control file. Recreate the datafile – alter database create datafile
‘filename’ – Recrated the datafile with a different filename – alter database created
datafile ‘filename’ as ‘new file name’
Recovery without a backup example – Datafile 4 was lost, when restoring datfile we find
that it is not backed up and it contains important data, Since it is not a system or undo
datafile and since we have all the archived log files we can do s follows
1. If databse is closed mount the database, take the datafile without backup offline
and mount the database. If database is already open take the datafile or tablespace
offline. – alter tablespace table_data offline immediate; . We should confirm the
recovery status by quering the v$recover_file. Select * from v$recover_file
2. Issue a command to recreate the file – Alter database create datafile
‘d:\data\db2.dbf’ as ‘e:\data\db2.dbf’;. the issue the query select * from
v$recover_file;
3. Use the recover to alter database recover command to start applying the archived
and online redo log files to recreate the datafile – recover tablespace table_data;
4. When recovery is finished bring the tablespace online – alter tablespace
table_data online
Case-1 – The tablespace being recovered is read-only when the last backup occurred,
Here we can simply recover the tablespace no need to apply redo information.
Case – 2 - The tablespace being recovered is read-write, but was read-only when the last
backup occurred, Here we can recover the tablespace and apply redo information from
when the tablespace was made read-write.
Case 3- Thetablespace being recovered is read-only but was read-write when last backup
occurred. Here we must restore the tablespace from the backup and recover up to the time
the tablespace was read-only.
Loss of control Files – We need to create control files if all control files are lost because
of a failure. The name of a database needs to be changed. The current settings in the
control file need to be changed.
Recovering control file - current control file – Use a current copy to restore a lost file. It
assumes that all the files are not lost. Create a new control file - use the create control
file command to create a new file. To do this we need to know all the files for the
database. Backing up an control file to trace on occasional basis facilitates this process.
Use a backup control file – Use recover database using backup control file command.
This is needed if all control files are lost.
RMAN – complete recovery
Restoration and Datafile Media Recovery Using RMAN - Restore files from backup sets
or image copies using RMAN restore command . RMAN uses a server session to restore
the correct backups and copies. The repository is used to select the best available backup
sets or image copies. Rcover files by using RMAN recover command – when we use
recover command RMAN applies changes from online redo log files and archived redo
log files or uses incremental backups to recover the restored files. Using RMan we can
perform recovery at database, tablespace,datafile.
Using RMAN to recover a database in Archivelog mode
Rman target /
Rman > startup mount . RMAN> Restore database; . RMAN > Recover database; .
Rman > Alter database open. This g. assumes that afull backup using RMAN is available
on disk.The current control files were not damaged and do no need to be restored. All
datafiles ar damaged or lost.
Using RMAN to relocate a tablespace - use the set newname command to restore the
files. Use the switch command to record the new names in the control file. Use the
recover tablespace command to recover the datafiles of the tablespace.
Eg- 1. check the location and size of the file from v$datafile. 2. Make sure that it is
offline. 3. Since file is copied to a new location using set name the file must be made
current by by notifying the oracle server the new file location with switch command. 4.
Use recover command to apply incremental and cumulative backuos, archived redo log
files and online redo log files. 5. Whe recover finished bring online and inform users that
they shoud reenter non commited data.
Eg. Run { sql “alter tablespace users offline immediate”; set newname for datafile
‘/abc/users01.dbf’ to ‘/def/users01.dbf’; restore tabelspace users; switch datafile 3;
recover tablespace users; sql “alter tablespace users online”;
Chapter 14 – User-Managed Incomplete Recovery
Incomplete recovery guidelines. – follow all steps carefully, take whole database backups
before and after recovery. Always verify that the recovery was successful. Back up and
remove archived logs.
Incomplete recovery and the alert log – check the alert log before and after recovery.
Contains error information, hints and SCNs.
User-Managed procedures for Incomplete recovery - SHUTDOWN AND BACKUP the
database. Restore all datafiles. Do not restore the control file, redo logs, password file and
parameter file. Mount the database. Recover the datafile to a point before the point of
failure. Open the database with resetlogs. Perform a closed database backup.
Recover Command Overview – Recover a database until cancel – Recover database until
cancel. Recover a database until time – Recover database until time ‘2003-03-
04:14:22:03’
Recover using backup control file – Recover database until time ‘2003-03-04:14:22:03’
Using backup control file.
Syntax - Recover [automatic ] database <option> - automatic automatically applies redo
log files. Options – until time ‘yyyy-mm-dd:hh:hmi:ss’, until cancel, until scn <integer>
using backup control file.
Time based recovery eg. – Scenario – current time is 12.00pm. on Mrach 9 2001, the
employees table has been dropped. The table was dropped appors at 11.45 am. Database
activity is minimal because most staff are currently in meeting. The table must be
recovered
Incomplete recovery using until time. – sice the time of failure is known and database
structure has not changed since the time we can use until time.
1. Shout down the database using normal,immediate, transactional options.
2. Restore all datafiles from backup (the most recent if possible). You may need to
restore archived logs. If there is enough space available restore to the
log_archive_dest lodation or use the alter system archive log start to <location> or
set logsource <location> to change the location.
3. Mount the database
4. Recover the database – sql>recover database until time ‘2001-03-09:11:44:00’
5. Synchronize datafiles with control files and redolog files , open the database by
using resetlogs option – sql > alter database open resetlogs.
6. 6. check whether employees table exist and take a whole closed backup.
Cancel Based Recovery – Scenario – The current time is 12.00 p.m. on March 9,2001.
The employee table was dropped whicle someone was trying to fix bad blocks. Log files
exist on the same disk. The table was dropped at approximately 11:45 am. . Staff are
currently in meeting.
Block corruption in employees table resulting from disk error. Redo logs are contained on
the same disk we need to check status of redo logs and archived logs.
Sql> select * from v$logfile; sql> select * from v$log; . We find that redo log log2a.rdo
cannot be located and has not been archived. Therfoe we cannot recover past this point.
We can query v$log_history configrm the absence of log seq 48 and find out the no of
minutes work the data will be lost. If database is recovered before applying log2a.rdo.
We can recover database as follows.
1. Shutdown the database. 2. Restore all datafiles from the most recent backup.3.
You already have a valid backup so mount he database. 4. Recover the databe
until log seq 48 . sql > recover database until cancel
2. specify log : {<return>=suggested | filename | auto | cancel } – type cancel (media
recovery cancelled)
3. Open the database by using the resetlogs option. 6. check that employees table
exists. When recovery is complete make a backup.
Using a backup control file curing recovery – scenario – Current ime 12.00 pm. On mar 9
2001. Tablespace containing employees table has been dropped. Error occurred around
11:45 a.m. Many employees records were update this morning but not after 11.00 am.
Backups are taken every night.
1. Tablespace containing the employees table has been dropped – sql> drop tablespace
emp_ts including contents; 2. We inform users and make system in restricted session –
sql > alter system enable restricted session. 3. We need to find the binary control files
form backup, since control file is replaced, we should get the database structure
information. – Select * from v$log; 4. Confirm the time of error by checking alert.log.
5. Shutdown the database, backup control files, then restore all datafiles and control files
for the database at a time when tablespace existed. If open we can find the databse is not
synchronized. 6. Verify any offline datafie exist and place them online. – Select * from
recover_file; if any datafile is offline make it online. – alter database datafile 4 online;
7. Perform recovery - recover database until time ‘2001-03-09:11:44:00’ using backup
control file.8. to synchronize open database with resetlogs option. 9. verify that
employees table exist. Make a whole backup.
Loss of current redo log files - If the database is closed – Attempt to opent he database.
Find the current log sequence number. Recover the database until cancel. Drop and
rcreate log files if necessary. Open the database using resetlogs. Perform a whole –
database backup.
If database is closed media falure have occurred. The step to be followed.
1. Attempting to open the database will imdtly notifyyou of the current redo log
group therough message database mounted ORA-00313 ope failed for memebere
of log group 2 of thread 1 . ora-00312 online log 2 thread 1 “
‘disk.1/archive/log2a.rdo’ nosuch file or directory. We cant clear the log 2 file
because it is the current one.
2. Incomplete recovery is reqd. we shoud note the current log sequence no by slect
* from v$log.we can find log 61 is the current one.
3. Restore all file form previous backup and the use recover until cancel and stop
before redo log 61 is applied. –SQL> recover database until cancel.
4. Open database using resetlogs option. 5. Databse will be operational because
missing file will be recreated. 6. Since it is incomplete recovery database should
be backed up.
Chapter -15 RMAN Incomplete recovery.
Incomplete recovery of a database using RMAN- Mount the database. Allocate multiple
channels for parallelization. Restore all datafiles. Recover the database by using until
time, until sequence, or until SCN. Open the database by using resetlogs. Perform a
whole database backup.
The restore and recovery process for rman are almost same except that all datafile need to
be restored from the past backup. Target database must be in mounted dtate. File being
restored should be offline. We can restore only if backups were taken with RMAN.
1. Target databse is open perform clean shutedown 2. Mount the target database. 3.
ensure that INS_lang and nls_date_format environmet variables are correct. 4. Start
recovery manager – rman target rman.rman@DB00. 5. we can allocate multiple channels
to improve the performance rman> run { allocate channel c1 type disk; allocate channel
c2 type disk; . 6. Specify the time for recovery and restor all datafiles from a backup with
rman command – rman > set until time ‘2002-12-09:11:$:00’ ; rman > .. restore database.
7. Recover the database to the time specified in the set until command – rman > …
recover database. 8. Open database by using resetlogs option – RMAN > alter database
open resetlogs; 9. check the table exists and perform a nbackup. 10.If using recovery
catalog register the new incaranation of the database; - rman > reset database.
Deleting Backups and copies – Use the backup.. delete input command
Delete input files upon successful creation of backup set. Delete archived redo log files.
Datafie copies, and backup sets. We can use this option when backing up archived redo
log files, datafile copies or backup sets. If we use delete all inpuit when backing up
archived redo log files all copies of corresponding archived redo logs that match the
selection criteria. The backup archivelog command back one copy of each distinct log
sequence no, if we specify delete input option without all tman deletes only the copy of
the file that it backs up.
Changing the availability of RMAN Backups and copies - Change the status of backup
or copy to unavailable with the change … unavailable command. Return the status to
Available with the change .. available command.
Changing the Availability status –
Change the stastus of a specific datafile – Change datafilecopy ‘/db01/backup/user01.dbf’
unavailable; Change the status of a control file backup – change backup of controlfile
unavailable; change backup of controlfile available; . change the sdtatus of archived redo
log files – change copy of archivelog sequence between 230 and 240 unavailable;
IF we do nto specify an option for backup then change backup operates on all backups
recorded in the repository.Copy keyword with change command indicates on which files
the command shoud operate, if no option isd specifiedthen it operates i=on all copies
recorded in the repository.
Exempting a backup or copy from the retention policy – Use the change keep command
to exempt a backup or copy from th retention policy. Use the change nokeep option
command to cancel the exemption.
Change Keep Command – Create a long-term backup – change backupset 123
keepforever nologs. Make a datafile exempt from retention policy for 60 days – change
datafilecopy ‘/db01/backup/users01.dbf’ keep until ‘sysdate+60’;
Forever parameter implies that backup or copy never expires.We must use a recovery
catalog when forever is specified, otherwise backup records wventualy age out of the
control files. When logs parameter is specified all archived logs requird ot be backed up
will remain till this backup is there. Nologs specifies that this backup or copy cannot be
recoverd archived logs will not be kept. We can use this to restore to the point in time
backup or copy was taken.’we can use until time = ‘date string’ to specify till what date
backup should be kept.
Cataloging Archived Redo Log files and user-managed backups – we can use the catalog
command to add information to the repository about an OS datafile copy, An archived
redo log copy, A control file copy.
Benefits of using a recovery catalog - Metadata about multiple target databases in one
catalog. Metadata about multiple incaranations of a single target database. Historical
metadata. Reporting on target database at a noncurrent time.
Resetting an database Incaranation – Use the reser database command to direct RMAN to
create a new database incarnation record. To distinguish between opening with restlogs
and an accidental restor operation of an old control file. Open with RESETLOGS after
RESET DATABASE.
An incarnation of a database is a number used to identify a version of the database prior
to the log sequence no being rest to zero. This prevents archived and online redo logs
from being applied to an incorrect incarnation of the database. This command id used by
RMAN to store the incarnation no in the recovery catalog. All subsequent backup and
log archives will be associated with new incarnation.
Reset databse
Reset database to incarnation <identifier>
Recovery Catalog reporting
Report command – To analyze various aspects of the backup, copy, restore and recovery
operations. List command – To display info on backup sets, file copies and archived logs
which are stored in recovery catalog. Views – the views that are created when recovery
catalog is created – rc_database, rc_datafile, rc_stored_script, rc_stored_script_line,
rc_tablespace.
Stored Scripts - Rman script is a set of commands that is stored and can be used for
backup recover and restore operations, It is created with create script command. Are
stored in recovery catalog, can be called by run command.Minimize the potential of
operator errors. We can display stored scripts form rc_stored_script view, we can use
rc_stored_script_line view to list the text stored in an specific script or we can use the
print script command.
Script eg – rman > create script level0back { backup incremental level 0 format
‘/u01/backup/%d_%s_%p’ fileperset 5 (database include current controlfile); sql ‘alter
database archive log current’;
We can use execute to run an script – rman > run {execute script level0backup}
We can use replace script to rewirte the script - rman >replace script level0back
We can use delete script to remove a script – rman> delete script level0back;
Use print script to display script – rman> print script level0back;
Backup of Recovery Catalog – Whole databse backup of the databse containing the
recovery catalog. Tablespace backup of the tablespace containing the recovery catlog.
Export – If catalog databse is not very large we can export at regular intervals. If it is
large we can export the schema containing the recovery catalog. We should always store
recovery catalog database in separate database,
Reocvering in the recovery catalog – Create a database form previous backup of recovery
catalog database. Relocate the catalog into another database and import the data. Import
the entire database from an export. When recovery catalog has been recbuilt we should
resynchronize the catalog with the control file of the target database immediately. During
sync RMAn add s records for files that no longer exists because files being re-cataloges
are not verified, we should remove these files bu using change … uncatalog command.