? Configure backup settings with Oracle Enterprise Manager? Enable automatic backup of control files? Configure the backup destination? Assign a channel to a tape target? Configure Backup Optimizations? Create a compressed backup? Create an encrypted backup
- Configuring persistent settings for Rman
? RMAN has preset default configuration settings. Use the Configure command to: – Configure automatic channels – Specify the backup retention policy – Specify the number of backup copies to create – Set the default backup type to Backupset or copy– limit the size of the backup fragment – Exclude tablespaces in Backup – Enable and disable backup optimizations – Configure automatic backup of control files – define archive log deletion policy – Specify the parallelism of the device – Set the encryption parameters and compression parameters for backup Configure the persistent settings for Rman to simplify the process of backing up and recovering with Rman, you can use Rman to set some persistent configuration settings for each target database. These settings control multiple aspects of the rman behavior. You can save persistent configuration information, such as channel parameters, parallelism, and the default device type in the Rman repository. These configuration settings are always stored in the control file and in the Recovery catalog database (if present). These settings provide default values and can be used immediately with Rman. However, when you develop a more advanced backup and recovery strategy, you may want to change these settings to enforce the policy. Use the Configure command to configure persistent settings for Rman backup, restore, replication, and maintenance jobs. These settings are valid for all Rman sessions until the configuration is cleared or changed. Note: Using the SET command to change the configuration in an Rman job (or session) only lasts for the duration of the job (or session). EM Note: This is also the case when using Rman through the Oracle Enterprise Manager interface. The backup setting provides default settings for all backups that occur. When you create a backup, you can override some of these settings for that particular backup.
To check the persistent Rman settings for a database:? If you are connected to a destination only, enter show all at the Rman prompt. Or:? If you are logged on to the target DB instance, query the V$rman_configuration view. View the RMAN persistence settings when you are connected to a destination and enter the show all command, or when you log on to Sql*plus and query the V$rman_configuration view. Example: Use Show all to view rman> show all; using target database control file instead of recovery Catalogrman configuration PA Rameters for database with Db_unique_name TEST0924 are:configure RETENTION POLICY to redundancy 1; CONFIGURE BACKUP optimization OFF; # defaultconfigure DEFAULT DEVICE TYPE to DISK; # defaultconfigure Controlfile autobackup on; CONFIGURE controlfile autobackup FORMAT for DEVICE TYPE DISK to '%F '; # defaultconfigure DEVICE type DISK PARALLELISM 1 BACKUP type to BACKUPSET; # defaultconfigure datafile BACKUP COPIES for DEVICE TYPE DISK to 1; # defaultconfigure ARCHIVELOG BACKUP COPIES for DEVICE TYPE DISK to 1; # defaultconfigure maxsetsize to UNLIMITED; # defaultconfigure encryption for DATABASE OFF; # defaultconfigure encryption algorithm ' AES128 '; # defaultconfigure COMPRESSION ALGORithm ' BASIC ' as of RELEASE ' DEFAULT ' OPTIMIZE for LOAD TRUE; # defaultconfigure ARCHIVELOG deletion POLICY to NONE; # defaultconfigure SNAPSHOT controlfile NAME to '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_test0924.f '; # default use view to view: [email protected]> select * from v$rman_configuration; conf# NAME VALUE----------------------------------------------------------------------1 controlfile autobackup ON2 RETENTION POLICY to redundancy 1
- control file Automatic backup
Rman> CONFIGURE controlfile autobackup on; Best practice Tip: Oracle recommends that you enable automatic backup of control files. Automatic backup of control files you can specify backup settings for instances using Oracle Enterprise Manager. In the Database home page, navigate to Availability > Backup Settings (Availability > Backup settings). To easily recover from all control file copies being lost, Rman should be configured to automatically back up the control files. Automatic backup of the control file is independent of the backup command explicitly requested for the backup of the current control file. If you are running Rman in Nocatalog mode, it is highly recommended to activate the control file automatic backup feature. Otherwise, you may not be able to recover the database if you lose the control file. To configure automatic backup of control files, use Oracle Enterprise Manager or use the following Rman command to modify the database's backup strategy: CONFIGURE controlfile autobackup on; Automatic backup of control files is disabled by default. If automatic backup of control files is enabled, Rman automatically backs up the control file and the current server parameter file (if the file is used to start the database) in the following cases:? At the end of the run script? When a successful backup is recorded in the Rman repository? When a structural change is made to the database, the Oracle kernel itself is backed up (for example, after a DDL operation that affects the control file content) for all device types, the control file automatic backup file name has a default format of%f, so Rman does not need the repository to infer the file location. and restore the file. The variable format is converted to C-IIIIIIIIII-YYYYMMDD-QQ, where:? IIIIIIIIII represents dbid? YYYYMMDD is the timestamp of the day the backup was generated? QQ is a hexadecimal sequence, starting from 00, the maximum value is FF you can change the default format by using the Configure Controlfile autobackup format for DEVICE type the type to ' string ' command.the value of the string must contain the substitution variable%f and cannot contain other alternative variables。 For example: CONFIGURE controlfile autobackup FORMAT for DEVICE TYPE DISK to '/u01/oradata/cf_orcl_auto_%f '; Unless otherwise indicated, automatic backup of control files is stored in
Quick Recovery ZoneIn Automatic backup with control files allows RMAN to recover the database even if the current control file, recovery directory, and server parameter files are inaccessible. Because the paths used to store automatic backups follow known formats, Rman can search for and restore server parameter files or control files from automated backups.
- Manage Persistent settings
? Use multiple streams of incoming and outgoing devices:rman> CONFIGURE device TYPE SBT
PARALLELISM3;? Use the show command to list the current settings: rman> Show All; Rman> SHOW EXCLUDE; rman> SHOW controlfile autobackup FORMAT;? Use the CLEAR option of the CONFIGURE command to reset any persistent settings to their default values: rman> CONFIGURE BACKUP optimization CLEAR; rman> CONFIGURE maxsetsize CLEAR; rman> CONFIGURE DEFAULT DEVICE TYPE CLEAR; Managing persistent settings parallelism is the number of data streams that can be used to read and write to the device. This can effectively allocate the number of channels when the device is used by Rman. For example, if a media manager has two tape drives available, the Media Manager Backup command allows you to use a two tape drive simultaneously when the degree of parallelism is 2. The degree of parallelism of a disk device type is also useful when you want to distribute a backup across multiple disks. You can use the followingPARALLELISMclause specifies the degree of parallelism used on the device: CONFIGURE device TYPE <device> PARALLELISM <n> where <n> is the degree of parallelism value. Using Rman'sSHOWcommand to view the Rman configuration settings. If show all is executed after connecting to the target database, only node-specific configuration and database configuration are displayed. By executing the Configure command with the clear option, you can return the value set by the same configure command to its default value.
To use tape storage for database backups, RMAN requires an Oracle Secure backup or Media Manager. Media Manager is a utility that uses facilitates, labeling, and unloading sequential media, such as a tape drive, to back up, restore, and restore data. Oracle DB Server calls the Media Management library (MML) software routines to back up and restore data files between media controlled by the media manager. Note that Oracle DB Server does not need to connect to the MML software when backing up to disk. The oracle Backup Solutions Program (BSP) provides a range of media management products that comply with the Oracle MML specification. With software compatible with the MML interface, Oracle DB sessions can back up data to the Media manager and request the Media Manager to restore the backup. First verify that the media vendor is a member of the Oracle BSP. You must install the Media Manager software and ensure that Rman communicates with the software before you can use Rman and Media Manager. perform the following basic steps according to the product to be installed: 1. Install and configure media management software on the target host or production network. The integration of Rman is not required at this stage. 2. Make sure that non-rman backups of the operating system files are performed on the target database host. This step will help you troubleshoot the problem later. 3. Obtain and install a third-party media management module for integration with Oracle DB. The module must contain libraries that are loaded by Oracle DB Server when accessing the media manager. Using Media Manager backup and restore operations The following Recovery manager script is a backup of data files to a tape drive controlled by the media Manager: Run {# allocating a channel of type ' SBT ' for s Erial deviceallocate CHANNEL ch1 DEVICE TYPE SBT; BACKUP datafile 3;} When Recovery Manager executes the command, the backup request is sent to the Oracle DB session that performed the backup. The oracle DB session identifies the output channel as a media management device, and then requests that the media manager load the tape and write the output. Media Manager will label the tapes and track the file names of the files on each tape. The media Manager also handles the restore operation. When you restore a file, the following steps are performed: 1. Oracle DB Server requests a restore of aSpecific files. 2. Media Manager determines the tape that contains the file and reads the tape. 3. The Media Manager transmits the information back to the Oracle DB session. 4. Oracle DB Server writes files to disk.
- Specify the backup destination
Backup can be written to:? Disk directory rman> CONFIGURE DEFAULT DEVICE TYPE to disk;? Tape (using Oracle Secure Backup)? Media Management Library – tape rman> CONFIGURE DEFAULT DEVICE TYPE to tape;– disk or tape (use proxy copy)? Fast Recovery zone: Disk area specifically reserved for backup and recovery and flashback database – Define location and size – files are automatically retained and deleted as needed the specified backup target backup can be written to the specified disk directory, media Management Library (MML), or fast recovery area. Specifying a disk directory or Fast recovery area means that the backup is moved to the hard disk media. In general, to keep disk space available, backups are periodically moved offline to tape through the media management interface. Any disk directory can be specified as a backup destination as long as the disk directory already exists. The Media management library can be used to copy files to a tape drive or to perform a proxy copy. A proxy replica is a location that requires the use of MML to create a copy of a file on a disk or tape drive. MML must be able to provide proxy replica services to create replicas. If you set up a quick recovery area, you can simplify many backup and recovery tasks. Oracle DB automatically assigns files and removes obsolete files when space is scarce. To specify that the backup be written to disk, use rman> CONFIGURE DEFAULT DEVICE TYPE to disks; Command. Then, when you create the backup, if you use the Format keyword (specifying the disk directory location of the backup), the backup is written to that location. If the quick recovery area is configured, it is backed up to that location, otherwise the backup is written to the platform-specific default location. To specify that you want to use a tape drive. Use rman> CONFIGURE DEFAULT DEVICE TYPE to TAPE;
- Configure and assign Channels
? To configure an automatic channel using the Configure command:? Manually assign channels:rman> CONFIGURE DEVICE TYPE SBT using the Allocate channel command within the run block; rman> CONFIGURE DEFAULT DEVICE TYPE to SBT; rman> CONFIGURE CHANNEL DEVICE TYPE SBT ... Rman> BACKUP DATABASE; rman> run{allocate CHANNEL ch1 DEVICE TYPE DISK; BACKUP DATABASE PLUS ARCHIVELOG;} Configure and assign channels select from the following options to configure the channel and perform a backup:? Use the Configure command to configure an automatic channel, and then issue the backup command at the Rman prompt or in the run block. Use the Allocate channel command in the run block to manually assign the channel, and then issue the backup command.
- Create a two-way backup set
To create a two-way backup set, use:? CONFIGURE ... BACKUP COPIES? BACKUP ... COPIES creating a two-way backup set Rman can be created for backup sets at the same timeFourReplicas, which are identical to each other. A copy of the backup set is a copy of all the backup fragments in the backup sets, each with a unique copy number (for example, 0tcm8u2s_1_1 and 0tcm8u2s_1_2). In most cases, the easiest way to create a two-way backup set is to use Backup ... Copies or configure ... Backup copies create a two-way backup set. For disk channels, specifying multiple values in the format option allows multiple copies to be placed on different physical disks. For SBT channels, if you use a Media manager that supports SBT API version 2, the Media Manager automatically places each copy on a separate piece of media (for example, a separate tape). Note: The system backup-to-tape (SBT) API is an interface defined for Media Management Library (MML) developers so that they can provide MML to communicate with Rman. Note that you cannot create a two-way backup set in the Quick recovery area, andTwo-way backup is only available for backup sets, not for image replicas。 If you specify backup when you create a copy of the image ... Copies option, you will receive an error. For image copy backup, configure is ignored ... BACKUP copies settings.Two-way backup sets are typically used for tape backups.
- Using Configure BACKUP COPIES
Create a two-way backup set rman> CONFIGURE ARCHIVELOG backup COPIES for DEVICE TYPE SBT to 2; rman> CONFIGURE datafile BACKUP COPIES for DEVICE TYPE SBT to 2; rman> backup DATABASE PLUS archivelog;--creates two copies backed up to two different tapes. rman> BACKUP DEVICE TYPE DISK as COPY DATABASE; is not affected by the copies configuration settings. Create only one copy of the backup to disk. Create a two-way backup set using Configure backup copies use configure ... The backup copies command specifies the exact number of backup sets to be created on the specified device type. When backing up with the backup backupset command, this setting applies to all backups except automatic backup of controlled files (because automatic backups of control files always generate a copy) and backup sets. Note: Automatic channels must already be configured. To create a two-way backup set using Configure backup copies, perform the following steps: 1. On the desired device type, the number of copies of the configuration data file and the archive redo log file. 2. Execute the backup command. 3. Issue the list Backup command to verify the backup. Note: The last backup command is not affected by the copies configuration settings. This command creates a single copy of the backup to disk.
? Skip backed-up files? Use When: – Backup optimization is enabled:rman> CONFIGURE Backup optimization on;– executes backup archivelog or backup with the all or like option BACKUPSET all command – only one type of channel is assigned? Use the force option to overwrite:rman> BACKUP DEVICE TYPE SBT BACKUPSET all force; Always used for RECOVERY area, db_recovery_file_dest, and RECOVERY Files backup options Backup optimization If Backup optimization is enabled, the backup command skips these files when the exact same files have been backed up to the specified device type. If Rman determines that a file is exactly the same and has been backed up, the file is a candidate file that can be skipped. However, Rman will determine whether to skip the file by performing further checks because the algorithm that Rman uses to determine whether there is sufficient backup on the specified device type takes into account both retention policy and dual backup functionality. Backup optimizations can be enabled in the Backup Settings page in Oracle Enterprise Manager, or by issuing the Configure Backup optimization on command. By default, backup optimization is disabled. For backup RECOVERY Area | Backup optimizations are automatically enabled by the Db_recovery_file_dest and backup RECOVERY files command system. To overwrite the backup optimization and back up all files (whether or not changed), specify the force option in the Backup command, as shown in the following example: Backup DEVICE TYPE SBT BACKUPSET all force; Please note that the Force option does not apply to files in the recovery area. Use Oracle Enterprise Manager or by issuing the following commands to permanentlyDisabling Backup Optimizations: CONFIGURE BACKUP optimization OFF;
- Save backup space by compressing unused blocks
During some types of backup operations, the following blocks can be skipped:? Unassigned Blocks: These blocks are higher than the data file's high water mark (HWM). Unused blocks: These blocks have been allocated but are no longer part of the segment. RMAN can skip blocks when performing certain types of backups by compressing unused blocks to save backup space. You can skip an unassigned block. These blocks have not been allocated; they are higher than HWM. In addition, you can skip certain allocated blocks that are no longer part of the segment (no longer used) when the following conditions are met:? No guaranteed restore points are defined. The data file contains only the data for the locally administered table space. The data file is backed up to a backup set as part of a full backup or a 0-level incremental backup. The backup is saved to disk, or Oracle Secure Backup is the media manager.
RMAN can perform binary compression on any backup set that is generated. In addition to compressing unused blocks, you can also perform binary compression. The available compression algorithms are: High, MEDIUM, low, and basic. DBAs can restore a compressed backup without performing additional steps. CONFIGURE COMPRESSION algorithm ' High/medium/low/basic ' run {SET COMPRESSION algorithm ' High/medium/low/basic '; ...} Compressing a backup does not restore data that is not needed for transaction processing (for example, for committed transactions). The advantage is that the backup time and storage space are reduced in general because it does not back up the restored data that is applied to the committed transaction. This optimization is enabled automatically. Compressing unused blocks reduces the number of blocks written to the backup (and the backup time), while binary compression uses the algorithm to compress the data that is written. The available compression algorithms are high, MEDIUM, low, and basic. If you specify it for a specific backup device, use the compressed keyword after the backup TYPE to clause. You can restore a compressed backup without performing any additional steps. It should be noted, however, that compression and decompression operations require CPU resources. Therefore, creating and restoring a compressed backup can take longer and require more system resources. When choosing an algorithm, you should consider disk space and dynamic system resources such as CPU and memory.
- Using Rman Backup compression
As shown, the binary compression of the backup set is supported by the algorithm settings. In addition to basic, all modes require Oracle Advanced compression database options. Because the performance of the various compression levels depends on the nature of the data in the database, the network configuration, system resources, and the type of computer system and the corresponding functions, Oracle Corporation cannot provide full description of the performance statistics that can be applied. To find the most appropriate level, consider the system's bandwidth-to-CPU balance, and the actual speed of the CPU. It is strongly recommended that you run tests with different compression levels for your data in your environment. The only way to ensure that the backup set compression level meets the performance requirements and any applicable service-level requirements is to select the compression level based on your environment, network traffic (workload), and data set. You can use the following levels or compression ratios:? Low: This level is the fastest. It provides less compression than medium, but has the lowest CPU utilization. (corresponds to Lzo compression.) )? MEDIUM: This level is good for both CPU usage and compression ratios. (corresponds to zlib compression.) )? High: This level provides the best compression ratio, but the CPU consumes the most. (corresponds to gzip compression.) )? BASIC: Corresponds to BZIP2 (10g type compression).
? Transparent encryption: Using wallet (default)? Password encryption: Use password (no wallet)? Dual-Mode encryption: – Use both transparent and password encryption modes – you can use either transparent mode or password mode to restore encrypted backups you can use one of the following three methods to encrypt a backup:? Transparent encryption: This method uses wallet, which is the default mode. Password encryption: This encryption method relies on passwords and does not require configuration of wallet. To restore, you must know the password used for the backup. Dual-mode encryption: You can use both transparent and password encryption. To restore, use either transparent mode or password mode. This type of encryption is useful if a backup is typically restored to a local site, but occasionally a backup is also delivered to another site.
- Set the date and time format for Rman
1. Set the Nls_lang and Nls_date_format variables so that Rman includes time information in all timestamp values. Add the following two lines to the ~ORACLE/.BASHRC file. Then exit all terminal windows. This ensures that these settings are valid when you create a new terminal window. Export Nls_lang=american_america.al32utf8export nls_date_format= "Yyyy-mm-dd:hh24:mi:ss" is as follows: [[email protected] ~]$ Rman target/recovery manager:release 11.2.0.3.0-production on Sat Oct 5 15:45:09 Copyright (c) 1982, Oracl e and/or its affiliates. All rights reserved. Connected to target database:test0924 (dbid=2720875862) rman> list backup; Using target database control file instead of recovery catalog List of Backup sets=================== BS Key Type LV Size Device Type Elapsed Time completion time-------------------------------------------------------------6 full 1.31G D ISK 00:29:5005-oct-13BP key:6 status:available compressed:no tag:tag20131005t114007piece Name:/u01/app/oracle/fast_recovery_area/ Test0924/backupset/2013_10_05/o1_mf_nnndf_tag20131005t114007_950dps9b_.bkplist of Datafiles in backup set 6File LV Type CKP SCN CKP time Name---------------------------------1 full 2375806 05-oct-13/u01/app/oracle/oradata/test0924/ SYSTEM01.DBF2 full 2375806 05-oct-13/u01/app/oracle/oradata/test0924/sysaux01.dbf Change the file to take effect immediately, and then view the format of the time: [email Protected] ~]$
VI. BASHRC#. BASHRC Export Nls_lang=american_america.al32utf8export nls_date_format= "YYYY-MM-DD:HH24:MI:SS" # Source Global Definitionsif [-F/ETC/BASHRC]; Then. /ETC/BASHRCFI # User specific aliases and functions
[[email protected] ~]$ source. BASHRC takes effect immediately. rman> list backup; Using target database control file instead of recovery catalog List of Backup sets=================== BS Key Type LV Size Device Type Elapsed Time completion time-----------------------------------------------------------------6 Full 1.3 1G DISK 00:29:50
2013-10-05:12:09:57BP key:6 status:available compressed:no tag:tag20131005t114007piece Name:/u01/app/oracle/fast_recovery_area/ Test0924/backupset/2013_10_05/o1_mf_nnndf_tag20131005t114007_950dps9b_.bkplist of Datafiles in backup set 6File LV Type CKP SCN CKP time Name-------------------------------------------1 full 2375806 2013-10-05:11:40:08/u01/app/orac LE/ORADATA/TEST0924/SYSTEM01.DBF2 Full 2375806 2013-10-05:11:40:08/u01/app/oracle/oradata/test0924/sysaux01.dbf
Source: http://blog.csdn.net/rlhua/article/details/12312463