To establish an incremental backup:
If the database is running in non-archive mode, only if the database is cleanly shut down (in normal,
Immediate, transactional mode off) for consistent incremental backups, if the database is running in a
mode, it can be done in the database shutdown state, or it can be backed up in a database open state. Again
The advantage of opening the archive mode, the archive log is more disk space, can also be equivalent to the number
It has been added layer protection. Creating an incremental backup is essentially a parameter incremental level=n, which executes the backup
command, for example, to create an incremental level 0 full-Library backup:
Rman> backup incremental level=0 database;
For example, create an incremental-level 1 USERS01.DBF data file backup
Rman> Backup incremental level=1 tablespace system
DataFile ' e:\oracle\oraback\sj_data.dbf ';
Note: The incremental backup created by Rman by default is differential, and if you want to establish a cumulative method, increase the
Backup, explicitly specified when the backup command is executed, for example:
Rman> Backup incremental level=2 cumulative database;
To create a mirrored copy:
The mirror copy in Rman is essentially the same as the backup via the OS Copy command, even the format of the command
are similar, except that copying a data file directly from the operating system's copy command is only a copy of the file, and Rman
Copy can verify the validity of the data while copying it. Personal view of the image replication application in Rman
Limited, but also does not reflect the advantages of rman, so I just have a general understanding of the concept, no actual
Operation, interested friends can do their own experiments, there is not much to do introduction.
Establish redundant backups
(
Rman provides a more cautious backup strategy: duplexed-mode backup, which is essentially a backup
Set, a backup set copy of the specified number of copies (up to 4 maximum) is generated to the specified location to avoid catastrophic
Crash when database corruption and backup loss occur, resulting in a full crash and improved backup availability. Available in Rman
Three ways to implement duplexed mode backup:
1) explicitly specify the copies parameter when executing the backup command in Rman. For example:
Rman> backup copies 3 database;
The above command will automatically generate 2 copies of the current backup set to the default backup directory at the same time as the full library backup.
2) Use the Set backup copies command in the run {} command block to set all the backup commands in the command block
Duplexed way, for example:
Rman> run{
Set backup copies 2;
Backup device Type disk format
' e:\oracle\oraback\dyk1\%u ', ' e:\oracle\oraback\dyk2\%u '
Tablespace users,sales;
}
The above command will generate two copies of the backup set, stored separately in the E:\ORACLE\ORABACK\DYK1 and
E:\oracle\oraback\dyk2 directory.
3) through configure ..... The backup copies command sets a predefined way of backing up duplexed
Configure. Backup copies command format, you can set the default copy count for the specified device type
Amount This configuration applies only to data files and archive redo log files and backups, and only when using automatic
Allocated channel can only be used when the Configure ...
Configuration of the backup copies command settings. For example:
Rman> Configure default device type to disk;
Rman> Configure DataFile backup copies for device type disk to 2;
Rman> Configure Archivelog backup copies for device type disk to 2;
The above command sets the number of copies of the data file and archive files on disk to 2, when the backup is executed
Database backup, a backup set of 2 data files is automatically generated.
Set up a save policy for Rman backup
Policy, if the database is very large and backups are performed more frequently, it is necessary to
Save and formulate a reasonable strategy. In a backup fragment created through Rman, the backup file is also made by Rman
and maintenance, so manual removal is not advisable, and Rman also provides a backup retention policy that is reasonably developed by
Rman automatically removes stale backup files for greater security and convenience, and two backup retention policies are available in Rman:
Based on time, and redundancy based on quantity
After you set up a backup retention policy for Rman, Rman automatically determines which backup sets or mirrors copy the files
No more reservations. These backup files will be marked as obsolete (obsolete) and can be used by the report obsolete
command to view the backup files that are currently in an obsolete state, or delete these obsolete. Obsolete commands by using the delete
Backup. For example:
Rman> report obsolete;
rman> Delete obsolete;
There are two points to know when executing the delete command:
If the backup that is judged to be obsolete is a mirror copy of a separate data file, then the delete command is executed
The image copy file will be deleted directly if the backup is determined to be a backup set
, you must wait until all other files in the entire backup set have been discarded before you can delete this backup set.
1) Time-based backup retention policy.
Simply put, you want the database to be restored to a few days ago. For example, setting the recovery period to 7
The backup that Rman retains is a guarantee that you can restore the database to those files at any time of the week. Set
A time-based backup retention policy can be configure through the command, for example:
Rman> Configure retention Policy to recovery windows of N days;
Note: After the command is executed by a positive integer greater than 0, Rman will always keep those that restore the database to n days before the n=
State, for example, the recovery time period is set to 7 days, then each data file is prepared
Must meet the following conditions:
sysdate-(select Checkpoint_time from V$datafile) >=7
Any backups that do not meet the above conditions will be discarded by Rman and can be deleted by the delete obsolete command.
2) Backup retention policy based on redundant quantity
Based on the amount of redundancy, the fact that a data file exists in various forms, including backup set and mirror copy
The number of backups. If the number of redundant backups for a data file exceeds the specified number, Rman discards the stale
Backup. Similarly, the number-based backup retention policy is also set through the Configure command, for example:
Rman> Configure retention Policy to recovery windows of N days;
Ibid.: n= positive integer greater than 0
You can also set policies that do not retain any data
Rman> Configure retention policy to none;
Backup optimization
Backup optimization in Rman means that, in the backup process, if certain conditions are met, Rman
Some files are automatically skipped and not included in the backup set to save time and space. Usually meet the following
conditions, the ability to enable backup optimizations is enabled:
Configure Backup optimization parameter is set to on;
The backup database or backup Archivelog command is executed with the all or the like parameter.
The allocated channel uses only one device type, that is, there is no simultaneous allocation of the use of SBT (tape) and disk
Multiple channels (disks).
Open backup optimization settings by using the following command:
Rman> configure backup optimization on;
In the case of backup optimizations, how Rman determines if the files to be backed up need to be optimized, the algorithm
is quite complex, and there are many factors that may affect the optimization algorithm, if a library is executed at 9 o'clock in the morning
Library backup, 3 o'clock in the afternoon when you perform a full-library backup again, the backed-up files are not changed and have been backed up
This part of the file is skipped. So theoretically backup optimizations are only available for read-only table spaces or offline table spaces
Role. Of course, for archivelog files that have been backed up, it also skips
3) Basic Supplement
The format string overrides the variable, and the various substitution variables that can be used when using the format parameter are as follows:
%c: Copy number of backup slices (numbered starting from 1);
%d: database name;
%d: Number of days in the month (DD);
%m: The Month in the year (mm);
%f: A unique name based on dbid, this format is C-IIIIIIIIII-YYYYMMDD-QQ, and its
In IIIIIIIIII for the database of dbid, YYYYMMDD as the date, QQ is a 1-256 sequence;
%n: The database name, and is populated with an X character on the right so that it remains the length of 8;
%u: is a 8-character name that consists of the backup set number and the build time compression. %u can be used for each
The backup set generates a unique name;
%p: Indicates the number of backup fragments in the backup set, numbering starting from 1;
%u: A shorthand form for%u_%p_%c, which can be used to generate each backup fragment (that is, a disk file)
A unique name, which is the most commonly used naming method;
%s: The number of the backup set;
%t: Backup set timestamp;
%t: Date format (YYYYMMDD); s
Note: If the format option is not specified in the backup command, Rman uses%u as the backup fragment by default
Name.
Configure Configuration Item Introduction
First, take a look at the current configuration, and go through the Show All command:
Connect to target database: Jssweb (dbid=3391142503)
Rman> Show All;
Using target database control file instead of recovery directory
The Rman configuration parameters are:
Configure retention policy to recovery windows of 3 days;
Configure backup optimization off; # Default
Configure default device type to disk; # Default
Configure Controlfile autobackup on;
Configure Controlfile autobackup format for device type disk to ' e:\oracle\oraback\%f ';
Configure device type disk parallelism 1; # Default
Configure DataFile backup copies for device type disk to 1; # Default
Configure Archivelog backup copies for device type disk to 1; # Default
Configure Maxsetsize to unlimited; # Default
Configure snapshot Controlfile name to ' E:\oracle\oraback\sj_data.ora '; #
Default
Rman>
The show command is briefly introduced in the Rman command, and it is also known that the following #default indicates that the configuration is still
Is the initial default configuration, if you want to reset a change over configuration option to
Initial settings, with the following command: Configure ... clear; For example:
Rman> Configure retention policy clear;
Configure retention policy to recovery windows of 3 days;
The above configurations, some of which have already been shown in the previous chapters, are described in more detail below:
1) Configure retention policy to configure backup retention policies
Two Retention policy settings:
Based on time:
Configure retention policy to recovery windows of N days;
Based on the number of redundancies:
Configure retention policy to redundancy N;
You can also cancel the backup retention policy:
Configure retention policy to none;
2) Configure backup optimization configuration backups optimized
Backup optimizations: Both off and on two states
To turn on backup optimization:
Configure backup optimization on;
To turn off backup optimizations:
Configure backup optimization off;
3) Configure default device type to configure IO device types
There are two types of IO devices supported by Rman: Disk and tape (SBT), which are disks by default.
Using Disk devices:
Configure default device type to disk;
Use tape settings:
Configure default device type to SBT;
One thing to note here is that if the IO device changes, the relevant configuration items also need to be modified. For example:
Rman> Configure device type disk parallelism 2;
4) Configure Controlfile autobackup configuration control file Automatic backup
Whether to automatically back up, contains two states: off and on
Turn on automatic backup
Configure Controlfile Autobackup on
Disable automatic backup
Configure Controlfile Autobackup off
Specifies the control format and path for the backup. For example:
Configure Controlfile autobackup format for device type disk to
' E:\oracle\oraback\%f ';
During the backup, a snapshot of the control file is generated to control the read consistency of the file, which can be
With the following configuration: Configure snapshot Controlfile name to
' E:\oracle\oraback\sj_data.ora ';
5) Configure device type to set up a parallel backup
Rman supports parallel backup and recovery, or you can specify the default degree of parallelism in the configuration. For example:
Configure device type disk parallelism 2;
Specifies that in the future backup and recovery, the degree of parallelism is 2, while 2 channels are turned on for backup and recovery.
Of course, you can also specify the channel in run to determine the degree of parallelism between backup and recovery. The number of parallelism determines the opening
The number of channels. If a channel configuration is specified, the specified channel will be used, and if no channel is specified, the
Default channel configuration. By default, the degree of parallelism for automatic allocation channels is 1, if you set the parallelism
If the parallel channel is set to 2, then in the run block, it will use 2 parallel channels by default; If the Run command
The allocate channel is specified in the block, then Rman will take the set channel as the backup command.
Regardless of whether multiple parallel channels are configured in the Configure. It is important to note that in the backup command there is a
Filesperset parameter, which refers to the backup fragments that can be included in each backup set created by Rman (that is, the disk
The default value of 64, if the parameter value is not specified when the backup command is executed, the
Rman will only use the first channel to perform a backup, and the other channels will be idle. About the number of channels and
There is also a size relationship between the Filesperset values, that is, the Filesperset value is not less than the set channel number.
6) Set redundancy of backup files
Configure DataFile backup copies
As follows:
Rman> run{
Set backup copies 2;
Backup device Type disk format
' e:\oracle\oraback\dyk1\%u ', ' e:\oracle\oraback\dyk2\%u '
Tablespace users,sales;
}
7) Configure Maxsetsize Configure the maximum size of the backup set
This configuration limits the maximum size of the backup set on the channel. The unit supports BYTES,K,M,G. The default value is unlimited.
8) Rman Backup-related dynamic performance table
V$archived_log: This view contains the creation of all archived redo log files, backup scenarios, and their
His message.
V$backup_corruption: This view shows what backup sets Rman found corrupted data in.
When you use the backup validate command to check the set of backups, if a corrupted block of data is found, Rman
The record will be written in this view.
V$copy_corruptio: This view shows which mirror copy backup files have been corrupted.
V$backup_datafile: This view is typically used to get the number of non-blank chunks in each data file, from
and help you create a backup set that is basically equal in size. In addition, the view also contains corrupted data files in the
The information for the data block.
V$backup_redolog: This view shows which archive redo log files are in the existing backup set of the diet.
V$backup_set: This view displays information about the backup sets that have been created.
V$backup_piect: This view displays information about the backup fragments that have been created.
You can obtain status information for an in-progress mirror copy operation by using the following SQL statement:
Select Sid,
serial#,
Context
Sofar,
TotalWork,
Round (Sofar/totalwork *, 2) "% complete"
From V$session_longops
where opname like ' rman:% '
and opname not like ' rman:aggregate% '
Use the following SQL to obtain SID and SPID information for the service process that Rman uses to complete the backup operation:
Select Sid,spid,client_info from V$process p,v$session s where p.addr=s.paddr and
Client_info like '%id=rman% '
Rman Channel
The last basic knowledge referred to the channel, the Rman channel is essentially a data stream to the storage device. It's like city sex.
Through the road, more than a few loops to alleviate traffic is meaningful. In Rman, either manually or automatically
Way to allocate channels.
1) Manual channel allocation
When you perform commands that require disk I/O operations such as backup, restore, delete, and so on, you can associate them with the allocate
The channel command is placed in a command block of run, and the channels are allocated using the allocate channel. For example:
run{
Allocate channel CH1 device type disk format ' e:\oracle\oraback\%u ';
Backup datafile ' E:\oracle\oradata\oradb1\sj_data.ora ';
}
It is important to note that each backup, delete, etc command executed in Rman requires at least one channel to be used.
The number of channels determines the degree of parallelism performed by these operations.
Oracle Rman Backup Strategy