RMAN User Manual 1

Source: Internet
Author: User
Tags configuration settings
Document directory
  • 1. Start or exit RMAN
  • 2. Configure the RMAN persistent setting Environment
  • 3. Back up database files
  • 4. Manage RMAN Repository
Technorati label: rman, Oracle

RMAN concise User Manual 1 (reproduced)

Background information

User Manual is based on Oracle 10.2

Reference: B14193-02

Minimum Environment

■ Target database: The target database for backup

RMAN Client: RMAN client. It is mainly responsible for interpreting backup and recovery commands, connecting to the server session to execute relevant commands, and recording backup and recovery activities in the control file.

Optional components:

Flash recovery area: The location of the specified disk. In this location, the database can store and manage files related to backup recovery.

Media Management Software: Media management software can be provided by a third party, but the RMAN backup interface is required.

Recovery catalog:It is the best practice of isolating schma on a database. It is used to record the various operations of RMAN for backup and recovery of one or more databases.

RMAN Repository:

The list, report, and show commands of RMAN can be used to display information in RMAN repository. RMAN repository is mainly stored in the control file of the backup target database. Initialization parameter: control_file_record_keep_time is used to control the time when the backup record is saved in the control file. After this time, the record information will be overwritten and reused by the updated backup information.

Recovery catalog

You can use the recovery catalog to save RMAN Repository Information and Records. The recovery catalog can also save the backup scripts frequently run by RMAN.

Flash recovery area

Is to record the automatic backup and recovery of the disk, throughFlash recovery areaTo simplify the management of disk space and Backup recovery files. You can use the db_recovery_file_dest and db_recovery_file_dest_size parameters to setFlash recovery areaLocation and space size. You can also specify a persistence policy to minimize the time and frequency of data recovery through tape.

Media managers

RMAN uses a third-partyMedia Management Software. Media Manager can control the devices in Backup recovery. Manage the loading, labeling, unloading, and other functions of media. A media management device is also called an SBT (system backup to tape) device.

RMAN Channels

RMAN executes all backup and recovery activities, which are Server sessions on the target database instance. Each session on the server used by RMAN is calledRMAN Channel. A channel can be used for disk operations.Disk ChannelOr one that is used together with media managementSBT Channel. You can use the RMAN allocate channel command to allocateChannelsTo specify the number of Server sessions that execute the task and the settings that affect the server session. You can also use the configure command to configureChannelsTo specify the default persistence settings for RMAN. If any channels is displayed and specified, the default configuration is ignored. If RMAN is connected to the target database for the first time, a disk channel will be generated immediately, and the disk channel will always exist as long as ramn is connected to the target database. It is calledDefault ChannelBut it is not used for transferring large data volumes, such as backing up or recovering database files.

1. Start or exit RMAN

Rman must be connected to the target database (with sysdba privileges) for backup and recovery. Likewise, if you have a recovery Catalog Database, RMAN can also connect to the recovery Catalog Database. Use the connect command to connect RMAN to the target database.

1. Start RMAN and connect to a target database and recovery catalog:

% RMAN target/catalogCat_usr/PWD@Cat_str

2. directly connect to the target database without using the recovery catalog:

% RMAN target sys/PWD@Target_str

3. Start RMAN only:

% RMAN

RMAN command line syntax options

RMAN

[Target [=] connectstringspec

| {Catalog [=] connectstringspec}

| Log [=] ['] filename ['] [append]

]...

Connectstringspec: =

['] [Userid] [/[Password] [@ net_service_name] [']

In the following example, an output file of the RMAN session is appended to $ ORACLE_HOME/dbs/log/msglog. log.

% RMAN target/log $ ORACLE_HOME/dbs/log/msglog. Log append

Exit RMAN Client

RMAN> exit

2. Configure the RMAN persistent setting Environment

Display All configuration information: RMAN> show all;

2.1 configure flash recovery area

If you use flash recovery area, the backup will be saved in the Flash recovery area unless you specify a location in the BACKUP command. If none of them are specified, the disk backup is saved in the default location of the specific operating platform. You can also configure a format for disk channel to specify different backup locations. You can use the format clause by running the configure Channel Device Type disk. Command.

