OCP Certification Examination Guide (19): backing up an Oracle database

Source: Internet
Author: User

1. Backup tools

You can directly use the Operating System Utility copy and CP to perform backup operations. However, Oracle strongly recommends that you use recovery Manager (RMAN ).

RMAN can back up data files, control files, archived logs, and server parameter files ). Backups can be written to disks or tapes.

2. concepts and terms

2.1 full backup and partial backup

Whole backup is a backup of all data files, control files, and server parameter files. All reusable copies of the control file are identical, so you only need to back up one of them. Note that you do not need to back up online redo logs! Online redo log files are protected by reuse and optional archiving. In addition, only data used for permanent tablespace is backed up. RMAN cannot back up temporary tablespace files, and these temporary files cannot be placed in the backup mode used for operating system backup.

Partial backup includes one or more data files and control files. Some backups and the rest of the database will certainly not be synchronized. Partial backup is only a copy of a certain part of the database at a specific time. If it is necessary to restore a file from a partial backup, the file must be synchronized with the rest of the database before it can be used, this means that the recovered files need to be updated by applying changes in the archive and online redo log files.

Partial backup is valid only when the database is in archivelog mode.

2.2 complete backup and Incremental Backup

Full backup is a complete copy of one or more data files. This copy can be full or partial backup.
Incremental backup is only a backup of some data blocks in the data file. This backup only contains the data blocks that have been modified or added since the last full backup.

Whether the database is in archivelog mode or noarchivelog mode, Incremental Backup can be performed when the database is enabled or disabled. However, only RMAN can perform Incremental backup.

2.3 offline backup and online backup

Offline backup is a backup generated when the database is closed.
Online backup is a backup generated when the database is being used.

Online backup can be full or partial backup, and can be completed by using RMAN or operating system commands. However, online backup can only be performed when the database is in archivelog mode. During online backup, the database performance degrades due to additional disk activity.

2.4 image copies and backup Sets

Image copy is a backup of a file, and each byte is the same as the source file.
Backup set is a proprietary structure generated by RMAN. This is a logical structure consisting of one or more physical files called piece. The backup file contains one or more database files, which can be data files, control files, or archive log files. Three types of files can be combined in any backup set. Only RMAN can parse the backup set format.

Image copies can only be generated on disks; backup sets can be generated on disks or tapes.

Data files, control files, and archive log image copies and backup sets can be online or offline backup, full or partial backup, and full or Incremental backup, it can be used in both archivelog mode and noarchivelog mode. However, backup sets can only be generated or restored using RMAN.

? {
Copycode ('p641code1 ');
} "Href =" javascript:; "> [copy to clipboard] {
Showcodetxt ('p641code1'); Return false;
} "Href =" javascript:; "> View code SQL
$ mkdir /u02/oradata/backup $ rman target system/oracle Recovery Manager: Release 10.2.0.1.0 - Production on Mon Oct 13 14:56:12 2008 Copyright (c) 1982, 2005, Oracle.  All rights reserved. connected to target database: ORA (DBID=1283726968) RMAN> backup as backupset datafile2> '/u01/db/oracle/oradata/ora/users01.dbf'3> format '/u02/oradata/backup/rman_backup_users01.dbf'; Starting backup at 13-OCT-08using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=147 devtype=DISKchannel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetinput datafile fno=00004 name=/u01/db/oracle/oradata/ora/users01.dbfchannel ORA_DISK_1: starting piece 1 at 13-OCT-08channel ORA_DISK_1: finished piece 1 at 13-OCT-08piece handle=/u02/oradata/backup/rman_backup_users01.dbf tag=TAG20081013T145636 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 13-OCT-08

3. RMAN settings

3.1 device settings

Options for disk backup include: parallelism, target directory, whether to generate a backup set or an image copy. The default degree of parallelism is 1, which means that the RMAN process will generate only one server process called channel to create a backup. When selecting the degree of parallelism, consider the nature of the number of CPUs and the disk subsystem.

The options used for tape backup specify the tape device data, tape library-specific options, and whether to compress the backup table. The specified number of tape devices is equivalent to the specified degree of parallelism for disk backup.

3.2 set backup Sets

The first option is maximum backup piece size. By default, there is no limit on the size of the backup slice: The entire backup set is physically stored in one slice or file. Because RMAN does not back up unused data blocks, you cannot know the size of the Backup set before you know the backup.

3.3. Policy Settings

The first option is to determine whether to back up the control file and server parameter file when a backup is generated. Backing up these two files is generally considered an excellent strategy. By enabling this automatic backup performance, you are sure you have the latest copies of the two important files. The default copy destination is determined by the db_recovery_file_dest parameter.

The next option is to determine whether to optimize the backup by excluding files that have not changed since the last backup.

There are also options to enable data block change tracking to accelerate Incremental backup.

