Вы находитесь на странице: 1из 35

Backup and Recovery

Part of Your Job

• The administrator’s duties are to:


– Protect the database from failure wherever possible
– Increase the mean time between failures (MTBF)
– Protect by redundancy
– Decrease the mean time to recover (MTTR)
– Minimize the loss of data
Categories of Failure

• Failures can generally be divided into the following


categories:
– Statement failure
– User process failure
– Network failure
– User error
– Instance failure
– Media failure
Statement Failure

Typical Problems Possible Solutions


Attempts to enter invalid data into Work with users to validate and
a table correct data.
Attempts to perform operations Provide appropriate object or
with insufficient privileges system privileges.

Attempts to allocate space that fail • Enable resumable space


allocation.
• Increase owner quota.
• Add space to tablespace.
Logic errors in applications Work with developers to correct
program errors.
User Process Failure

Typical Problems Possible Solutions


A user performs an abnormal A DBA’s action is not usually
disconnect. needed to resolve user process
failures. Instance background
A user’s session is abnormally processes roll back uncommitted
terminated. changes and release locks.

A user experiences a program


error that terminates the session. Watch for trends.
Network Failure

Typical Problems Possible Solutions


Listener fails. Configure a backup listener and
connect-time failover.
Network Interface Card (NIC) fails. Configure multiple network cards.

Network connection fails. Configure a backup network


connection.
User Error

Using Flashback technology:


• Viewing past states of data
• Winding data back and forth in time
• Assisting users in error analysis and recovery

• For error analysis: • For error recovery:


– Oracle Flashback Query – Oracle Flashback
(SELECT … AS OF…) Transaction Backout
– Oracle Flashback Versions – Oracle Flashback Table
Query (SELECT … – Oracle Flashback Drop
VERSIONS BETWEEN…)
– Oracle Flashback
Transaction Query
User Error

Typical Causes Possible Solutions


User inadvertently deletes or Roll back transaction and
modifies data. dependent transactions or rewind
table.
User drops a table. Recover table from recycle bin.

Oracle LogMiner
Instance Failure

Typical Causes Possible Solutions


Power outage Restart the instance by using the
STARTUP command. Recovering
from instance failure is automatic,
Hardware failure including rolling forward changes
in the redo logs and then rolling
back any uncommitted
Failure of one of the critical transactions.
background processes
Investigate the causes of failure
Emergency shutdown procedures
by using the alert log, trace files,
and Enterprise Manager.
Archive Log Files

• To preserve redo information, create archived copies


of redo log files by performing the following steps.
1. Specify archive log file-naming convention.
2. Specify one or more archive log file locations.
3. Switch the database to ARCHIVELOG mode.

Online redo log files Archive log files


Enabling ARCHIVELOG Mode

• To place the database in ARCHIVELOG mode,


perform the following steps in Enterprise Manager:
1. Select the ARCHIVELOG Mode check box and click Apply.
The database can be set to ARCHIVELOG mode only from the
MOUNT state.
2. Restart the database (with SYSDBA privileges).
3. (Optional) View the archive status.
4. Back up your database.
• Note: Databases in ARCHIVELOG
• mode have access to the full sqlplus / as sysdba
• range of backup and recovery
• options. shutdown immediate
startup mount
alter database archivelog;
alter database open;
archive log list
Backup Solutions: Overview

• Backups can be performed by using:


– Recovery Manager
– Oracle Secure Backup
– User-managed backup

Target
Data files database Image copies

Backup pieces
Archi
Redun ve log Backup data
dant files
Flash recovery area
archive
log
files
Oracle Secure Backup
– Oracle Secure Backup and RMAN provide an
end-to-end backup solution for Oracle environments:
• Centralized tape backup management for file
system data and the Oracle database
• Most well-integrated media management layer for
RMAN backups
• Backup of any data anywhere on the network
– A single technical support resource for the entire
backup solution expedites problem resolution.
– This ensures reliable data protection at lower cost and
complexity.
User-Managed Backup

• A user-managed scenario:
– Is a manual process of tracking backup needs and status
– Typically uses your own written scripts
– Requires that database files be put in the correct mode
for backup
– Relies on operating system commands to make backups
of files
Terminology

– Backup strategy may include:


• Entire database (whole)
• Portion of the database (partial)
– Backup type may indicate inclusion of:
• All data blocks within your chosen files (full)
• Only information that has changed since a previous
backup (incremental)
– Cumulative (changes up to last level 0)
– Differential (changes up to last incremental)
– Backup mode may be:
• Offline (consistent, cold)
• Online (inconsistent, hot)
Control Online
files redo log
Database
Data files files
Terminology

• Backups may be stored as:


– Image copies
– Backup sets
Data file #1 Data file #1 Data file #2

Data file #2 Data file #3 Data file #4


Data file #5 Data file #6
Data file #3
Backup set
Data file #4
(Binary, compressed files in
Data file #5 Oracle proprietary format)

Data file #6
Image copies
(Duplicate data and log files in OS format)
Recovery Manager (RMAN)

– Powerful control and scripting language


– Integrated with Enterprise Manager
– Published API that enables interface with most
popular backup software
– Backing up data, control, archived log, and server
parameter files
– Backing up files to the disk or tape
Configuring Backup Settings
Configuring Backup Settings

Best practice

Backup
pieces
Change
tracking Recovery
Data files file area
Scheduling Backups: Strategy
Scheduling Backups: Options
Scheduling Backups: Settings
Scheduling Backups: Schedule
Scheduling Backups: Review
Backing Up the Control File to a Trace File

• Control files have an additional backup option.

Control file trace backups may


be used to recover from loss
of all control files.
Managing Backups
Viewing Backup Reports
Monitoring the Flash Recovery Area
Using the RMAN Command Line

1 $ rman target /
2 RMAN> CONFIGURE …
3 RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

Copies of

Control
Control Archived log SPFILE
Data files file
files file
Using RMAN RESTORE and
RECOVER Commands
– RESTORE command: Restores database files from backup
– RECOVER command: Recovers restored files by applying
changes recorded in incremental backups and redo log files

RMAN> SQL 'ALTER TABLESPACE inv_tbs OFFLINE IMMEDIATE';


RMAN> RESTORE TABLESPACE inv_tbs;
RMAN> RECOVER TABLESPACE inv_tbs;
RMAN> SQL 'ALTER TABLESPACE inv_tbs ONLINE';

• The Enterprise Manager Recovery Wizard creates and runs an


RMAN script to perform the recovery.
Performing Complete Recovery: Loss
of a System-Critical Data File in
ARCHIVELOG Mode
• If a data file is lost or corrupted, and that file belongs
to the SYSTEM, UNDO (or SYSAUX) tablespace,
then perform the following steps:
1. The instance may or may not shut down automatically. If it
does not, use SHUTDOWN ABORT to shut the instance
down.
2. Mount the database.
3. Restore and recover the missing data file.
4. Open the database.
Performing Restore and Recovery of
a Database in NOARCHIVELOG
Mode
– If the database is in NOARCHIVELOG mode, and
any data file is lost, perform the following tasks:
• Shut down the instance if it is not already down.
• Restore the entire database, including all data and control
files, from the backup.
• Open the database.
– Users must reenter all changes made since the last
backup.
Performing Point-in-Time Recovery
• Perform server-managed point-in-time recovery by
doing the following:
1. Determine the target point of the restore: SCN, time,
restore point, or log sequence number.
2. Set the NLS environment variables appropriately.
3. Mount the database.
4. Prepare and run a RUN block, using the SET UNTIL,
RESTORE, and RECOVER commands.
5. Open the database in READONLY mode, and verify that
the recovery point is what you wanted.
6. Open the database using RESETLOGS.
Backup Commands:

To start RMAN session at OS.

rman target /

Using RMAN issue the next command to take a FULL DB BACKUP level 0, including
the archive logs.

RMAN> backup database plus archivelog delete input;

Issue next command to run an archive backup and delete input files.

RMAN> backup archivelog all delete input;

RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;

RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;


Restore Commands:

Script to perform a database point in time recovery, database needs to be in


mount state in order to do it.

RUN
{
SET UNTIL SCN 1000;
# Alternatives:
# SET UNTIL TIME 'Nov 15 2004 09:00:00';
# SET UNTIL SEQUENCE 9923;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;
}

Restore database.

RESTORE DATABASE;
RECOVER DATABASE;

Вам также может понравиться