In the following example, configure RMAN to write the backup to/tmp of the Disk:

RMAN> Configure Channel Device Type disk format '/tmp/% U ';

The % u table indicates that a unique file name is used for backup.

If you want to restore the default settings of the original disk backup location:

RMAN> Configure Channel Device Type disk format clear;

2.2 configure the tape device and channels

After you have configured your media management software, you can use media management to specify the default target location for RMAN backup.

RMAN> Configure Default device type to SBT;

Sometimes media management requires a parameter string to configure device information.

RMAN> Configure Channel Device Type SBT parms = 'env =Mml_env_settings';

Multiple channels can be configured to run parallel backup. The following command configures three SBT channels for the RMAN backup:

RMAN> Configure device type SBT parallelism 3;

2.3 configure a retention policy)

The retention policy is used to manage the database backup for a long time, and how long ago the database can be recovered. The retention policy can follow the recovery window (recovery window) (how long ago the database was recovered) or the redundant backup (redundancy value) (the number of backups of each file must be retained ).

The following command ensures that all necessary backups that can be recovered to a specific time point are at least 7 days

RMAN> Configure retention policy to recovery window of 7 days;

Run the following command to ensure that RMAN backs up three data files:

RMAN> Configure retention policy to redundancy 3;

You can use Delete Obsolete To quickly delete backups that are no longer needed by the persistence policy. (However, you do not need to execute this command for those backups stored in the Flash recovery area. However, when there is space demand, the database will automatically delete expired backups in the Flash recovery area or files with media Backup management)

You can also use the keep option of the backup and change commands to invalidate the specified backup.

2.4 automatic backup of configuration control files

After RMAN backup, the control file can be automatically backed up to protect RMAN repository. The following command ensures automatic backup of the control file by RMAN:

RMAN> Configure controlfile autobackup on;

By default, RMAN automatically generates the name of the backup file for the automatic backup control file and stores it in the Flash recovery area. Run the following command to configure RMAN to write the backup file of the automatic backup control file to the/mybackupdir directory:

RMAN> Configure controlfile autobackup format for device type disk to '/mybackupdir/CF % F ';

The character % f Represents the combination of a group of elements, including dbid, day, month, year, and sequence number to generate a unique name. Note: % F must contain the formatted name string.

Restore all default configurations

RMAN> Configure Channel Device Type SBT clear;

RMAN> Configure retention policy clear;

RMAN> Configure controlfile autobackup format for device type disk clear;

3. Back up database files