Tablespace excluded from whole database backup allows you to specify one or more tablespaces that do not need to be backed up during the full backup operation.

The last part is the retention policy. Based on the backup retention policy, RMAN can delete backups that are considered unnecessary.

4. Scheduled Automatic Backup

Run a complete backup example of the database and use em to perform a comprehensive and complete online backup for the database.

Select whole database, enter the operating system user and password, tick the following, and click Next.

All of the above are directly next and use the default settings.

Start the backup operation.

View the running of a job.

Refresh to view the backup process.

5. control file backup

Because the control file is very important, another option for regular backup should also be used. The backup used for tracking will use the create controlfile command to generate a control file creation script. The syntax of the create controlfile command is similar to that of the create database Command.

Run the backup controlfile to trace command in SQL * Plus to create a file in the directory specified by the user_dump_dest parameter. You should rename it to a meaningful name and copy it to a secure location. You must back up the control files as long as you add or rename any data files or online redo log files, create or delete tablespaces.

? {
Copycode ('p641code2 ');
} "Href =" javascript:; "> [copy to clipboard] {
Showcodetxt ('p641code2'); Return false;
} "Href =" javascript:; "> View code SQL
SQL> alter database backup controlfile to trace; Database altered. SQL> show parameter user_dump_dest; NAME                       TYPE        VALUE-------------------------- ----------- ------------------------------user_dump_dest             string      /u01/db/oracle/admin/ora/udump SQL> exit $ cd /u01/db/oracle/admin/ora/udump $ ls -ltr

The last file is the latest file we have backed up. Open with VI and you can see that there is a very important part in the middle.

? {
Copycode ('p641code3 ');
} "Href =" javascript:; "> [copy to clipboard] {
Showcodetxt ('p641code3'); Return false;
} "Href =" javascript:; "> View code SQL
CREATE CONTROLFILE REUSE DATABASE "ORA" NORESETLOGS  ARCHIVELOG    MAXLOGFILES 16    MAXLOGMEMBERS 3    MAXDATAFILES 100    MAXINSTANCES 8    MAXLOGHISTORY 292LOGFILE  GROUP 1 (    '/u01/db/oracle/oradata/ora/redo01.log',    '/u01/db/oracle/oradata/ora/redo01b.log'  ) SIZE 50M,  GROUP 2 (    '/u01/db/oracle/oradata/ora/redo02.log',    '/u01/db/oracle/oradata/ora/redo02b.log'  ) SIZE 50M,  GROUP 3 (    '/u01/db/oracle/oradata/ora/redo03.log',    '/u01/db/oracle/oradata/ora/redo03b.log'  ) SIZE 50M-- STANDBY LOGFILEDATAFILE  '/u01/db/oracle/oradata/ora/system01.dbf',  '/u01/db/oracle/oradata/ora/undotbs01.dbf',  '/u01/db/oracle/oradata/ora/sysaux01.dbf',  '/u01/db/oracle/oradata/ora/users01.dbf',  '/ora02/oradata/ocp/mydemo.dbf',  '/ora02/oradata/ocp/ats.dbf',  '/ora02/oradata/ocp/bts.dbf',  '/ora02/oradata/ocp/cts.dbf'CHARACTER SET WE8ISO8859P1;

6. Manage RMAN backup

The information of the four backup sets is outlined. The keys of these four backup sets are 1, 2, 3, and 4. Backup set 2 and 3 form a complete backup of data files, control files, and server parameter files.

The catalog additional files button notifies RMAN of the backup generated by the operating system utility.
The crosscheck all button instructs RMAN to check whether the created backup set and image copy are still available.
The delete all expired button can delete all references to the lost backup that are detected by the cross-check.
The delete all obsolete button can delete all backups that follow the retention policy but are no longer needed.

7. default backup destination
The disk-based storage structure of the flash recovery area. The Flash recovery area is used as the default location for storing recovery-related data, including: Reusable copies of control files and online redo log files; archived log destinations; RMAN backup sets and image copies; flash Back log. The Flash recovery zone is controlled by the db_recovery_file_dest and db_recovery_file_size parameters. The two parameters are static.

Once a large amount of data written to the Flash recovery area reaches the specified size, problems may occur. In archivelog mode, Oracle does not allow you to overwrite online log files that have not yet been archived.

? {
Copycode ('p641code4 ');
} "Href =" javascript:; "> [copy to clipboard] {
Showcodetxt ('p641code4'); Return false;
} "Href =" javascript:; "> View code SQL
SQL> select * from v$recovery_file_dest; NAME-------------------------------------------------------------------SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES----------- ---------- ----------------- ---------------/u01/db/oracle/flash_recovery_area 2147483648  440984064                 0               3

It indicates that the maximum value of the flash recovery zone and its size is 2 GB, and 400 m is used. Three files exist in the Flash recovery area.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.