Oracle RMAN 11g Backup and Recovery (12 page)

BOOK: Oracle RMAN 11g Backup and Recovery
10.78Mb size Format: txt, pdf, ePub

Backup and Recovery: Crafting the Plan

Now that you have gathered your requirements, you can begin to craft your backup and recovery plan. You need to make a number of decisions:

■ Based on the user (and business) requirements, do you need to do offline or online backups of the database?

■ If you are going to use online backups, how often do you need to back up archived redo logs? How will you protect the archived redo logs from loss between backup sessions?

■ What are the company policies and standards with regard to recoverability?

■ How are you going to ensure that your system is recoverable in the event of a disaster?

■ Are there any architectural decisions that need to be made?

Each of these questions is important. Disasters are important to plan for, and they do happen.

Company policies may well supersede the needs of the users. Backup policies and standards are important to implement and enforce. Managing one database backup and recovery policy is easy.

Managing many different databases with different methods of doing backup and recovery becomes cumbersome and dangerous.

Managing archived redo logs is important because they are critical to recovery, and you want to be able to support your users as much as you can. After all, the users are the reason you are there! To really determine how to craft your backup strategy, you need to understand how Oracle works and how Oracle backup and recovery works; we will talk about that shortly. First, just to make sure we are all on the same page, let’s discuss some basic Oracle terms.

A Few Oracle Terms to Know

It is always a bit hard to decide where to start when discussing the Oracle architecture, because so many of the different components are interrelated. This makes it hard to talk about one without referring to the other. So that we can have a common point of reference for some basic terms, in this section we quickly define those terms. We will be using these terms throughout the rest of this book, so it is really important that you clearly understand them (we also define them in more depth as this chapter progresses). So, if you are a bit hazy on Oracle internal terms, please review the following until you know without hesitation what they are:


Alert log
A text log file in which the database maintains error and status messages. The alert log can be a critical structure when trying to determine the nature of a database failure. Typically, the alert log is in the background dump destination directory, as defined by the database parameter BACKGROUND_DUMP_DEST, and is called alert.log.


Archived redo logs
When the database is in ARCHIVELOG mode, archived redo logs are generated each time Oracle switches online redo logs by the LGWR process.

Archived redo logs are used during database recovery. Copies of the archived redo logs can be written to as many as ten different directories, defined by the Oracle parameter LOG_ARCHIVE_DEST_
n
in the database parameter file. Also, Oracle Database 11
g
8
Part I: Getting Started with RMAN in Oracle Database 11
g

allows you to store archived redo logs in a new location called the flash recovery area, which we discuss in more detail in Chapter 3.


Backup control file
A backup of the control file generated as the result of using the
alter database backup controlfile to ‘file_name’
command or the
alter database backup
control file to trace
command.


Block
The most atomic unit of storage in Oracle. The default block size is determined by the parameter DB_BLOCK_SIZE in the database parameter file, and it is set permanently when a database is created. Oracle Database 11
g
allows tablespaces to be different block sizes than the default.


Checkpoint
A database event that causes the database to flush dirty (used) blocks from memory and write them to disk.


Database
Consists of the different components that make up an Oracle database (tablespaces, redo logs, and so forth). A database is much different from an instance.

A database is where the data lives, and what you will be backing up and recovering with RMAN.


Database consistency
Implies that each object in the database is consistent to the same point in time. This means that the data in the database datafiles is consistent to the same point in time. This also means that the database control files are synchronized with the database datafile headers.


Database control file
A database control file stores several kinds of metadata related to the database. This includes information on the database datafiles, archived redo logs, RMAN backups, and other internal database information.


Database datafile
A physical entity that is related to a tablespace. A database consists of at least one database datafile (which would be assigned to the SYSTEM tablespace), and most databases consist of many different database datafiles. Whereas a tablespace can have many different database datafiles associated with it, a given database datafile can have only one tablespace associated with it.


Database parameter file
Contains instance and database configuration information and comes in two mutually exclusive flavors: init.ora, which is a text file, and spfile

.ora, which allows for persistent settings of database parameters via the
alter system
command.


Flash recovery area (FRA)
An optionally configured area of disk that is used to store various recovery-related files. RMAN backup files, archived redo logs, online redo logs, and control files can be stored in this area. You can find more details on the FRA in Chapter 2 and find setup information in Chapter 3. You’ll see examples of the use of the FRA in most chapters of this book.


Granule
A unit of Oracle contiguous memory. All System Global Area (SGA) memory allocations are rounded to the nearest granule units. The size of a granule depends on the overall expected size of the SGA, and it may be 4MB or 16MB. An SGA size of greater than 128MB tends to be the break point when Oracle uses the larger granule sizes. The number of granules allocated to the database is determined at database startup.

