Oracle RMAN 11g Backup and Recovery- P10

50 1.1K 4
Oracle RMAN 11g Backup and Recovery- P10

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

418 Part III: Using RMAN Effectively Now, catalog the backup in rman rman target sys/robert catalog datafilecopy 'd:\backup\recover\users01.dbf.backup'; Replace arc001.log with the list of archive logs you generated earlier catalog archivelog 'd:\backup\recover\arc001.log'; Now catalog the control file catalog controlfilecopy 'd:\backup\recover.ctl'; The catalog command allows you to enter new backup set–related information into the control file or recovery catalog RMAN overwrites any pre-existing catalog information that conflicts with the information being cataloged This command can be handy if you need to move the location of your backup set pieces In this example, we have moved all our backup set pieces to a new directory We use the catalog command to load the correct directory location for each of the moved pieces in the control file: RMAN> catalog backuppiece '/opt/oracle/oracle-10.0.0/dbs/backup'; You can also use the catalog command with the start with option, which allows you to define the directory that contains the RMAN backup set pieces to be cataloged RMAN will then catalog all backup set pieces in that directory Here is an example of using the catalog command in this way: RMAN> catalog start with '/u01/oracle/RMAN/mydb'; Once you press ENTER, this command prompts you with a list of files to catalog and asks if you wish to catalog the files listed If you respond in the affirmative, RMAN catalogs all the backup set pieces listed (which will be contained in the /u01/oracle/RMAN/mydb directory) This command also allows you to catalog several like-named backup set pieces For example, if you want to catalog several backup set pieces that start with the name “backup” (e.g., backupset01, backupset02, and so forth), then you could issue the following command: RMAN> catalog start with '/u01/oracle/RMAN/mydb/backup'; When you use the catalog start with command, it is indiscriminate about which files it tries to catalog; it will try to catalog everything that matches the argument list However, as the catalog process proceeds, files that are not backup set pieces will fail the catalog process and an error will occur Files that are backup set pieces will be cataloged successfully, in spite of other errors RMAN Stored Scripts If you find that you are often doing the same RMAN operations over and over, then you would probably like to be able to store those operations somewhere and execute them when needed Of course, you could create a command file, which is just a text file physically located on disk somewhere, with the RMAN commands, and then execute the command file from the RMAN command-line interface using the cmdfile parameter, as shown in this example: rman target robert/password cmdfile run backup.cmd Or, you can run a command file from within RMAN itself, using the @ command: @@run backup.cmd Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Chapter 16: Maintaining RMAN 419 RMAN offers another option, which is to store scripts in the recovery catalog As you might guess, this requires that you use a recovery catalog, so if you are not using one, you will not be able to store RMAN scripts This section shows you how to store scripts in the recovery catalog and how to manage those scripts Creating Stored Scripts To store a script in the recovery catalog, you use the create script RMAN command Each stored script is assigned a name when you create it You can create scripts that backups, recoveries, and maintenance of your databases To create a script, you must be connected to the recovery catalog Here is an example of using the create script command to create a backup script RMAN also allows you to store comments related to your stored scripts by using the comment parameter: create script my backup script comment 'This script backs up the database' { backup database plus archivelog;} Oracle Database 11g supports the use of substitution variables Each substitution variable is denoted with an ampersand and a number that makes each variable unique For example, you could rewrite this script as follows: create script my backup script comment 'This script backs up the database' { backup database tag '&1' plus archivelog;} When you execute this command, RMAN will prompt you for initial values for the substitution variables Querying the Recovery Catalog for Stored Script Information You can use the recovery catalog views to determine the name of scripts stored in the recovery catalog by querying the RC_STORED_SCRIPT view You can see the contents of a given script by querying the RC_STORED_SCRIPT_LINE view Changing Stored Scripts You use the replace script command to replace stored scripts in the recovery catalog Here is an example of using the replace script command Note that we also add a comment to the script replace script my backup script comment 'This script backs up the database' { backup database plus archivelog delete input;} Deleting Stored Scripts To drop a script, you use the delete script command You must be connected to the recovery catalog to successfully drop a stored script Here is an example of using the delete script command: delete script my backup script; Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 420 Part III: Using RMAN Effectively Using Stored Scripts Now that you have created some stored scripts, you probably want to use them This is what the execute script command is for Simply connect to the recovery catalog and use the execute script command within the confines of a run block, as shown in this example: run {execute script my backup script;} If you are using substitution variables, you can use the using parameter to include the values of those parameters in the execute script command, as seen in this example: Run {execute script my backup script using TEST BACKUP;} Printing Stored Scripts If you want to print a copy of your stored script, you can use the print script command Connect to the recovery catalog, and run the print script command, as shown in this example: RMAN> print script my backup script; printing stored script: my backup script { backup database plus archivelog;} You can also use the RC_STORED_SCRIPT_LINE recovery catalog view to display the contents of a stored script, as shown in this example: select script name, text from rc stored script line order by script name, line; SCRIPT NAME TEXT -my backup script { backup database plus archivelog;} RMAN Workshop: Using RMAN Stored Scripts Workshop Notes This workshop expects that you have an operational Oracle database (called recover) and that you are also using a separate Oracle database to store the recovery catalog in (called catalog) Step Connect to the target database and to the recovery catalog: rman target rman account/rman password catalog rcat user/rcat password@catalog Step Create a stored script to back up the target database: RMAN> create script my backup script 2> {backup database plus archivelog;} created script my backup script Step Print the stored script: RMAN> print script my backup script; printing stored script: my backup script {backup database plus archivelog;} Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Chapter 16: Maintaining RMAN 421 Step Execute the stored script to back up your database: RMAN> run {execute script my backup script;} Step Delete the stored script: RMAN> delete script my backup script; When You Just Can’t Take It Anymore If you are sick and tired of your database and you just can’t take it anymore, RMAN offers the perfect response, the drop database command If only terrorists were as easy to get rid of Simply put the database in restricted session mode, connect to the target database with RMAN, issue the drop database command, and watch your database quietly go away You can add the including backups parameter, and all RMAN-related backups will be removed, too When you issue this command, RMAN will confirm the action first and then proceed to remove the database If you wish to not be prompted, you can use the noprompt parameter Here is an example of the use of the drop database command: SQL> alter system enable restricted session; SQL> quit; log into RMAN RMAN>drop database including backups; Summary In this chapter, we discussed the various maintenance operations that RMAN may require We discussed the crosscheck command and validating RMAN backups, both very important operations We also talked about retention policies and how RMAN uses them to control how long your backups will remain available to you for recovery purposes We also talked about the change and delete commands and how they can be used to modify the status of RMAN records in the control file or recovery catalog We also covered adding backups to the control file or recovery catalog Finally, we discussed maintenance of the recovery catalog and the use of stored scripts for RMAN operations Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark This page intentionally left blank Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark CHAPTER 17 Monitoring and Reporting on RMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 424 Part III: Using RMAN Effectively ecause everyone wants to know for sure that their databases have been backed up and are currently recoverable, RMAN comes with some good reporting tools This chapter covers RMAN reporting in some depth First, we look at the RMAN list command, followed by the RMAN report command Each of these commands provides facilities for in-depth analysis of the database that you are using RMAN to back up and its backups These commands are the primary ways of extracting information from RMAN You will find that lists and reports come in handy not only during recovery, but also when you want to see how RMAN is configured and when you need to perform other administrative tasks (such as determining if a tablespace has been backed up) B The RMAN list Command The RMAN list command is a method of querying either the database control file or the recovery catalog for historical information on backups Lists provide an array of information, from lists of database incarnations, to lists of backup sets and archive log backups The bottom line is that if you want to know whether the database was backed up and when, then you want to generate a list The format of lists initially tends to appear not very reader friendly Once you have looked at a few lists, though, they seem a little easier to read So, let’s look at the list commands and how they can be interpreted Listing Incarnations The list incarnation command provides you a list of each database incarnation for the target database This list can be used to recover your database to a point in time before your last resetlogs command was issued, if this is required (refer to Chapter 14 for more details on this operation) Here is an example of the list incarnation command output: RMAN> list incarnation of database; using target database control file instead of recovery catalog List of Database Incarnations DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time - - - -1 ROB1 1854903786 PARENT 07-SEP-09 2 ROB1 1854903786 CURRENT 635384 08-SEP-09 In this listing, we find that our database has had two different incarnations, with each incarnation represented in each row of the report Each individual incarnation has its own key (Inc Key), which we would use if we wanted to reset the database incarnation (refer to Chapter 14) We also get our database name and ID in this report The STATUS column displays the status of the incarnation listed It indicates whether the incarnation is an older incarnation (PARENT), the current incarnation, or, if a recovery past resetlogs has occurred, an orphan incarnation Finally, the Reset SCN and Reset Time columns basically indicate when the database incarnation was created (which is why the Reset SCN for the first entry is 1) This column helps support recovery through resetlogs and also helps support easier recovery to a previous incarnation An important point to note is that output generated with a recovery catalog and output generated without a recovery catalog generally look somewhat different For example, this is the output of the list incarnation command while attached to a recovery catalog: Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Chapter 17: RMAN> list incarnation of database; List of Database Incarnations DB Key Inc Key DB Name DB ID - - -2 18 ROB1 1854903786 ROB1 1854903786 Monitoring and Reporting on RMAN 425 STATUS Reset SCN Reset Time - -PARENT 07-SEP-09 CURRENT 635384 08-SEP-09 Note in this example that both the DB keys and the incarnation keys are different from those reported when using the control file This leads to an important point: Many reports have keys that identify specific items in the reports You will use these keys in other RMAN commands (such as in the reset database command) Since the values of the keys change depending on whether you are connected to the recovery catalog, you need to be careful about determining which keys you need Listing Backups The list command comes with a number of different options that allow you to report on the status of database backups and copies In this section, we are going to look at several of these reports Summarizing Available Backups Let’s first look at a few ways of getting summary backup information The list command provides a couple of options The first option is the list backup summary report: RMAN> list backup summary; List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag 60 61 62 63 67 68 70 176 207 421 433 B B B B B B B B B B B A A F A A F F F F F F A A A A A A A A A A A DISK DISK DISK DISK DISK DISK DISK DISK DISK DISK DISK 08 08 08 08 08 08 08 08 08 08 08 SEP SEP SEP SEP SEP SEP SEP SEP SEP SEP SEP 09 09 09 09 09 09 09 09 09 09 09 1 1 1 1 1 2 2 1 1 1 YES NO NO NO NO NO NO NO NO NO NO TAG20090908T025311 TAG20090908T025326 TAG20090908T025328 TAG20090908T025355 TAG20090908T032531 TAG20090908T032815 TAG20090908T032850 TAG20090908T040309 TAG20090908T040315 TAG20090908T051140 TAG20090908T051144 This report provides us with some nice summary information The backup set key is listed in the Key column The TY (type) and the LV (level) columns indicate the type of backup listed (B = backup, F = full, A = archive log, and and = incremental backups) The S column indicates the status of the backup (AVAILABLE, UNAVAILABLE, or EXPIRED) The Device Type column lets us know whether the backup is a tape or disk backup We also have columns for the date of the backup (Completion Time), the number of pieces (#Pieces) or copies (#Copies) that the backup set consists of, if the backup was compressed, and any tag that was assigned to the backup set (Tag) Most of the list commands will accept the summary parameter at the end For example: list backup of database summary; list expired backup of archivelog all summary; list backup of tablespace users summary; Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 426 Part III: Using RMAN Effectively Listing Backups by Datafile Another way to summarize backups is to use the list backup by file command to list each backup set and backup set piece Here is an example of this report (we have removed some output to save a few trees): RMAN> list backup by file; List of Datafile Backups ======================== File Key TY LV S Ckp SCN 62 421 176 68 B B B B F F F F A A A A #Pieces #Copies Compressed Tag 08 08 08 08 1 1 635676 644956 642222 637442 Ckp Time SEP SEP SEP SEP 09 09 09 09 1 NO NO NO NO TAG20090908T025328 TAG20090908T051140 TAG20090908T040309 TAG20090908T032815 List of Archived Log Backups ============================ Thrd Seq Low SCN Low Time BS Key S #Pieces #Copies Compressed Tag 1 1 1 60 61 63 67 67 67 67 A A A A A A A 10 635574 635642 635668 636872 637317 637320 637324 08 08 08 08 08 08 08 SEP SEP SEP SEP SEP SEP SEP 09 09 09 09 09 09 09 1 1 1 2 2 2 YES NO NO NO NO NO NO TAG20090908T025311 TAG20090908T025326 TAG20090908T025355 TAG20090908T032531 TAG20090908T032531 TAG20090908T032531 TAG20090908T032531 List of Control File Backups ============================ CF Ckp SCN Ckp Time 644990 642268 637490 BS Key 08 SEP 09 433 08 SEP 09 207 08 SEP 09 70 S #Pieces #Copies Compressed Tag A A A 1 1 NO NO NO TAG20090908T051144 TAG20090908T040315 TAG20090908T032850 List of SPFILE Backups ====================== Modification Time BS Key S #Pieces #Copies Compressed Tag 08 SEP 09 08 SEP 09 08 SEP 09 A A A 433 207 70 1 NO NO NO TAG20090908T051144 TAG20090908T040315 TAG20090908T032850 This report summarizes each backup file that has been created by the type of backup (datafile backup, archived log backup, control file backup, and SPFILE backup) and then by datafile for the datafile backups In this report, we get the date of the backup and the specific keys associated with the backup file Depending on the type of backup, we get information that pertains to that type of backup Additional Backup Information If you want as much information reported on your RMAN backups as you can get, then the list backup command is for you It provides detailed information on the backups that you have taken, including backup sets, archived redo log backups, and control file/SPFILE backups Let’s look at an example of the results of the execution of the list backup command: Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark Chapter 17: Monitoring and Reporting on RMAN 427 RMAN> list backup; BS Key Size Device Type Elapsed Time Completion Time 509 12.43M DISK 00:00:04 08 SEP 09 BP Key: 513 Status: AVAILABLE Compressed: YES Tag: TAG20090908T192844 Piece Name: /oracle/app/oracle/flash recovery area/ROB1/backupset/2009 09 08 /o1 mf annnn TAG20090908T192844 5bg16fk5 bkp List of Archived Logs in backup set 509 Thrd Seq Low SCN Low Time Next SCN Next Time 1 1 08 08 08 08 08 10 11 12 636872 637317 637324 637349 675660 08 08 08 08 08 SEP SEP SEP SEP SEP 09 09 09 09 09 637317 637320 637349 675660 676291 SEP SEP SEP SEP SEP 09 09 09 09 09 This first listing is an archive log backup The backup set key (BS Key) is 509 The size of the backup is listed, and we see that it went to disk, instead of to SBT The elapsed time of the backup is pretty short, at four seconds, and we see that it was completed on September Later in the report, we see that the backup is available and that it is a compressed backup We also find the backup set piece name, which tells us where the backup is physically located Finally, a list of archived redo logs appears These are the archived redo logs contained in this backup set Here is an example of the listing of the rest of this backup: BS Key Type LV Size Device Type Elapsed Time Completion Time 510 Full 243.36M DISK 00:01:16 08 SEP 09 BP Key: 514 Status: AVAILABLE Compressed: YES Tag: TAG20090908T192853 Piece Name: /oracle/app/oracle/flash recovery area/ROB1/backupset/2009 09 08 /o1 mf nnndf TAG20090908T192853 5bg16pwv bkp List of Datafiles in backup set 510 File LV Type Ckp SCN Ckp Time Name BS Key Full Full Full Full Size 676334 676334 676334 676334 08 08 08 08 SEP SEP SEP SEP 09 09 09 09 /ora01/oracle/rob1/rob1/system01.dbf /ora01/oracle/rob1/rob1/sysaux01.dbf /ora01/oracle/rob1/rob1/undotbs01.dbf /ora01/oracle/rob1/rob1/users01.dbf Device Type Elapsed Time Completion Time 536 783.00K DISK 00:00:01 08 SEP 09 BP Key: 541 Status: AVAILABLE Compressed: YES Tag: TAG20090908T193014 Piece Name: /oracle/app/oracle/flash recovery area/ROB1/backupset/2009 09 08 /o1 mf annnn TAG20090908T193014 5bg196xr bkp List of Archived Logs in backup set 536 Thrd Seq Low SCN Low Time Next SCN Next Time 08 SEP 09 13 676291 08 SEP 09 676364 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark ... summarizes each backup file that has been created by the type of backup (datafile backup, archived log backup, control file backup, and SPFILE backup) and then by datafile for the datafile backups In... command will display all expired backup sets With the list expired backup command, you can also get a list of expired tablespace and datafile backups and lists of expired archive log backups and. .. your RMAN backups as you can get, then the list backup command is for you It provides detailed information on the backups that you have taken, including backup sets, archived redo log backups, and

Ngày đăng: 20/10/2013, 15:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan