In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
RMAN (Recovery Manager): recovery Manager
RMAN concept:
RMAN: Recovery Manager is a management tool for backing up and restoring databases. Server process for backup and recovery is established, and backup and recovery is done on oracle server.
It has the following characteristics:
1) the function is similar to physical backup, but N times more powerful than physical backup, as can be seen from the following features
2) empty blocks can be compressed
3) increments can be achieved at the block level
4) you can package the backup output into a backup set, or you can split the backup set according to a fixed size.
5) the process of backup and recovery can be managed automatically
6) scripting can be used (stored in Recovery catalog)
The concept of composition of RMAN:
RMAM client (RMAN client)
A client application used to operate backup and recovery, which can connect to the target database over the network
Target database (target database)
The database backed up and restored by RMAN is the target library; the goal of your backup and recovery is called the target library.
Auxiliary database (secondary database)
A copy of the main library, usually used for testing. The DBID of the main library is different from that of the auxiliary library, and the DB_NAME can be different.
Catalog database (restore catalog database)
The metadata information of RMAN backup is stored in the control file by default. Because the control file is divided into bad reuse records and non-circular reuse records, backup information belongs to circular reuse records, which will be constantly covered and reused, and will be retained by default for 7 days. The preservation time is limited. You can use the recovery catalog database to achieve long-term preservation of RMAN backup metadata information.
Media manager (Media Manager)
If you want to store backup files to other devices (such as with libraries), you need a media manager.
Fast recovery area (flashback recovery area)
By default, RMAN stores backups in the flashback recovery area.
Db_recovery_file_dest
Db_recovery_file_dest_size
View:
V$recovery_file_dest
V$recovery_area_usage
Channel (Channel):
The data flow from the RMAN tool to the storage device is called a channel.
With this channel, the data is read to pga, processed, and written to the output disk.
Backup strategy for RMAN:
(backups that meet the RMAN backup strategy but are no longer needed are outdated backup obsolete)
Recovery time window:
Ensure that the existing backup can restore the database to any time within the recovery time window.
Explanation:
The current time is 14, and the recovery time window is set to 7 days, 7-14.
Suppose there is a backup of No. 6.
You can restore to any time within 7 days by using the backup + log of No. 6.
Backups before the 6th will become obsolete.
Even if there is a backup between the 7th and 14th, it cannot be restored to any time within 7 days, so the backup on the 6th will not become an obsolete backup.
RMAN > configure retention policy to recovery window of 7 days
RMAN > configure retention policy clear
Redundancy retention policy:
The number required for each data file backup.
For example: make a full backup of the data file datafile 7 on Monday, Tuesday, Wednesday and Thursday
There are 4 full backups of the data file datafile7 at this time.
If the redundancy parameter value is 2 in the configuration command, then Monday and Tuesday's datafile7 full backups are out of date.
If another backup is being made on Friday, Wednesday's datafile7 full backup becomes obsolete.
Archive log deletion policy:
Several archive log backups need to be kept and can be deleted from disk only if the logs meet the archive log deletion policy.
RMAN > configure retention policy to redundancy 2
RMAN > configure retention policy clear
Archive log deletion:
Backup archivelog all delete input (delete after backup is complete)
Delete archivelog all (delete directly)
RMAN > configure archivelog deletion policy to backed up 2 times to disk
When backing up archived logs, if 2 backups already exist in the archived log, the backup archivevlog command skips the number of archived logs that meet the requirement.
Some other RMAN environment parameter settings:
Control automatic backup of files:
When the database starts any backup behavior or changes in the physical structure of the database, a current control file and spfile file are automatically backed up by default.
RMAN > configure controlfile autobackup on
RMAN > restore controlfile from autobackup
Backup device type:
Tape device SBT
Disk device DISK
Configure default device type to disk
Channel Settings:
Automatically assign channels:
Configure command to complete the channel configuration. If you do not manually assign channels to RMAN, RMAN will use predefined settings to automatically assign channels to commands
Configure channel device type disk format 'xxx'
Can be configured to automatically assign multiple channels
Manually assign channels:
The allocate channel command allocates channels, which can only be placed in the run command block, and the channels it allocates only operate on commands within the run block.
Run {
Allocate channel D1 device type disk format 'xxx'
Allocate channel D2 device type disk format 'xxx'
Backup database
}
Parallelism:
The number of channels matches the number of parallelism, and if the number of channels allocated is greater than the set degree of parallelism, RMAN only writes data to the channels that match the degree of parallelism, and ignores other channels that exceed the degree of parallelism.
RMAN > CONFIGURE DEVICE TYPE DISK PARALLELISM 2 backup type to backupset
Duplex backup:
When RMAN creates a backup set, it can make multiple identical copies of the backup set at the same time, which can improve the reliability of the backup. If one of the copies is corrupted, RMAN can also use the other copies to complete the database repair operation.
You cannot duplex the backup set to the fast recovery area. Rman can make up to four copies of the backup set at the same time. Each backup slice in the original backup set will be copied, and each copy has a unique copy number. Duplex backups apply only to backup sets, not to mirrored copies.
RMAN > Configure archive | datafile backup copies for device type disk | sbt clear | to n
The difference between an obsolete backup and an expired backup:
Obsolete backup:
Backups that have met the RMAN backup strategy and are no longer needed are outdated backups.
Report obsolete
Delete obsolete
Expired backup:
When DBA manually deletes the backup file or archive log on disk, because the backup information and archive information of RMAN are recorded in the control file, if deleted manually, the control file is not known.
You need to let the control file recognize that the file has been deleted.
For example, manually delete archive log files on disk
If there is no cross-check, RMAN will report an error.
Crosscheck archivelog all cross-check
Delete expired archivelog all deletes expired records
RMAN is differentiated by backup type:
Backup set backup: by default, backup files generated by backup sets can only be restored using the RMAN tool
Backup as compressed backupset database compressed backup set
Mirror copy backup: similar to the copy command cp on the operating system, the data file is copied to another location. The image copy backup can be restored directly using the operating system command cp.
Backup as copy database
The concept of backup set and backup slice:
Backup set: logical concept, is a collection of backup files, a backup set contains multiple backup slices.
Backup film: physical concepts, physical documents
RMAN is differentiated by backup mode:
Full backup:
Back up only all blocks needed to rebuild the data file (after a failure event occurs)
The backup film will be much smaller than the data file.
Backup as backupset full database
Level 0 incremental backup:
Backup as backupset incrememtal level=0 database
The difference between a level 0 incremental backup and a full backup:
Level 0 full backups can use hierarchical incremental backups.
Full backups cannot use hierarchical incremental backups.
Hierarchical incremental backup:
(1) level 1 differential backup
Only blocks that have been modified since the last level 1 or level 0 backup are backed up.
Backup as backupset incrememtal level=1 database
(2) level 1 cumulative backup
Only blocks that have been modified since the last level 0 backup are backed up.
Backup as backupset incrememtal level=1 cumulative database
The level 0 backup is partially completed in restore.
Level 1 backup is partially completed in recover
Incremental update backup:
Incremental update backup is an efficient way to achieve mirror copy backup.
Create a mirrored copy of the data file with RMAN, and then create an incremental backup with RMAN
(create only block backups that have changed since the last backup) and apply the incremental backup to the mirrored copy (instead of creating a new mirrored copy).
Steps:
1. Creates a full mirror copy backup of the data file with the specified label.
two。 Establish a level 1 differential incremental backup of the data file using the same label as the copy of the basic data file at a specified time (such as every day)
3. Apply the incremental backup established in 2 to the latest backup with the same label.
Block modification tracking function:
To speed up the efficiency of incremental backup, RMAN will track the changed data blocks by itself and find the modified data blocks after the last backup through the block tracking files. When performing incremental backups, there is no need to scan all the data blocks, only the block tracking files can be scanned, and the changed data blocks can be directly located and backed up.
RMAN backup and restore operations:
Backup and recovery of parameter files
(static parameter files can only be backed up using cp)
Backup:
RMAN > backup spfile
View backup information:
RMAN > list backup of spfile
Restore:
-when restoring parameter files, RMAN will start a pseudo instance (dummy) to restore parameter files because the database instance is not started.
RMAN > startup nomount
RMAN > restore spfile from'/ path/to/backupspfile'
-since the database is not in mount state at this time, RMAN cannot view the backup information recorded in the control file and cannot automatically search for backup information of spfile, so it is necessary to specify the absolute path of the backed up spfile file.
RMAN > shutdown abort
-disable pseudo instances
Control file backup and recovery
Backup:
RMAN > backup current controlfile
View:
RMAN > list backup of controlfile
Restore:
RMAN > restore controlfile from'/ u01/app/oracle/fast_recovery_area/xxx
Restoring the control file also requires explicitly specifying the absolute path of the backup control file.
Note:
Alter database open resetlogs
When to use the resetlogs statement?
1. When the recovery is not complete
2. When restoring with backup control files
3. When DBA manually uses trace files to create control files
Resetlogs:
If the current online redo logs are accessible, archive them, then delete the contents of the online redo logs, and reset the log sequence number to 1.
For example, when the database is opened with the resetlogs option, the current online redo log sequence numbers are 1000 and 1001, then the database will archive logs 1000 and 1001
Finally, reset the online redo log to sequences 1 and 2.
Backup of data files
There are three levels:
(1) backup of tablespace-level data files
(2) specify data file backup
(3) full database backup
Tablespace backup and recovery:
Backup
RMAN > backup tablespace users
RMAN > backup tablespace users,example
View:
RMAN > list backup of tablespace users
Restore:
RMAN > restore tablespace users
RMAN > recover tablespace users
Specify data file backup and restore:
Backup:
RMAN > backup datafile 1
RMAN > bacup datafile 1 Pol 2
View:
RMAN > list backup of datafile 1 Pol 2
Restore:
RMAN > restore datafile 1
RMAN > recover datafile 1
Full library backup and recovery:
Backup:
RMAN > backup database
Compressed backup set mode
RMAN > backup as compressed backupset database
View
RMAN > list backup
Restore:
RMAN > restore database
RMAN > recover database
Archive log backup and recovery:
Backup:
Archive logs are recognized by RMAN by default
RMAN > backup archivelog all
-when using the backup archivelog all command for a backup, RMAN attempts to make a log switch during the backup.
RMAN > backup archivelog all delete input
Back up archive logs and delete archive logs
RMAN > backup archivelog from scn 1804209
-specify the starting point for backup archive logs
The process of using backup xxx plus archivelog to back up archived redo logs:
1. Execute the alter system archivelog current statement to archive the current redo
two。 Execute the backup archivelog all command to back up all archived redo log files
3. Execute the backup command to back up the specified data files, etc.
4. Execute alter system archive log current again to archive the current redo
5. Back up the newly generated archive redo log files that have not yet been backed up during the backup.
View:
View archive log backups:
RMAN > list backup of archivelog all
View all current archive log files:
RMAN > list archivelog all
RMAN > list copy of archivelog all
Restore:
RMAN > restore archivelog all
RMAN > restore archivelog from scn 1804209; specify recovery range
Restore the archive log files to the specified location:
Run
{
Set archivelog destination to 'xxxx'
Restore archivelog all
}
Incomplete recovery:
RMAN > restore database
RMAN > recover database until scn 1671928
Restore to the specified SCN number
RMAN > alter database open resetlogs
RMAN Management and maintenance:
Crosscheck-verify the consistency between backup files and backup metadata information
RMAN > crosscheck backup;-- verify all backups
RMAN > delete expired backup;-- deleting expired backups
RMAN > crosscheck archivelog all;-- verify all archive logs
Lost backup or archive logs are identified as expired
RMAN > delete expired archivelog all;-deletes all archive logs with expired statu
Catalog-registers backup file information with the control file
RMAN > catalog datafilecopy'/ u01GUBULAGULAR BMR01.dbf'
RMAN > catalog start with'/ u01amp App Backup`
-register all files under a path to the control file
Report-report information
RMAN > report schema
-View the backup data of the current target library
RMAN > report obsolete
-View outdated backup
RMAN > report need backup
-check which files do not meet the backup retention policy
RMAN > report need backup days 7 database
-displays data files that take more than 7 days to archive logs to recover
RMAN > report need backup incremental 3
Displays files that need to be restored with more than 3 incremental backups applied
RMAN > report need backup redundancy 3
Displays the objects that need to be backed up to meet the redundancy retention policy (3 backups).
RMAN > report unrecoverable
Reports data files affected by unrecoverable operations.
(database files need to be backed up due to non-logging operations (nologging, such as insert operations in direct paths), that is, all unrecoverable data files are listed. )
List-list command:
RMAN > list backup
-View all backups
RMAN > list archivelog all
-View archive log
RMAN > list backup of archivelog all
-View the archive log status of all backups
RMAN > list backupset
-View backup set
RMAN > list backup of tablespace tbs_bmr
-View the specified type of backup
RMAN > list copy
-View mirrored copies of data files and control files, as well as archive logs
Delete-delete command:
RMAN > delete archivelog all
-Delete archive log
(if you configure an archive log deletion policy, only archive logs that meet the archive log deletion policy can be deleted.)
RMAN > delete backup
-Delete all backups
RMAN > delete obsolete
-Delete obsolete backup
(backups that meet backup policies but are no longer needed)
RMAN > delete backupset 55
-Delete the specified backup set
RMAN > delete backup
-Delete all backups
RMAN > delete backuppiece 55
-Delete the backup film
RMAN > delete expired backup
-Delete an expired backup
(crosscheck cross-checks expired backups)
RMAN > delete expired archivelog all
-Delete archive logs with expired statu
(crosscheck cross-checks expired archive logs)
RMAN > backup xxx delete input
(command to back up the file to disk first, and then delete the backed-up source file)
RMAN > delete noprompt obsolete
You can set the delete operation without prompting for information. Use when scripting
Advanced operations for backup:
Limit the number of files in the backup set
Filesperset defaults to 64
When the number of files to be backed up exceeds the value set by filesperset, RMAN splits the backed up files into multiple backup sets.
Assume that filesperset uses the default value:
RMAN > backup as backupset (datafile 3, 4, 4, 5, 6, 7) (datafile 8, 9)
3, 4, 4, 5, 6, 7, and save to a backup set.
8pr 9 is stored in a backup set
Multi-segment backup:
Section
Example: assuming that the users tablespace has only one 900MB data file and 3 SBT channels are configured, and the SBT device parallel parameter is set to 3, the data file in the tablespace can be divided into file areas:
RMAN > backup section size 300m tablespace users
Each of the three SBT channels backs up the 300m file area in the data file of the users tablespace.
Backup optimization skips the specified file:
Skip readonly skips read-only
Skip offline skips offline files
Skip inaccessible skips inaccessible files
Manually update the database status of backups and replicas:
Change
When the backup cannot be found or has been migrated, run the change xxx unavailable command
RMAN files that do not use unavailable state in restore or recover commands
If you find the missing file later, you can use change. The available command updates its status to available again.
Backup options and optimizations for RMAN restore:
1. Backup selection
RMAN takes precedence over the most recent available backups.
If the backup set and the mirrored copy are at the same point in time, RMAN takes precedence over the mirrored copy. Because RMAN is faster to restore from a mirror copy than from a backup set.
The Restore command of RMAN searches for backups on all device types on which the channel is configured.
two。 Verify database files and backups:
Validation refers to checking whether the database file has bad blocks or whether the backup set can be used for restore.
Validate, backup validate and restore... Validate
Validate:
Use the validate command to manually check for physical or logical corruption and missing data files in database files, or to determine whether backup sets are available for restore.
Verify with the validate backupset command when it is suspected that one or more backup slices in the backup set are missing or damaged. This command checks each block in the backup set to ensure that the backup can be restored.
RMAN > validate database include current controlfile plus archivelog
If RMAN detects a bad block, it will report to the
The v$database_block_corruption view adds relevant information.
Backup validate:
RMAN reads the entire file to be backed up as if it were a real backup, but RMAN does not actually produce any backup sets or mirror copies
Restore... Validate:
The validate option of the restore command is to let RMAN choose the backup set to check.
Just read the backup without affecting the use of the data file
Other testing measures:
Recover... Test: experimental repair.
Fix the simulation and apply the rewrite log in the same way as the normal repair, but it does not write its changes to disk and roll back its changes after the experiment is complete.
The experimental repair is only carried out in memory.
Preview the backups to be used in the restore:
1.restore... Preview
You can display a detailed list of each backup to be used in the restore operation, as well as the target SCN to repair after the restore operation is complete.
Just access the database to query the metadata to make sure they can be restored, and do not actually read the backup files
2.restore... Validate header
In addition to listing the files required for restore and repair, this command validates the backup file header to determine whether the files in the disk or media management directory are consistent with the metadata in the RMAN database.
Archive redo logs required to restore the repair:
When RMAN performs a repair operation, it automatically restores the archive redo log files from the backup as needed.
If you want to save the time required to restore these files during the recover command, you can restore the archive redo logs manually.
If the archive redo log is lost during disaster recovery, the repair command automatically repairs the database to the last available archive redo log with the until available redo option, which is useful only when repairing the entire database.
Cannot be used in repairing database files and tablespaces.
If you want to restore some data files to a new location:
Rename data files using set newname
Run
{
Set newname for datafile 2 to 'xxx'
Set newname for datafile 3 to 'xxx'
Set newname for datafile 4 to 'xxx'
Restore database
Switch datafile all
Recover database
}
If RMAN restores the archive log to the quick recovery area during repair
The archive logs will be deleted automatically after they are applied to the data file.
Can be used
RMAN > recover database delete archivelog
Delete restored archive logs from disk that are no longer needed for repair.
Switch to full restore of the mirrored replica:
Suppose the database lost data file 5, to switch to a copy of the data file and repair:
RMAN > alter database datafile 5 offline
RMAN > switch datafile 5 to copy
RMAN > recover datafile 5
RMAN automatically restores archived logs and incremental backups and automatically deletes them after the application is completed
RMAN > alter database datafile 5 online
All data files are corrupted, but there are mirrored copies of all data files:
RMAN > switch database to copy
RMAN > recover database
Block Media repair:
Use recover... The block command repairs the specified block of the data file.
Block media recovery keeps the affected data files online and only restores and repairs damaged blocks. (only the actual recovered blocks are not available during the restore)
Block-level data loss is usually caused by intermittent random IO errors, which do not cause large amounts of data loss and memory information corruption.
RMAN > recover datafile 8 block 13
RMAN Advanced recovery Technology:
1.
The process type of restoring a database in non-archived mode and recovering a database in archived mode.
The main difference between the two is that only consistent backups can be used to restore databases in non-archive mode.
Second, because there are no archived redo logs in non-archived databases, media recovery cannot be carried out.
When repairing a non-archive mode database, specify the noredo selection in the recover command to indicate that RMAN will not attempt to apply archive redo logs. Otherwise, RMAN returns an error.
two
After repairing the database with backup control files, regardless of whether the log is available or not
You always need to open the database with the open resetlogs option.
When performing recover database
If redo is available, RMAN can find them and apply these logs.
If redo is not available, you need the until clause to specify the target time, SCN, or log sequence number for the repair.
Otherwise, RMAN-7054 appears.
Using the set until operation in the run block fixes the limit to the end of the archive redo log.
If you do not use the set until operation to restrict the execution of recover database to read the archive log, it will look for the archive log file until the next archive log file cannot be found, and report an error, which does not indicate a problem. Then check whether the header of the data file is consistent with the SCN recorded in the control file, and if so, directly open resetlogs.
If the last created archive redo log has sequence number N, then specify until sequence sequence 1 so that RMAN stops when applied to log sequence number N.
If you use the restore catalog database and the database name is not unique in the recovery directory, you must execute the SET DBID command before restoring the control file.
For example:
-set dbid 123456
Run {
Set newname for datafile 1 to 'xxxx'
Set newname for datafile 2 to 'xxxx'
Set newname for datafile 3 to 'xxxx'
Allocate channel t1 device type disk
Restore controlfile from autobackup
Alter database mount
Set until sequence 124 thread 1
Restore database
Switch datafile all
Recover database
}
RMAN > alter database open resetlogs
View DBID:
The DBID of the database is recorded on the file name of the control file for automatic backup
DBID is displayed when RMAN connects
Select dbid from v$database
Data dictionary containing RMAN backup information:
RMAN backup Job
V $RMAN_BACKUP_JOB_DETAILS
Online data file status in backup mode (hot backup)
V $BACKUP
Archive log backup
V $backup_archivelog_details
Control file backup
V $backup_controlfiles_details
Control file and data file copy
V $backup_copy_details
-Control files and data files
V $backup_datafile
V $backup_datafile_details
Backed up files
V $backup_files
Backup film file
V $backup_piece
V $backup_piece_details
Backup set
V $backup_set
V $backup_set_details
-
Copyright notice: this article is the original article of CSDN blogger "people do not forget their roots", in accordance with the CC 4.0BY-SA copyright agreement, reprint please attach the original source link and this statement.
Original link: https://blog.csdn.net/baoyuhang0/article/details/106129267
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.