Chapter 1: Oracle Database 11
g
Backup and Recovery Architecture Tour
9


Instance
The collection of Oracle memory and processes. When the SGA (memory) is allocated and each of the required Oracle processes is up and running successfully, then the Oracle instance is considered started. Note that just because the Oracle instance is running, this does not mean that the database itself is open. An instance is associated with one, and only one, database at any given time.


Online redo logs
When redo is generated, it is physically stored in the online redo logs of the database. Oracle requires that at least two online redo logs be created for a database to operate. These online redo logs can have multiple mirrored copies for protection of the redo. This is known as
multiplexing
the redo log. As an online redo log fills with redo, Oracle switches to the next online redo log, which is known as a
log switch
operation.

Each online redo log file has a unique
log sequence number
associated with it that uniquely identifies it and, if it’s archived, its associated archived redo log file. You can find the log sequence number of the online redo logs by querying the V$LOG view. The sequence number of a given archived redo log can be found in the V$ARCHIVED_LOG

view or the V$LOG_HISTORY view.

Additionally, an online redo log (and an archived redo log) contains a range of database System Change Numbers (SCNs) that is unique to that redo log. During recovery, Oracle applies the undo in the archived/online redo logs in order of log sequence number.


Processes
The programs that do the actual work of the Oracle database. Oracle Database 11
g
has five required processes among others.


Redo
A record of all changes made to a given database. For almost any change in the database, an associated redo record is generated.


Schema
Owns the various logical objects in Oracle, such as tables and indexes, and is synonymous with the user.


SGA (System Global Area)
An area of shared memory that is allocated by Oracle as it is started. Memory in the SGA can be shared by all Oracle processes.


System Change Number (SCN)
A counter that represents the current state of the database at a given time. As with the counter on a VCR, as time progresses, the SCN

increases. Each SCN atomically represents a point in the life of the database. Thus, at 11 A.M., the database SCN might be 10ffx0 (4351 decimal), and at 12 P.M., it might be 11f0x0 (4592 decimal).


Tablespace
A physi-logical entity. It is a logical entity because it is the place that Oracle logical objects (such as tables and indexes) are stored. It is a physical entity because it is made up of one or more database datafiles. A database must contain at least one tablespace, the SYSTEM tablespace, but most databases consist of many different tablespaces.


Trace files
Generated by the database in a number of different situations, including process errors. Each database process also generates its own trace file. Trace files can be important when trying to resolve the nature of a database failure.

10
Part I: Getting Started with RMAN in Oracle Database 11
g
Controlling the Database Software

During various recovery operations, you need to control the state of the Oracle database and its associated instance. Let’s quickly review how to start and stop Oracle databases.

To start the Oracle Database 11
g
database, you use the SQL*Plus Oracle utility. Log in as the user system by using the SYSDBA login ID. At the SQL*Plus prompt, issue the
startup
command, as you can see in this example:

/usr/oracle>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jan 26 10:55:49 2010

Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Dada Mining and Real Application Testing options

Connected to an idle instance.

SQL> startup

When you start an Oracle database with the
startup
command, the operation goes through three different phases:


Instance startup
The Oracle database instance is started.


Database mount
The Oracle database is mounted.


Database open
The Oracle database is opened for user activity.

NOTE

You should be aware that the RMAN client, which we will discuss

in later chapters, has the ability to shut down and start up the Oracle
database on its own. You will not need to move from RMAN to

SQL*Plus during a recovery operation in most cases.

The
startup
command has several different variations (which are important to know for several different RMAN operations), some of which include the following:


startup
Causes Oracle to go through each of the three startup phases, and to open to the user community.


startup restrict
Causes Oracle to go through each of the three startup phases, and to open in restricted mode. Only those users with restricted privileges can access the database.


startup nomount
Causes the startup process to stop after it has successfully started the database instance. You will often use this command to start the database instance prior to actually creating a database. This command is also handy to have if you need to re-create the control file. Note that to use RMAN with a given database, you must be able to successfully start the instance with the
startup nomount
command.

Other books

Night Visitor by Melanie Jackson
Magic Burns by Ilona Andrews
What I Love About You by Rachel Gibson
Return to Mars by Ben Bova
Lyn Cote by The Baby Bequest
Raptor by Jennings, Gary
New Pompeii by Daniel Godfrey
The Two-Gun Man by Seltzer, Charles Alden
The Delicate Storm by Giles Blunt