If we use backup as copy to back up a file, RMAN copies the file as an image (Image copies. That is, copy each bit of the database file on the disk. By using backup as copy, relevant information is recorded in RMAN repository, and RMAN can be used for recovery. An image cannot be copied on a tape.

Run the following command to copy all data files in the database:

RMAN> Backup as copy database;

If you use backup as backupset, RMAN stores the backup data to the backup set (Backup sets).A backup set contains more than one backup disk (Backup pieces)Is a physical file that contains data in a format that only RMAN can access. Backup sets can be written on disks or tapes and can only be written by RMAN to tapes. The following command uses the default channels to create a database backup and archive logs on the tape device in the backup set format:

RMAN> Backup Device Type SBT Database Plus archivelog;

Note:Backing up data files on a disk in the backup set format can save disk space and time. Because RMAN can skip some data file blocks that do not need to be backed up. Once a backup set is created on the disk, you can still use backup backupset to move it to the tape.

Back up individual database files

RMAN can also use different options to back up individual tablespaces, data files, control files, spfiles, and backup sets:

RMAN> Backup archivelog completion time between 'sysdate-31 'and 'sysdate-7 ';

RMAN> Backup tablespace system, users, tools;

RMAN> Backup as backupset datafile 'oracle _ home/oradata/trgt/users01.dbf ',

'Oracle _ home/oradata/trgt/tools01.dbf ';

RMAN> Backup datafile 1, 3, 5;

RMAN> Backup current controlfile to '/backup/curr_cf.copy ';

RMAN> Backup spfile;

RMAN> Backup backupset all;

Parameter description

Format: Format '/tmp/% U' specifies the location and name of backup pieces and copies. The replace variable must be used to generate a unique file name.

Tag: Tag 'Monday _ Bak' specifies a user-defined backup tag. If not specified, RMAN specifies a default tag for date and time.

Example:

RMAN> Backup format = 'al _ % d/% t/% S/% P' archivelog like '% arc_dest % ';

RMAN> Backup tag 'Weekly _ full_db_bkup 'database maxsetsize 10 m;

RMAN> backup copies 2 device type SBT backupset all;

3.1 incremental backups (Incremental Backup)

If Incremental backup is used, RMAN will create an incremental backup of the database (Incremental backups). Incremental backup records the changes of each data block in the database since the last Incremental backup. However, the start point of Incremental Backup must be level 0 Incremental backup. (Level 0 Incremental Backup), That is, all the blocks in the backup database. Then start level 1 (Level 1Only records the data block changes from the last Incremental backup. This backup includes (Cumulative) (All data block changes since the last 0-level backup) and changes (Differential) (Since the last Incremental backup after the data block change, whether it is level 0 or Level 1 backup) Incremental backup is usually smaller and faster to create a full database backup. Restore the database from an incremental backup is faster than using the log (redo logs) method. As long as the Incremental backup is available, RMAN will be used in the recovery.

3.1.1 Incremental Backup modification (incrementally updated backups)

Incremental modification of backup (Incrementally updated backups)Allows more daily incremental backups. Roll back the first-level Incremental backup to the previous zero-level backup. This will generate a level 0 backup that includes a level 1 Incremental backup. Using this modified backup of level 0 will make recovery faster.

3.1.2 validating backups)

Check whether the backup is available by checking whether the current database file exists, the file location, the remaining physical space, and the logical error.

RMAN> Backup validate database archivelog all;

3.2 Restore database files

Restoring is to select the desired backup from the recovery operation. Recovery applies changes in logs and incremental backups to data files so that the data files are restored to the desired SCN number or a specified time point.

3.2.1 restore the entire database

Use the Restore database and recover database commands to restore the entire database

RMAN> startup force Mount;

RMAN> Restore database;

RMAN> recover database;

RMAN> alter database open;

Note: When the entire database is restored, the database must not be in the open state.

3.2.2 restore the current tablespace

When the database is opened, use restore tablespace and recover tablespace to restore individual tablespaces. First, deprecate the tablespace to be restored (offline), and then restore the tablespace in restore and recover.

In the following example, restore the users tablespace:

RMAN> SQL 'alter tablespace users offline ';

RMAN> restore tablespace users;

RMAN> recover tablespace users;

RMAN> SQL 'alter tablespace users online ';

3.2.3 restore the current data file

When the database is opened, use the restore datafileherecover datafile command to restore the specified data file. First, deprecate the file to be restored, and then restore the data file (Restore and recover.

In the following example, restore the data file 7:

RMAN> SQL 'alter database datafile 7 offline ';

RMAN> restore datafile 7;

RMAN> recover datafile 7;

RMAN> SQL 'alter database datafile 7 online ';

3.2.4 recover individual data blocks

RMAN can restore individual blocks in the data file. When RMAN performs a complete scan of the file to be backed up, any corrupted block information will appear in the V $ database_block_partition uption view. Damage information is usually displayed in the alarm log (Alert logs), trace files, and query SQL results.

The following example uses blockrecover to correct all bad blocks:

RMAN> blockrecover upload uption list;

You can also restore the specified data block, as shown in the following example:

RMAN> blockrecover datafile 7 block 233,235 datafile 4 block 101;

3.2.5 validating restores)

Use the restore... validate operation to confirm that the restore operation is successful.

RMAN> Restore database validate;

RMAN operation report

The list and report commands of RMAN can generate multiple reports based on RMAN repository.

Backups list

Use the list backup and list copy commands to display the backup and data file copy information in repository.

RMAN> List backup of database;

RMAN> List copy of datafile 1, 2, 3;

RMAN> List backup of archivelog from sequence 1437;

RMAN> List controlfilecopy "/tmp/Cf. CPY ";

RMAN> List backupset of datafile 1;

You can use specific parameters to control the output of the LIST command:

By backup: displays the backup information of the database. (Backup set output information. This is the default expression .)

By file: displays the backup file information (displays the backup of the completed backup file)

Summary: displays the backup summary. (Display abstract information. By default, the output option is verbose .)

Additional options:

Expired:

List expired copy; (the backups recorded in RMAN repository are displayed, but the crosscheck command does not show backups at the specified disk location or on tape. This backup has been deleted by RMAN)

Recoverable:

List backup recoverable; (list available data file backups or copies, and can be used by the current database for recovery (restored and recovered .)

Report database files and backups

The report command can perform more complex analysis than the LIST command.

Need backup:

Report need backup database; (the files under the current retention policy need to be backed up .)

Obsolete:

Report obsolete; (the backup that has expired under the current retention policy is displayed .)

Unrecoverable:

Report unrecoverable; (displays objects that have been unrecoverable in all data files since the last backup .)

Schema:

Report Schema; (report the tablespace and data files currently in the database (default .)

Monitor RMAN through V $ views

The execution degree of RMAN jobs and also completed jobs are stored in V $ rman_status. V $ rman_output saves the text output of RMAN jobs.

When an RMAN job is working, use the following SQL link to display the corresponding channel of the job:

SQL> select S. Sid, P. spid, S. client_info from V $ PROCESS p, V $ session s where P. ADDR = S. paddr and client_info like 'rman % ';

The following example calculates the RMAN job degree.

SQL> select Sid, serial #, context, SOFAR, totalwork, round (SOFAR/totalwork *, 2) "% complete" from V $ session_longops where opname like 'rman % 'and opname not like' % aggregate % 'and totalwork! = 0 and SOFAR totalwork;

4. Manage RMAN Repository

The original data (metadata) of RMAN repository is always stored in the control file of the target database. You can also create a recovery catalog in another database to store all RMAN records.

4.1 manage control file records

Set control_file_record_keep_time = In the parameter fileNumber_of_days_to_keepThe parameter determines the record retention time.

4.1.1 multi-direction backup check (crosschecking backups)

The crosscheck command checks whether the files backed up and copied by RMAN in repository are still readable.

RMAN> crosscheck backup; # Check the backup of rman on the configuration Device

RMAN> crosscheck copy; # check the copy of the Image of rman on the configuration device.

If the backup storage is not configured with media management and tape pipeline, you must allocate a maintenance pipeline on the tape device before crosscheck and delete.

RMAN> allocate channel for maintenance device type SBT;

RMAN> crosscheck backup;

4.1.2 Delete backups created through RMAN

Delete the backup and copy created by rman on disks and tape devices by using the DELETE command. The object in the control file of Peugeot is deleted, and remove the records in the recovery catalog (if catalog is used ).

RMAN> Delete backupset 101,102,103;

RMAN> Delete controlfilecopy '/tmp/Cf. cpy ';

RMAN> Delete noprompt archivelog until sequence = 7300;

RMAN> Delete backup of spfile tablespace users device type SBT;

RMAN> Delete backup of database like '/tmp %'; # pattern match

RMAN> Delete archivelog all backed up 2 times to device type SBT;

The following useful DELETE command options are as follows:

Expired:

Delete expired; (delete an expired (expired) backup or copy represented by crosscheck)

Obsolete:

Delete Obsolete; (delete outdated backup and copy based on the persistence policy .)

Noprompt:

Delete noprompt obsolete; (you do not need to prompt to delete the files to be deleted)

4.1.3 cataloging and uncataloging backups and copies)

The catalog command adds backup information available for RMAN to RMAN repository. This command records the information of using tools to create backups except RMAN. For example, if you use an operating system tool to copy a data file image, if you have used RMAN to create a backup but it is no longer displayed in RMAN repository, you can use this command to enable RMAN to use these backups for backup and recovery.

RMAN> catalog datafilecopy '/backup/users01.bak'; # copy

RMAN> catalog like '/backup ';

If the backup is manually deleted using the operating system command, you can use the change... uncatalog statement to remove the information in RMAN repository.

RMAN> change controlfilecopy '/tmp/Cf. CPY' uncatalog;

RMAN> change backupset 121,122,127,203,300 uncatalog;

4.1.4 repeated task execution: RMAN and script

RMAN supports the use of stored scripts and command files to help manage repetitive tasks. The RMAN Run Command provides controllable scripts ..

Use command files

A command file is a text file that contains the RMAN command on the client.

RMAN> @/my_dir/my_command_file.txt # Runs specified command file

Any file with the extension can be used. Run RMAN to call the Command Script, as shown below:

% RMAN @/my_dir/my_command_file.txt

Controllable Script: Run Command

The run command can use a series of RMAN commands. If a command fails, the remaining commands in the running block will not be executed.

Run {

Backup archivelog all delete all input;

Backup incremental level 0 tag mon_bkup database;

}

If one or more archiving logs fail to be backed up, RMAN will continue to back up all the archived logs that can be backed up because these tasks are caused by a Backup command. However, the backup Incremental after backup archivelog will not be executed. The command set, switch datafile, and allocate channel can be used in the Run Command block. The pipeline configuration and other parameters configured by the configure command are ignored when running the command block.

4.2 views related to backup and recovery

The following information describes the views that can access the RMAN repository information.

If the query view is stored in the control fileV $View starting, If you are using a recovery catalog, use a View starting with RC _.

1. V $ archived_log (rc_archived_log): archived and Unarchived redo logs

2. V $ backup_datafile (rc_backup_controlfile): control files in backup Sets

3. V $ backup_partition uption (rc_backup_partition uption): Configure upt block ranges in datafile backups

4. V $ backup_datafile (rc_backup_datafile): datafiles in backup Sets

5. V $ backup_files (rc_backup_files): RMAN backups and copies in the repository.

6. V $ backup_piece (rc_backup_piece): Backup pieces

7. V $ backup_redolog (rc_backup_redolog): Archived logs in backups

8. V $ backup_set (rc_backup_set): Backup Sets

9. V $ backup_spfile (rc_backup_spfile): Server parameter files in backup Sets

10. V $ datafile_copy (rc_controlfile_copy): control file copies on disk

11. V $ copy_partition uption (rc_copy_partition uption): Information about datafile copy partition uptions

12. V $ database (rc_database): Databases registered in the recovery catalog (rc_database) or information about the Currently mounted database (V $ database)

13. V $ database_block_0000uption (rc_database_block_0000uption): Database blocks marked as duplicate upt in the most recent RMAN backup or copy

14. V $ database_incarnation (rc_database_incarnation): All Database incarnations registered in the catalog

15. V $ datafile (rc_datafile): All datafiles registered in the recovery catalog

16. V $ datafile_copy (rc_datafile_copy): datafile image copies

17. V $ log_history (rc_log_history) historical information about online redo logs

18. V $ offline_range (rc_offline_range): offline ranges for datafiles

19. V $ proxy_archivedlog (rc_proxy_archivedlog): Archived log backups created by proxy copy

20. V $ proxy_controlfile (rc_proxy_controlfile): control file backups created by proxy copy

21. V $ proxy_datafile (rc_proxy_datafile): datafile backups created by proxy copy

22. V $ log and V $ logfile (rc_redo_log): Online redo logs for all incarnations of the database since the last catalog Resynchronization

23. V $ thread (rc_redo_thread): All redo threads for all incarnations of the database since the last catalog Resynchronization

24. N/A (rc_resync): Recovery catalog resynchronizations

25. V $ rman_configuration (rc_rman_configuration): RMAN persistent configuration settings

26. V $ tablespace (rc_tablespace): All tablespaces registered in the recovery catalog, all dropped tablespaces, and tablespaces that belong to old incarnations

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.