Download backup

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
User-Managed Backups
Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do
the following:
• Describe user-managed backup and recovery
operations
• Discuss backup issues associated with read-only
tablespaces
• Perform closed database backups
• Perform open database backups
• Back up the control file
• Perform cleanup after a failed online backup
• Use the DBVERIFY utility to detect corruption
10-2
Copyright © Oracle Corporation, 2002. All rights reserved.
Terminology
•
Whole database backup
– Target database may be open or closed
– Backup of all datafiles and the control file
•
Partial database backups
– Tablespace
– Data file
– Control file
•
•
10-3
Consistent backups
Inconsistent backups
Copyright © Oracle Corporation, 2002. All rights reserved.
10-4
Copyright © Oracle Corporation, 2002. All rights reserved.
User-Managed Backup and Recovery
•
•
•
10-5
Files are backed up with operating system
commands
Backups are restored with operating system
commands
Recovery is accomplished using SQL and
SQL*Plus commands
Copyright © Oracle Corporation, 2002. All rights reserved.
Querying Views to Obtain
Database File Information
V$DATAFILE
V$CONTROLFILE
V$LOGFILE
DBA_DATA_FILES
10-6
Copyright © Oracle Corporation, 2002. All rights reserved.
10-7
Copyright © Oracle Corporation, 2002. All rights reserved.
Obtaining Database File Information
10-8
Copyright © Oracle Corporation, 2002. All rights reserved.
Backup Methods
Closed database
NOARCHIVELOG
mode
Closed or open database
ARCHIVELOG
mode
Physical backup
10-9
Copyright © Oracle Corporation, 2002. All rights reserved.
Consistent Whole Database Backup
(Closed Database Backup)
Data files
Control
files
Redo log Parameter Password
files
file
file
Online or
offline storage
10-10
Copyright © Oracle Corporation, 2002. All rights reserved.
Advantages of Making Consistent
Whole Database Backups
•
•
•
10-11
Conceptually simple
Easy to perform
Require little operator interaction
Copyright © Oracle Corporation, 2002. All rights reserved.
10-12
Copyright © Oracle Corporation, 2002. All rights reserved.
Making a Consistent Whole
Database Backup
2
SHUTDOWN IMMEDIATE
3
HOST cp <files> /backup/
1
Datafiles
Control
files
Redo log Password Parameter
files
file
file
STARTUP OPEN
4
10-13
Copyright © Oracle Corporation, 2002. All rights reserved.
10-14
Copyright © Oracle Corporation, 2002. All rights reserved.
Open Database Backup
Datafiles
Password file
10-15
Control files
Parameter file
Archived redo
log files
Copyright © Oracle Corporation, 2002. All rights reserved.
Online redo
log files
Advantages of Making
Open Database Backups
•
•
•
10-16
Maintains high database availability
Can be done at a tablespace or datafile level
Supports nonstop business operations
Copyright © Oracle Corporation, 2002. All rights reserved.
Open Database Backup Requirements
LGWR
ARCHIVELOG mode
052
054
052
054
051
053
051
053
ARC0
051
051
Online redo
log files
10-17
Copyright © Oracle Corporation, 2002. All rights reserved.
052
052
053
053
Archived redo
log files
Open Database Backup Options
Tablespace backup
Tablespace USERS
users01.dbf
10-18
users02.dbf
Datafile backup
Tablespace USERS
users01.dbf
Copyright © Oracle Corporation, 2002. All rights reserved.
users02.dbf
Making a Backup of an Online Tablespace
145
Datafile 1
144
Datafile 2
145
Datafile 3
145
Control
files
144
Redo log
file 1
145
Redo log
file 2
Database
143
Datafile 1
144
Datafile 2
Database Backup
SQL> ALTER TABLESPACE users
2> BEGIN BACKUP;
SQL> !cp /…/users01.dbf /BACKUP/users01.dbf
10-19
Copyright © Oracle Corporation, 2002. All rights reserved.
Ending the Online Tablespace Backup
145
Datafile 1
145
Datafile 2
145
Datafile 3
145
Control
files
144
Redo log
file 1
145
Redo log
file 2
Database
143
Datafile 1
144
Datafile 2
Database Backup
SQL> ALTER TABLESPACE users
2> BEGIN BACKUP;
SQL> !cp /…/users01.dbf /BACKUP/users01.dbf
SQL> ALTER TABLESPACE users
2> END BACKUP;
10-20
Copyright © Oracle Corporation, 2002. All rights reserved.
Backup Status Information
V$BACKUP
10-21
Copyright © Oracle Corporation, 2002. All rights reserved.
10-22
Copyright © Oracle Corporation, 2002. All rights reserved.
Failure During Online Tablespace Backup
ALTER TABLESPACE users
BEGIN BACKUP;
cp /…/users01.dbf
/BACKUP/users01.dbf
144
144
144
Datafile 1 Control Redo log
files
file 1
144
145
Datafile 2
Redo log
file 2
144
Datafile 3
Database
146
146
146
Datafile 1 Control Redo log
files
file 1
144
145
Datafile 2
Redo log
file 2
146
Datafile 3
Database
10-23
Copyright © Oracle Corporation, 2002. All rights reserved.
Ending the Online Backup
•
•
Query V$BACKUP to check backup status
Issue the ALTER DATABASE command to change
the status and unfreeze the header:
ALTER DATABASE DATAFILE ‘<filename>’ END
BACKUP;
•
Or use this command in Oracle9i:
ALTER DATABASE END BACKUP;
10-24
Copyright © Oracle Corporation, 2002. All rights reserved.
10-25
Copyright © Oracle Corporation, 2002. All rights reserved.
Read-Only Tablespace Backup
1
ALTER TABLESPACE query_data READ ONLY;
2
3
File 1
backup copy SCN 1
SCN 1
Query_Data
file 1
Users File 1
4
SCN 2
DBW0
Users File 2
SCN 2
10-26
Copyright © Oracle Corporation, 2002. All rights reserved.
Read-Only Tablespace Backup Issues
•
•
•
10-27
Only one backup is needed after altering the
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 read-only mode; otherwise you must
recover it.
Copyright © Oracle Corporation, 2002. All rights reserved.
Backup Issues with
LOGGING and NOLOGGING Options
LOGGING
10-28
NOLOGGING
All changes recorded to redo
Minimal redo recorded
Fully recoverable from
last backup
Not recoverable from last
backup
No additional backup
May require additional backup
Copyright © Oracle Corporation, 2002. All rights reserved.
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;
10-29
Copyright © Oracle Corporation, 2002. All rights reserved.
10-30
Copyright © Oracle Corporation, 2002. All rights reserved.
Backing Up the
Initialization Parameter File
CREATE PFILE FROM SPFILE;
CREATE PFILE = '/backup/init.ora'
FROM SPFILE;
10-31
Copyright © Oracle Corporation, 2002. All rights reserved.
Verifying Backups
Using the DBVERIFY Utility
4
DBVERIFY
1
2
Online
Error
reporting
3
Online
Offline
datafiles
10-32
Copyright © Oracle Corporation, 2002. All rights reserved.
DBVERIFY Command-Line Interface
•
•
•
External command-line utility
Used to ensure that a backup database or datafile
is valid before a restore
Can be a helpful diagnostic aid when data
corruption problems are encountered
%dbv file=/ORADATA/u03/users01.dbf logfile=dbv.log
10-33
Copyright © Oracle Corporation, 2002. All rights reserved.
10-34
Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:
• Determine which files require backup and when
they should be backed up
• Make user-managed backups
• Backup the control file
• Backup the server initialization parameter file
• End an online backup that did not complete due to
instance failure
• Use dynamic views to determine the status of
backup operations
• Use DBVERIFY to verify the backup
10-35
Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 10 Overview
This practice covers the following topics:
• Performing a full offline database backup
• Performing an online backup of a tablespace
datafile
• Creating a trace file of the control file
10-36
Copyright © Oracle Corporation, 2002. All rights reserved.
10-37
Copyright © Oracle Corporation, 2002. All rights reserved.
10-38
Copyright © Oracle Corporation, 2002. All rights reserved.
Related documents