oracle backup recovery student guide
TRANSCRIPT
-
7/25/2019 Oracle Backup Recovery Student Guide
1/125
1
Oracle Database 10g:Backup and Recovery
Volume I Student Guide
D22057GC10Production 1.0June 2006D46524
-
7/25/2019 Oracle Backup Recovery Student Guide
2/125
2
Authors
Donna Keesling
Maria Billings
Technical Contributors
and Reviewers
Christopher Andrews
Tammy Bednar
Tom Best
Harald van BreederodeMary Jane Bryksa
Marielle Canning
Tim ChienDonna Cooksey
Judy Ferstenberg
Gerlinde Frenzen
Joel GoodmanPete Jones
Isabelle Marchand
Sabiha Miri
Manish Pawar
Jim SpillerGeorge Stabler
Anthony Woodell
Editor
Daniel Milne
Graphic Designer
Satish Bettegowda
Publisher
Jobi Varghese
-
7/25/2019 Oracle Backup Recovery Student Guide
3/125
3
Copyright 2006, Oracle. All rights r eserved.Disclaimer
This document contains proprietary information and is protected by copyright andother intellectual property laws. You may copy and print this document solely for your
own use in an Oracle training course. The document may not be modified or altered inany way. Except where your use constitutes "fair use" under copyright law, you maynot use, share, download, upload, copy, print, display, perform, reproduce, publish,
license, post, transmit, or distribute this document in whole or in part without theexpress authorization of Oracle.The information contained in this document is subject to change without notice. If you
find any problems in the document, please report them in writing to: Oracle University,500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is notwarranted to be error-free.
Restricted Right s Notice
If this documentation is delivered to the United States Government or anyone usingthe documentation on behalf of the United States Government, the following notice isapplicable:
U.S. GOVERNMENT RIGHTSThe U.S. Governments rights to use, modify, reproduce, release, perform, display, ordisclose these training materials are restricted by the terms of the applicable Oracle
license agreement and/or the applicable U.S. Government contract.
Trademark Notice
Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of OracleCorporation and/or its affiliates. Other names may be trademarks of their respectiveowners.
-
7/25/2019 Oracle Backup Recovery Student Guide
4/125
4
Practice for Lesson 1
There are no practices for Lesson 1.
-
7/25/2019 Oracle Backup Recovery Student Guide
5/125
5
Practice for Lesson 2
In this practice, you configure your database for recoverability.
-
7/25/2019 Oracle Backup Recovery Student Guide
6/125
6
Practice 2-1: Configure Your Database
1) Use Enterprise Manager to configure your database in ARCHI VELOG mode.
2) Use Enterprise Manager to verify that the Flash Recovery Area has been configured for yourdatabase and increase the Flash Recovery Area size to 3 GB.
3) Set Preferred Credentials in Enterprise Manager.
4) Use Recovery Manager (RMAN) to connect to your target database. Make note of thedatabaseidentifier (DBID) of your database.Database Identifier: ____________________________ Make
note of the database identifier (DBID) of your database.
5) Use the RMAN SHOW ALL command to view the configuration settings in yourdatabase andthen exit from your RMAN session.
-
7/25/2019 Oracle Backup Recovery Student Guide
7/125
7
Practice for Lesson 3
In this practice, you configure automatic backup of the control file. You also configure a
backup of your database using the Oracle-Suggested Backup Strategy feature inEnterprise Manager Database Control..
-
7/25/2019 Oracle Backup Recovery Student Guide
8/125
8
Practice 3-1: Use RMAN to Create and Manage Backups
1) Use Enterprise Manager Database Control to configure autobackup of the control file and theserver parameter file.
2) Use Enterprise Manager Database Control to configure backup optimization and enable block
change tracking. Specify / u01/ app/ or acl e/ or adat a/ or cl / chg_t r ack. f for thename of the blockchange tracking file.
3) Use Enterprise Manager Database Control to create a whole database backup using the Oracle-suggested backup strategy.
4) Use Enterprise Manager to view information about your backups.
5) Use RMAN to create a duplexed backup set of the EXAMPLE tablespace.
6) Use Enterprise Manager Database Control to perform a crosscheck of your backups.
-
7/25/2019 Oracle Backup Recovery Student Guide
9/125
9
Practice for Lesson 4
In this practice, you use RMAN to perform recovery.
-
7/25/2019 Oracle Backup Recovery Student Guide
10/125
10
Practice 4-1: Use RMAN to Recover a Datafile
In this practice, you use RMAN to recover a lost datafile. Notice how you are promptedby Enterprise Manager to recover the lost datafile.
1) Use SQL*Plus to query the HR. REGI ONS table. Make note of the number of rows in theHR. REGI ONS table.
2) At the operating system prompt, execute the l ab_04_01_02_01. sh script to simulate afailure in your database. This script deletes the EXAMPLE tablespace datafile.
3) Use SQL*Plus to query the HR. J OBS table.
4) Use Enterprise Manager to perform database recovery of the EXAMPLE tablespacedatafile.
5) Return to your SQL*Plus session and again attempt to query the HR. J OBS table.
-
7/25/2019 Oracle Backup Recovery Student Guide
11/125
11
Practice 4-2: Use the Flash Recovery Area to Quickly Recover aDatafile
In this practice, you recover a lost datafile by using the Flash Recovery Area for fast
recovery.
1) Use SQL*Plus to query the HR. REGI ONS table. Make note of the number of rows inthe HR. REGI ONS table.
2) At the operating system prompt, execute the l ab_04_02_02_01. sh script tosimulate a failure in your database. This script deletes the EXAMPLE tablespacedatafile.
3) Use SQL*Plus to query the HR. DEPARTMENTS table.
4) Use the RMAN SWI TCH TO COPY command to recover the datafile.
5) Query the HR. J OBS table.
6) Using Enterprise Manager Database Control, verify that the datafile being used forthe EXAMPLE tablespace is in the Flash Recovery Area.
7) Make a copy of the datafile in the original location and switch back to it.
8) Use Enterprise Manager Database Control to verify the file.
-
7/25/2019 Oracle Backup Recovery Student Guide
12/125
12
Practice 4-3: Recover Control Files
In this practice, you recover your control file using an autobackup.
1) Use SQL*Plus to view files information for the control files in your database. Query
V$CONTROLFI LE.
2) Simulate a failure in your environment by executing the l ab_04_03_02_01. sh script todelete all your control files.
3) You need some more information about your control files. Query
V$CONTROLFI LE_RECORD_SECTI ON to learn more about the contents of yourcontrol file.
4) You have lost all your control files and will need to recover them from the control fileautobackup. Use Recovery Manager to recover the control files.
-
7/25/2019 Oracle Backup Recovery Student Guide
13/125
13
Practice 4-4: Delete Obsolete Backups
1) Use Recovery Manager to view obsolete backups.
2) Use Enterprise Manager Database Control to delete obsolete backups.
3) You can also use RMAN to verify that your obsolete backups were deleted.
-
7/25/2019 Oracle Backup Recovery Student Guide
14/125
14
Practice for Lesson 5
In this practice, you use Oracle Flashback features to recover from errors in your database.
-
7/25/2019 Oracle Backup Recovery Student Guide
15/125
15
Practice 5-1: Enable Flashback Database
1) Use Enterprise Manager to enable Flashback Database.
2) Use the ALTER DATABASE command to enable supplemental logging.
-
7/25/2019 Oracle Backup Recovery Student Guide
16/125
16
Practice 5-2: Set Restore Points and Perform Flashback Table
Restore points are a way to bookmark database points in time. Set a restore point toremember a significant change so that you can quickly recover to that point in timewithout having to record an SCN or time.
1) You must enable row movement to use restore points. Use Enterprise Manager toenable row movement for the HR. LOCATI ONS table.
2) Create a normal restore point.
3) Use SQL*Plus to query the POSTAL_CODE column in the HR. LOCATI ONS table.
4) Execute the l ab_05_02_04_01. sql script to update the POSTAL_CODE columnin the HR. LOCATI ONS table so that all postal codes are set to 11111.
5) Execute the l ab_05_02_05_01. sql script to query the POSTAL_CODE column
in the HR. LOCATI ONS table again.
6) Restore the POSTAL_CODE column values using the restore point.
7) Return to your SQL*Plus session. Execute the l ab_05_02_07_01. sql script toquery the POSTAL_CODE column in HR. LOCATI ONS again to be sure the correct valueshave been restored.
-
7/25/2019 Oracle Backup Recovery Student Guide
17/125
17
Practice 5-3: Use Flashback Query and Flashback VersionsQuery
1. Execute the l ab_05_03_01_01. sql script to query the HR. LOCATI ONS table for locationID 1400.
2. Execute the l ab_05_03_02_01. sql script to update the POSTAL_CODE column in theHR. LOCATI ONS table, simulating user error.
3. Execute the l ab_05_03_03_01. sql script to query the POSTAL_CODE column inHR. LOCATI ONS and view the change.
4. Execute the l ab_05_03_04_01. sql script to update the POSTAL_CODE column in theHR. LOCATI ONS table, simulating user error.
5. Use Enterprise Manager to perform Flashback Versions Query to correct the user errors.
6. Return to your SQL*Plus session. Query the HR. LOCATI ONS table to confirm the Flashbackoperation.
-
7/25/2019 Oracle Backup Recovery Student Guide
18/125
18
Practice 5-4: Use Flashback Database
1) Use Enterprise Manager to verify that Flashback Database is enabled.
2) Use Enterprise Manager to create a Guaranteed Restore Point.
3) Execute the l ab_05_04_03_01. sql script to determine the number of rows inthe HR. J OB_HI STORY table. Record the number of rows: ___________
4) Execute the l ab_05_04_04_01. sql script to truncate the HR. J OB_HI STORYtable.
4) Execute the l ab_05_04_05_01. sql script to determine the number of rows inthe HR. J OB_HI STORY table.
5) Use Flashback Database to restore the HR. J OB_HI STORY table rows.
6) Return to your SQL*Plus session. Execute the l ab_05_04_07_02. sql script to query theHR. J OB_HI STORY table again to be sure the data has been restored.
-
7/25/2019 Oracle Backup Recovery Student Guide
19/125
19
Practice for Lesson 6
In this practice, you create a duplicate database.
-
7/25/2019 Oracle Backup Recovery Student Guide
20/125
20
Practice 6-1: Create a Dupl icate Database
In this practice, you use RMAN to create a duplicate database on the same host as yourdatabase.
1) Create an Oracle password file for your auxiliary instance.
2) Use Oracle Net Manager to create an entry calledAUXDB in the t nsnames. orafile.
3) Create an initialization parameter file for the auxiliary instance.
4) Start the auxiliary instance in NOMOUNT mode using the i ni t AUX. or a file.
5) Create a server parameter file (SPFILE).
6) Verify that your target database (orc l database) is mounted or open.
7) Start RMAN with a connection to the target database (orcl ) and the auxiliaryinstance.
8) Create the duplicate database by executing the DUPLI CATE command.
9) Use SQL*Plus to log in to your AUX database and execute a query against theHR. REGI ONS table.
10)Now that you have completed the test recovery by creating a duplicate database, shutdown the aux instance.
11)Change your ORACLE_SI D to orc l in preparation for later practices.
-
7/25/2019 Oracle Backup Recovery Student Guide
21/125
21
Practice for Lesson 7
In this practice, you use tablespace point-in-time recovery to recover from unwanted changes to your
database.
-
7/25/2019 Oracle Backup Recovery Student Guide
22/125
22
Practice 7-1: Use Tablespace Point-in-time Recovery
1) Execute the l ab_07_01_01_01. sh script to export the HR schema.
2) Execute the l ab_07_01_02_02. sql script to create a new tablespace and a new
user in your database.
3) Execute the l ab_07_01_03_01. sh script to populate the new tablespace with acopy of the data from the HR schema.Note: The import should complete successfully. You will receive error messages
because the import excludes the COUNTRI ES, REGI ONS, and LOCATI ONS tables.These messages can be ignored.
4) Create a backup of your database using RMAN.
5) Record the current SCN: ____________
6) Record the current time.
7) Execute the l ab_07_01_07_01. sql script to query the HRTEST. EMPLOYEEStable and view information about employees in department 60.Make note of the highest salary that is displayed: ________
8) Execute the l ab_07_01_08_01. sql script to update the salaries for theemployees in department 60 and note the highest salary displayed.
Highest salary: _____________
9) You now want to perform TSPITR for the HRTEST tablespace to return it to the stateprior to the updates. Execute the l ab_07_01_09_01. sql script to determine
whether there are any dependencies that will prevent the TSPITR operation.
10)You can use Enterprise Manager Database Control or RMAN command line toperform tablespace point-in-time recovery.
11)Verify that the HRTEST tablespace is online.
12)Verify that the SALARY columns in HRTEST. EMPLOYEES for the employees indepartment 60 contain the correct values.
13)Execute the l ab_07_01_13_02. sql script to add a constraint to theHRTEST. DEPARTMENTS table.
14)Assume you need to perform TSPITR on the HRTEST tablespace again. Execute thel ab_07_01_14_02. sql query to determine whether there are any dependenciesoutside the recovery set.
15)If you wanted to complete the tablespace point-in-time recovery for the HRTEST tablespacenow, what would you need to do?
-
7/25/2019 Oracle Backup Recovery Student Guide
23/125
23
Note: You will not perform another tablespace point-in-recovery in this practice.
You would need to disable the DEPT_LOC_I D_FK constraint that was added to yourHRTEST. DEPARTMENTS table or you would need to add
-
7/25/2019 Oracle Backup Recovery Student Guide
24/125
24
Practice for Lesson 8
In this practice, you create a recovery catalog in your instructors database and register
your database in the recovery catalog.
-
7/25/2019 Oracle Backup Recovery Student Guide
25/125
25
Practice 8-1: Create the Recovery Catalog and Regis ter theDatabase
The tablespace for the recovery catalog and the recovery catalog owner have been created
in the instructor database. The tablespaces are named RCTS01 RCTS12. The users are
named RCUSER01 RCUSER12.
1) Connect to the recovery catalog database (instructors database) with the appropriaterecovery catalog owner name (if you are using PC01, connect as RCUSER01) usingRMAN. Create the recovery catalog in your assigned tablespace. (If you are using
PC01, your assigned tablespace is RCTS01.) The service name is RCDB.
2) Using RMAN, connect to your target database and the recovery catalog database.
3) Using RMAN, execute the command to resynchronize the control file and recovery catalog. Whathappens? Why?
4) Register the target database in the recovery catalog. You can use RMAN commandline orEnterprise Manager for this step.
5) Create an RMAN script named whol e_backup to make a whole database backup. Do notexecute the whole_backup script at this time.
6) Use the PRI NT command to query the recovery catalog and verify the creation of yourwhol e_backup script.
7) In preparation for later practices, use RMAN to unregister your database from therecovery catalog.
-
7/25/2019 Oracle Backup Recovery Student Guide
26/125
26
Practice for Lesson 9
In this practice, you monitor the progress of your RMAN backup jobs.
-
7/25/2019 Oracle Backup Recovery Student Guide
27/125
27
Practice 9-1: Use SQL to Monitor the Progress of RMANBackups
1) Invoke RMAN and delete all obsolete backups.
2) Open a second terminal window. Change to the l abs directory. Invoke SQL*Plusand connect as SYSDBA. You will use this second session to monitor a databasebackup.
3) Return to your first terminal window. In your RMAN session, begin a whole databasebackup.
4) Use your SQL*Plus session to monitor the progress of the whole database backup by
querying the V$SESSI ON_LONGOPS view. By using this view you can determinewhether the backup is progressing normally or hanging. If the backup is progressing
normally, theTI ME_REMAI NI NG column should be decreasing. Execute thel ab_09_01_04_01. sql script to query V$SESSI ON_LONGOPS.
-
7/25/2019 Oracle Backup Recovery Student Guide
28/125
28
Practice 9-2: Use Enterprise Manager to Monitor RMAN Jobs
You can easily monitor RMAN jobs in Enterprise Manager.
1) Start Enterprise Manager and log in as SYS/ ORACLE as SYSDBA.
2) Delete obsolete backups.
3) Start a whole database backup
-
7/25/2019 Oracle Backup Recovery Student Guide
29/125
29
Practice Solutions
-
7/25/2019 Oracle Backup Recovery Student Guide
30/125
30
Table of ContentsSolutions for Practice 2-1: Configure Your Database .................................................... 5Solutions for Practice 3-1: Use RMAN to Create and Manage Backups ..................... 10
Solutions for Practice 4-1: Use RMAN to Recover a Datafile ..................................... 17Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover a Datafile
...................................................................................................................................... 21Solutions for Practice 4-3: Recover Control Files ........................................................ 26
Solutions for Practice 4-4: Delete Obsolete Backups ................................................... 33Solutions for Practice 5-1: Enable Flashback Database ............................................... 36
Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table.............. 38Solutions for Practice 5-3: Use Flashback Query and Flashback Versions Query....... 46
Solutions for Practice 5-4: Use Flashback Database .................................................... 52Solutions for Practice 6-1: Create a Duplicate Database .............................................. 60
Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery............................ 74Solutions for Practice 8-1: Create the Recovery Catalog and Register the Database... 89
Solutions for Practice 9-1: Use SQL to Monitor the Progress of RMAN Backups...... 96
Solutions for Practice 9-2: Use Enterprise Manager to Monitor RMAN Jobs ............. 9
-
7/25/2019 Oracle Backup Recovery Student Guide
31/125
31
Practice Solutions for Lesson 1
There are no practices for Lesson 1.
-
7/25/2019 Oracle Backup Recovery Student Guide
32/125
32
Practice Solutions for Lesson 2
In this practice, you configure your database for recoverability.
-
7/25/2019 Oracle Backup Recovery Student Guide
33/125
33
Solutions for Practice 2-1: Conf igure Your Database
1) Use Enterprise Manager to configure your database in ARCHI VELOG mode.Answer:
1. Start the Web browser and enter ht tp : / / your host name: 1158/ em.
2. Enter SYS in the User Name field and or acl e in the Password field. SelectSYSDBA in the Connect As menu. Click Login.
3. Click I agree on the Oracle Database 10g Licensing Information page.
4. Select the Maintenance page.
5. Select Recovery Settings in the Backup/Recovery Settings section.
6. In the Media Recovery section, select ARCHIVELOG Mode and click Apply.
7. The Confirmation page is displayed. Click Yes to restart the database instance.
8. On the Restart Database: Specify Host and Target Database Credentials page. Inthe Host Credentials section, enter or acl e in the Username and Password fields.In the Database Credentials section, enter SYS in the Username field andor acl e in the Password field. Select Save as Preferred Credential. Click OK.
9. The Restart Database: Confirmation page is displayed. Click Yes to confirm the
restart of the database instance.
10. The Restart Database: Activity Information page is displayed. Wait a few minutes
and then click Refresh.
2) Use Enterprise Manager to verify that the Flash Recovery Area has been configured
for your database and increase the Flash Recovery Area size to 3 GB.Answer:
1. Select the Maintenance page.
2. Select Recovery Settings in the Backup/Recovery Settings section.
-
7/25/2019 Oracle Backup Recovery Student Guide
34/125
34
3. Scroll to the Flash Recovery Area and verify that the Flash Recovery Area is enabled.
4. Enter 3 in the Flash Recovery Area Size field and click Apply.
5. The Update Message is displayed. Click the Database instance link to return to theMaintenance page.
3) Set Preferred Credentials in Enterprise Manager.
Answer:
1. Select Preferences at the top of the Maintenance page.
2. Select Preferred Credentials on the left side of the page.
3. Click the Set Credentials icon for the database instance.
4. Supply the following values:
Normal Username: syst em
Normal Password: or acl eSYSDBA Username: sysSYSDBA Password: or acl eHost Username: or acl eHost Password: or acl e
5. Click Test. The Credentials successfully verified for orcl.oracle.com message is displayed. Ifyou have any errors, correct them and click Test again.
6. Click Apply to save the settings.
7. Click Database to return to the Database home page.
4) Use Recovery Manager (RMAN) to connect to your target database. Make note of the databaseidentifier (DBID) of your database.
Database Identifier: ____________________________
Answer:
-
7/25/2019 Oracle Backup Recovery Student Guide
35/125
35
1. Open a terminal window and log in as or acl e/or acl e.
2. Start RMAN and connect to the target database by entering the followingcommand at the operating system prompt: r man t ar get /
[ oracl e@edr sr 10p1 or acl e]$ r man t arget /
Recover y Manager : Rel ease 10. 2. 0. 1. 0 - Product i on on TueMar 7 12: 51: 53 2006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.connect ed t o t arget dat abase: ORCL ( DBI D=1090770270)
RMAN>
Make note of the database identifier (DBID) of your database.
3. Use the RMAN SHOW ALL command to view the configuration settings in your
database and then exit from your RMAN session.
Answer:
RMAN> show al l ;
usi ng t ar get dat abase cont r ol f i l e i nst ead of r ecover ycat al ogRMAN conf i gurat i on par amet er s ar e:CONFI GURE RETENTI ON POLI CY TO REDUNDANCY 1; # def aul tCONFI GURE BACKUP OPTI MI ZATI ON OFF; # def aul tCONFI GURE DEFAULT DEVI CE TYPE TO DI SK; # def aul t
CONFI GURE CONTROLFI LE AUTOBACKUP OFF; # def aul tCONFI GURE CONTROLFI LE AUTOBACKUP FORMAT FOR DEVI CE TYPEDI SK TO ' %F' ; # def aul tCONFI GURE CONTROLFI LE AUTOBACKUP FORMAT FOR DEVI CE TYPESBT_TAPE TO ' %F' ; # def tCONFI GURE DEVI CE TYPE DI SK PARALLELI SM 1 BACKUP TYPE TOBACKUPSET; # def aul tCONFI GURE DEVI CE TYPE SBT_TAPE PARALLELI SM 1 BACKUP TYPE
TO BACKUPSET; # def aul tCONFI GURE DATAFI LE BACKUP COPI ES FOR DEVI CE TYPE DI SK TO1; # def aul tCONFI GURE DATAFI LE BACKUP COPI ES FOR DEVI CE TYPE SBT_TAPE
TO 1; # def aul tCONFI GURE ARCHI VELOG BACKUP COPI ES FOR DEVI CE TYPE DI SK TO1; # def aul tCONFI GURE ARCHI VELOG BACKUP COPI ES FOR DEVI CE TYPESBT_TAPE TO 1; # def aul tCONFI GURE CHANNEL DEVI CE TYPE ' SBT_TAPE' FORMAT ' %U' ;CONFI GURE MAXSETSI ZE TO UNLI MI TED; # def aul tCONFI GURE ENCRYPTI ON FOR DATABASE OFF; # def aul t
-
7/25/2019 Oracle Backup Recovery Student Guide
36/125
36
CONFI GURE ENCRYPTI ON ALGORI THM ' AES128' ; # def aul tCONFI GURE ARCHI VELOG DELETI ON POLI CY TO NONE; # def aul tCONFI GURE SNAPSHOT CONTROLFI LE NAME TO' / u01/ app/ or acl e/ pr oduct / 10. 2. 0/ db_1/ dbst
RMAN> exi t
Recover y Manager compl et e.
-
7/25/2019 Oracle Backup Recovery Student Guide
37/125
37
Practice Solutions for Lesson 3
In this practice, you configure automatic backup of the control file. You also configure a
backup of your database using the Oracle-Suggested Backup Strategy feature inEnterprise Manager Database Control.
-
7/25/2019 Oracle Backup Recovery Student Guide
38/125
38
Solut ions for Practice 3-1: Use RMAN to Create and Manage Backups
1) Use Enterprise Manager Database Control to configure autobackup of the control fileand the server parameter file.
Answer:
1. Select Maintenance > High Availability > Backup/Recovery Settings > BackupSettings.
2. On the Backup Settings page, select the Policy tab.
3. In the Backup Policy section, select Automatically backup the control file andserver parameter file (SPFILE) with every backup and database structuralchange. Click OK.
4. You are returned to the Maintenance page.
2) Use Enterprise Manager Database Control to configure backup optimization and enable block changetracking. Specify / u01/ app/ or acl e/ or adat a/ or cl / chg_t r ack. f for the name of the
block change tracking file.Answer:
1. Select Maintenance > High Availability > Backup/Recovery Settings > Backup Settings.
2. On the Backup Settings page, select the Policy tab.
3. In the Backup Policy section, select Optimize the whole database backup by skipping unchangedfiles such as read-only and offline datafiles that have been backed up.
4. Select Enable block change tracking for faster incremental backups and entera. / u01/ app/ or acl e/ or adat a/ or cl / chg_t r ack. f in the Block Change
Tracking File field. Click OK.
-
7/25/2019 Oracle Backup Recovery Student Guide
39/125
-
7/25/2019 Oracle Backup Recovery Student Guide
40/125
40
5. On the Schedule Oracle-Suggested Backup: Schedule page, you can specify the time for yourbackups. Set the Time Zone field to correspond to your time zone.
6. Review the information on the Schedule Oracle-Suggested Backup: Review page.Click Submit Job.
7. The Status page is displayed indicating that the job has been submitted. Click View Jobto monitor the status of the backup job.
8. Click the Refresh button on your browser to refresh the Execution page. Click theBackup link to view the output log.
9. In the output log, you can see that RMAN has made a datafile copy backup ofeach datafile in your database.
-
7/25/2019 Oracle Backup Recovery Student Guide
41/125
41
10. Click the Database tab to return to the Database Home page.
4) Use Enterprise Manager to view information about your backups.Answer:
1. Select Maintenance > High Availability > Backup/Recovery > Backup Reports.
2. Click the link for the backup you took in Question 3 to view detailed information about thebackup.
3. Click the Database Instance link to return to the Maintenance page.
5) Use RMAN to create a duplexed backup set of the EXAMPLE tablespace.Answer:
1. Start RMAN and connect to the target database.
[ oracl e@edr sr 10p1 backup1] $ rman t arget /
Recover y Manager : Rel ease 10. 2. 0. 1. 0 - Product i on on WedMar 22 10: 38: 18 2006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.
connect ed t o t arget dat abase: ORCL ( DBI D=1090770270)
2. Create two backup set copies. One copy should be in the
-
7/25/2019 Oracle Backup Recovery Student Guide
42/125
42
/ home/ oracl e/ backup1 directory and one copy should be in the/ home/ oracl e/ backup2 directory.RMAN> @sol _03_01_05_02. r mnRMAN> backup devi ce t ype di sk2> copi es 23> t abl espace exampl e
4> f or mat ' / home/ oracl e/ backup1/ %U' ,' / home/ or acl e/ backup2/ %U' ;St ar t i ng backup at 22- MAR- 06usi ng channel ORA_DI SK_1channel ORA_DI SK_1: st ar t i ng f ul l dat af i l e backupsetchannel ORA_DI SK_1: speci f yi ng dat af i l e(s) i n backupseti nput dat af i l e f no=00005name=/ u01/ app/ or acl e/ oradata/ orcl / exampl e01. dbfchannel ORA_DI SK_1: st ar t i ng pi ece 1 at 22- MAR- 06channel ORA_DI SK_1: f i ni shed pi ece 1 at 22- MAR- 06 wi t h 2copi es and t ag TAG20063pi ece handl e=/ home/ oracl e/ backup1/ 0ehej ks7_1_1
comment =NONEpi ece handl e=/ home/ oracl e/ backup2/ 0ehej ks7_1_2comment =NONEchannel ORA_DI SK_1: backup set compl ete, el apsed t i me:00: 00: 15Fi ni shed backup at 22- MAR- 06
Star t i ng Cont r ol Fi l e and SPFI LE Aut obackup at 22- MAR- 06pi ecehandl e=/ u01/ app/ or acl e/ f l ash_r ecover y_area/ ORCL/ aut obackup/ 2006_03_22/ o1_EFi ni shed Cont r ol Fi l e and SPFI LE Aut obackup at 22- MAR- 06
RMAN> **end- of - f i l e**RMAN>
3. Use the RMAN LI ST BACKUP SUMMARY command to view a listing of the backup sets andpieces. The #Copi es column shows the duplexed backup set copies you made. Exit fromRMAN.
RMAN> @sol _03_01_05_03. r mnRMAN> l i st backup summar y;
usi ng t ar get dat abase cont r ol f i l e i nst ead of r ecover y cat al og
Li st of Backups===============Key TY LV S Devi ce Type Compl et i on Ti me #Pi eces#Copi es Compr essed Tag- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - -5 B F A DI SK 21- MAR- 06 1 1NO TAG200600
-
7/25/2019 Oracle Backup Recovery Student Guide
43/125
43
7 B F A DI SK 22- MAR- 06 1 1NO TAG2006078 B F A DI SK 22- MAR- 06 1 2NO TAG2006039 B F A DI SK 22- MAR- 06 1 1NO TAG200608
RMAN> **end- of - f i l e**RMAN> exi t
Recover y Manager compl et e
6) Use Enterprise Manager Database Control to perform a cross-check of your backups.Answer:
1. Select Maintenance > High Availability > Backup/Recovery > Manage CurrentBackups.
2. Click Crosscheck All.
3. Review the information on the Crosscheck All: Specify Job Parameters page andaccept the default values. Click Submit Job.
4. You receive the Job submission succeeded message. You can click View Job tomonitor the cross-check job. After it completes successfully, return to theDatabase Home page.
5. Log out of Enterprise Manager.
-
7/25/2019 Oracle Backup Recovery Student Guide
44/125
44
Practice Solutions for Lesson 4
In this practice, you use RMAN to perform recovery.
-
7/25/2019 Oracle Backup Recovery Student Guide
45/125
45
Solutions for Practice 4-1: Use RMAN to Recover a Datafile
In this practice, you use RMAN to recover a lost datafile. Notice how you are promptedby Enterprise Manager to recover the lost datafile.
1) Use SQL*Plus to query the HR. REGI ONS table. Make note of the number of rows in the
HR. REGI ONS table.Answer:
1. Open a terminal window and log in to SQL*Plus and connect as the HR user with HR as thepassword.
2. Query the HR. REGI ONS table and record the number of rows. Number of rows: ___________
[ or acl e@edr sr 10p1 or acl e] $ sql pl us hr / hr
SQL*Pl us: Rel ease 10. 2. 0. 1. 0 - Product i on on Thu Mar 23 12: 51: 002006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.
Connect ed t o:Or acl e Dat abase 10g Ent er pr i se Edi t i on Rel ease 10. 2. 0. 1. 0 Product i on Wi t h the Par t i t i oni ng, OLAP and Data Mi ni ng opt i ons
SQL> sel ect * f r om r egi ons;
REGI ON_I D REGI ON_NAME- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 Europe2 Amer i cas
3 Asi a4 Mi ddl e East and Af r i ca
3. Exit from your SQL*Plus session.
2) At the operating system prompt, execute the l ab_04_01_02_01. sh script to simulate a failure inyour database. This script deletes the EXAMPLE tablespace datafile.Answer:
1. At the operating system prompt, change to the l abs directory and execute thel ab_04_01_02_01. sh script.
[ oracl e@edr sr 10p1 l abs] $ . / l ab_04_01_02_01. sh
EXAMPLE tabl espace f i l e del eted
3) Use SQL*Plus to query the HR. J OBS table.Answer:
-
7/25/2019 Oracle Backup Recovery Student Guide
46/125
46
1. Log in to SQL*Plus and connect as the HR user with HR as the password.2. Query the HR. J OBS table.
SQL> sel ect * f r om j obs;
sel ect * f r om j obs
*ERROR at l i ne 1:ORA- 00376: f i l e 5 cannot be r ead at t hi s t i meORA- 01110: dat a f i l e 5:' / u01/ app/ or acl e/ or adat a/ or cl / exampl e01. dbf '
4) Use Enterprise Manager to perform database recovery of the EXAMPLE tablespace datafile.Answer:
1. Start Enterprise Manager and log in as SYS/ORACLE as SYSDBA.
2. Navigate to the Maintenance page.
3. Select Perform Recovery on the Maintenance page.
4. Click the Datafiles Need Media Recovery link.
5. Select the file and click Next.
-
7/25/2019 Oracle Backup Recovery Student Guide
47/125
47
6. Select No. Restore the files to the default location. Click Next.
7. On the Perform Object Level Recovery: Review page, click Edit RMAN Script to view the
script that will be executed. Click Submit.
8. The Processing page is displayed. After the recovery operation completes, the Result page isdisplayed indicating that the recovery operation succeeded.
9. Click OK to return to the Maintenance page.
5) Return to your SQL*Plus session and again attempt to query the HR. J OBS table.Answer:
1. Query the HR. J OBS table.
-
7/25/2019 Oracle Backup Recovery Student Guide
48/125
48
SQL> sel ect * f r om j obs;
J OB_I D J OB_TI TLE MI N_SALARYMAX_SALARY- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -AD_PRES Pr esi dent 20000
40000AD_VP Admi ni st r at i on Vi ce Presi dent 15000
30000AD_ASST Admi ni st r at i on Assi st ant 3000
6000FI _MGR Fi nance Manager 8200
16000MK_REP Market i ng Repr esent at i ve 4000
9000
HR_REP Human Resources Representat i ve 40009000PR_REP Publ i c Rel at i ons Repr esent at i ve 4500
10500
19 r ows sel ected.
-
7/25/2019 Oracle Backup Recovery Student Guide
49/125
49
Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover aDatafile
In this practice, you recover a lost datafile by using the Flash Recovery Area for fastrecovery.
1) Use SQL*Plus to query the HR. REGI ONS table. Make note of the number of rows in theHR. REGI ONS table.Answer:
1. Log in to SQL*Plus and connect as the HR user with HR as the password.
2. Query the HR. REGI ONS table.
3. Exit from SQL*Plus.
2) At the operating system prompt, execute the l ab_04_02_02_01. sh script to simulate a failure in
your database. This script deletes the EXAMPLE tablespace datafile.Answer:
1. At the operating system prompt, change to the l abs directory and execute thel ab_04_02_02_01. sh script.
[ oracl e@edr sr 10p1 l abs] $ . / l ab_04_02_02_01. sh
EXAMPLE tabl espace f i l e del eted
[ oracl e@edr sr 10p1 l abs] $
3) Use SQL*Plus to query the HR. DEPARTMENTS table.Answer:
1. Log in to SQL*Plus and connect as the HR user with HR as the password.
2. Query the HR. DEPARTMENTS table.
SQL> sel ect * f r om depar t ment s;sel ect * f r om depar t ment s*ERROR at l i ne 1:
ORA- 01116: er r or i n openi ng database f i l e 5ORA- 01110: dat a f i l e 5:' / u01/ app/ or acl e/ or adat a/ or cl / exampl e01. dbf 'ORA- 27041: unabl e t o open f i l eLi nux Er r or : 2: No such f i l e or di r ectoryAddi t i onal i nf or mat i on: 3
3. Make note of the number of the datafile that is unavailable. Datafile number: ____
-
7/25/2019 Oracle Backup Recovery Student Guide
50/125
50
4. Exit from your SQL*Plus session.
4) Use the RMAN SWI TCH TO COPY command to recover the datafile.Answer:
1. Log in to your target database using RMAN.
2. Take the datafile offline.
RMAN> SQL ' al t er dat abase dat af i l e 5 of f l i ne' ;sql st at ement : al t er dat abase dat af i l e 5 of f l i ne
3. Execute the SWI TCH TO COPY command for the datafile you noted in step 3.
RMAN> swi t ch dataf i l e 5 t o copy;dat af i l e 5 swi t ched t o dat af i l e copy" / u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ "
4. Recover the datafile.
RMAN> r ecover dataf i l e 5;
Star t i ng r ecover at 24- MAR- 06al l ocat ed channel : ORA_DI SK_1channel ORA_DI SK_1: si d=132 devt ype=DI SKal l ocated channel : ORA_SBT_TAPE_1channel ORA_SBT_TAPE_1: si d=130 devt ype=SBT_TAPEchannel ORA_SBT_TAPE_1: Or acl e Secur e Backup
st ar t i ng medi a r ecover ymedi a r ecover y compl ete, el apsed t i me: 00: 00: 03
Fi ni shed r ecover at 24- MAR- 06
5. Bring the datafile online.
RMAN> sql ' al t er dat abase dat af i l e 5 onl i ne' ;
sql st at ement : al t er dat abase dat af i l e 5 onl i ne
RMAN>
6. Exit from your RMAN session.
5) Query the HR. J OBS table.Answer:
1. Log in to SQL*Plus as HR/ HR and query the HR. J OBS table. (Output has been formatted to fitthe code box.)
-
7/25/2019 Oracle Backup Recovery Student Guide
51/125
51
SQL> sel ect * f r om j obs;J OB_I D J OB_TI TLE MI N_S MAX_SALARY- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AD_PRES Pr esi dent 20000 40000AD_VP Admi ni st r at i on Vi ce Presi dent 15000 30000
HR_REP Human Resources Representat i ve 4000 9000PR_REP Publ i c Rel at i ons Repr esent at i ve 4500 10500
19 r ows sel ect ed.
6) Using Enterprise Manager Database Control, verify that the datafile being used for the
EXAMPLE tablespace is in the Flash Recovery Area.Answer:
1. Select Tablespaces on the Administration page.
2. Select the Example tablespace and click View.
3. Click Return to return to the Tablespaces page.
7) Make a copy of the datafile in the original location and switch back to it.
Answer:
1. Log in to RMAN and connect to your target database.
2. Create an image copy of the datafile in the original location.
RMAN> @sol _04_02_07_02. r mnRMAN> backup as copy dat af i l e 52> f or mat ' / u01/ app/ or acl e/ or adat a/ or cl / exampl e01. dbf ' ;
St ar t i ng backup at 24- MAR- 06usi ng t ar get dat abase cont r ol f i l e i nst ead of r ecover y
-
7/25/2019 Oracle Backup Recovery Student Guide
52/125
52
cat al ogal l ocat ed channel : ORA_DI SK_1channel ORA_DI SK_1: si d=129 devt ype=DI SKchannel ORA_DI SK_1: st ar t i ng dat af i l e copyi nput dataf i l e f no=00005name=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ dat af i l ef
out put f i l ename=/ u01/ app/ or acl e/ or adat a/ or cl / exampl e01. dbft ag=TAG20060324T13447channel ORA_DI SK_1: dataf i l e copy compl et e, el apsed t i me:00: 00: 07Fi ni shed backup at 24- MAR- 06
St ar t i ng Cont r ol Fi l e and SPFI LE Aut obackup at 24- MAR- 06pi ecehandl e=/ u01/ app/ or acl e/ f l ash_r ecover y_area/ ORCL/ aut obackup/ 2006_03_24/ o1_EFi ni shed Cont r ol Fi l e and SPFI LE Aut obackup at 24- MAR- 06RMAN> **end- of - f i l e**
3. Take the datafile offline.
RMAN> sql ' al t er dat abase dat af i l e 5 of f l i ne' ;sql st at ement : al t er dat abase dat af i l e 5 of f l i ne
4. Switch to the new copy you made.
RMAN> swi t ch dat af i l e 5 t o copy;
dat af i l e 5 swi t ched t o dat af i l e copy" / u01/ app/ or acl e/ or adat a/ or cl / exampl e01. dbf "
5. Recover the datafile.
RMAN> r ecover dataf i l e 5;
St ar t i ng r ecover at 24- MAR- 06usi ng channel ORA_DI SK_1al l ocated channel : ORA_SBT_TAPE_1channel ORA_SBT_TAPE_1: si d=154 devt ype=SBT_TAPEchannel ORA_SBT_TAPE_1: Or acl e Secur e Backup
st ar t i ng medi a r ecover y
medi a r ecover y compl ete, el apsed t i me: 00: 00: 02
Fi ni shed r ecover at 24- MAR- 06
6. Bring the datafile back online. Exit from RMAN.
RMAN> sql ' al t er dat abase dat af i l e 5 onl i ne' ;sql st at ement : al t er dat abase dat af i l e 5 onl i ne
-
7/25/2019 Oracle Backup Recovery Student Guide
53/125
53
8) Use Enterprise Manager Database Control to verify the file.
Answer:
1. Select Tablespace on the Administration page.
2. Select the EXAMPLE tablespace and click View.
3. Note that the datafile is the one you switched to.
4. Click the Database tab to return to your database home page.
-
7/25/2019 Oracle Backup Recovery Student Guide
54/125
54
Solutions for Practice 4-3: Recover Control Files
In this practice, you recover your control file by using an autobackup.
1) Use SQL*Plus to view files information for the control files in your database. Query
V$CONTROLFI LE.Answer:
1. Log in to SQL*Plus as SYSDBA.2. Query the NAME column in V$CONTROLFI LE. Exit from SQL*Plus.
SQL> SELECT name FROM v$cont r ol f i l e;NAME- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/ u01/ app/ or acl e/ or adat a/ or cl / cont r ol 01. ctl/ u01/ app/ or acl e/ or adat a/ or cl / cont r ol 02. ctl/ u01/ app/ or acl e/ or adat a/ or cl / cont r ol 03. ctl
2) Simulate a failure in your environment by executing the l ab_04_03_02_01. shscript to delete all your control files.
Answer:
1. In your terminal window session, change to the l abs directory and execute thel ab_04_03_02_01. sh script.
[ oracl e@edr sr 10p1 or acl e]$ cd l abs[ oracl e@edr sr 10p1 l abs] $ . / l ab_04_03_02_01. sh
Cont r ol f i l es del et ed
[ oracl e@edr sr 10p1 l abs] $
3) You need some more information about your control files. Query
V$CONTROLFI LE_RECORD_SECTI ON to learn more about the contents of yourcontrol file.
Answer:
1. Log in to SQL*Plus as SYSDBA.
2. Query the V$CONTROLFI LE_RECORD_SECTI ON view.SQL> SELECT * FROM v$cont r ol f i l e_r ecor d_sect i on; SELECT * FROM v$cont r ol f i l e_r ecor d_sect i on*ERROR at l i ne 1:ORA- 00210: cannot open t he speci f i ed cont r ol f i l eORA- 00202: cont r ol f i l e:' / u01/ app/ or acl e/ oradat a/ orcl / cont r ol 01. ct l 'ORA- 27041: unabl e t o open f i l eLi nux Er r or : 2: No such f i l e or di r ectoryAddi t i onal i nf or mat i on: 3
-
7/25/2019 Oracle Backup Recovery Student Guide
55/125
55
4) You have lost all your control files and will need to recover them from the control file
autobackup. Use Recovery Manager to recover the control files.
Answer:
1. Use SQL*Plus to shut down your instance. Exit from your SQL*Plus session.
[ or acl e@edr sr 10p1 or acl e] $ sql pl us / as sysdba
SQL*Pl us: Rel ease 10. 2. 0. 1. 0 - Product i on on Tue Mar 2810: 20: 26 2006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.
Connect ed t o:Or acl e Dat abase 10g Ent er pr i se Edi t i on Rel ease 10. 2. 0. 1. 0- Pr oduct i onWi t h t he Par t i t i oni ng, OLAP and Data Mi ni ng opt i onsSQL> shut down abor t
ORACLE i nst ance shut down.SQL> exi tDi sconnect ed f r om Or acl e Dat abase 10g Ent er pr i se Edi t i onRel ease 10. 2. 0. 1. 0 - PnWi t h t he Par t i t i oni ng, OLAP and Data Mi ni ng opt i ons[ oracl e@edr sr 10p1 or acl e]$
2. Use RMAN to connect to your target database.
[ oracl e@edr sr 10p1 or acl e]$ rman
Recover y Manager : Rel ease 10. 2. 0. 1. 0 - Product i on on Tue
Mar 28 10: 23: 17 2006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.
RMAN> connect t arget /
connect ed t o tar get dat abase ( not st ar t ed)
RMAN>
3. Restart the instance in NOMOUNT mode.RMAN> st ar t up nomount
Or acl e i nst ance st ar t ed
Tot al Syst em Gl obal Ar ea 285212672 byt esFi xed Si ze 1218992 bytesVar i abl e Si ze 109053520 byt esDat abase Buf f ers 171966464 bytesRedo Buf f ers 2973696 byt es
-
7/25/2019 Oracle Backup Recovery Student Guide
56/125
56
4. Set the database identifier.Note: Your database identifier will be a different value from that shown in the
solution. You recorded the database identifier in Practice 2-1.
RMAN> set dbi d 1090770270;
execut i ng command: SET DBI D
5. Restore the control file from the autobackup.
RMAN> r est or e cont r ol f i l e f r om aut obackup;
St ar t i ng rest or e at 28- MAR- 06usi ng t ar get dat abase cont r ol f i l e i nst ead of r ecover ycat al ogal l ocat ed channel : ORA_DI SK_1channel ORA_DI SK_1: si d=156 devt ype=DI SK
r ecover y ar ea dest i nat i on:/ u01/ app/ or acl e/ f l ash_r ecover y_ar eadat abase name ( or dat abase uni que name) used f or sear ch:ORCLchannel ORA_DI SK_1: aut obackup f ound i n t he r ecover y areachannel ORA_DI SK_1: aut obackup f ound:/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ pchannel ORA_DI SK_1: cont r ol f i l e r est or e f r om aut obackupcompl et eout put f i l ename=/ u01/ app/ or acl e/ or adat a/ or cl / cont r ol 01. ct lout put f i l ename=/ u01/ app/ or acl e/ or adat a/ or cl / cont r ol 02. ct l
out put f i l ename=/ u01/ app/ oracl e/Fi ni shed r est ore at 28- MAR- 06
6. Mount the database.
RMAN> al t er database mount ;
dat abase mount edr el eased channel : ORA_DI SK_1
7. Recover the database by issuing the RECOVER DATABASE command.
RMAN> r ecover database;
Star t i ng r ecover at 28- MAR- 06St ar t i ng i mpl i ci t cr osscheck backup at 28- MAR- 06al l ocat ed channel : ORA_DI SK_1channel ORA_DI SK_1: si d=156 devt ype=DI SKCr osschecked 11 obj ect s
-
7/25/2019 Oracle Backup Recovery Student Guide
57/125
57
Fi ni shed i mpl i ci t cr osscheck backup at 28- MAR- 06
St ar t i ng i mpl i ci t cr osscheck copy at 28- MAR- 06usi ng channel ORA_DI SK_1Cr osschecked 5 obj ect sFi ni shed i mpl i ci t cr osscheck copy at 28- MAR- 06
sear chi ng f or al l f i l es i n t he r ecover y ar eacatal ogi ng f i l es . . .catal ogi ng doneLi st of Cat al oged Fi l es=======================Fi l e Name:/ u01/ app/ or acl e/ f l ash_recovery_area/ ORCL/ ar chi vel og/ 2006_03_28/ o1_mf cFi l e Name:/ u01/ app/ or acl e/ f l ash_recovery_area/ ORCL/ ar chi vel og/ 2006_03_28/ o1_mf c
Fi l e Name:/ u01/ app/ or acl e/ f l ash_recovery_area/ ORCL/ ar chi vel og/ 2006_03_28/ o1_mf cFi l e Name:/ u01/ app/ oracl e/ f l ash_r ecovery_area/ ORCL/ aut obackup/ 2006_03_27/ o1_mf p
usi ng channel ORA_DI SK_1al l ocated channel : ORA_SBT_TAPE_1channel ORA_SBT_TAPE_1: si d=155 devt ype=SBT_TAPEchannel ORA_SBT_TAPE_1: Or acl e Secur e Backup
st ar t i ng medi a r ecover yarchi ve l og t hr ead 1 sequence 116 i s al r eady on di sk asf i l e / u01/ app/ or ac l e/ f l carchi ve l og t hr ead 1 sequence 117 i s al r eady on di sk asf i l e / u01/ app/ or ac l e/ f l carchi ve l og t hr ead 1 sequence 118 i s al r eady on di sk asf i l e / u01/ app/ or ac l e/ f l carchi ve l og t hr ead 1 sequence 119 i s al r eady on di sk asf i l e / u01/ app/ or acl e/ or gar chi ve l ogf i l ename=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ ar chi velog/ 2006_06ar chi ve l og
f i l ename=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ ar chi velog/ 2006_07ar chi ve l ogf i l ename=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ ar chi velog/ 2006_08ar chi ve l ogf i l ename=/ u01/ app/ or acl e/ oradat a/ orcl / r edo01. l og t hr ead=1
-
7/25/2019 Oracle Backup Recovery Student Guide
58/125
58
sequence=9medi a r ecover y compl ete, el apsed t i me: 00: 00: 02Fi ni shed r ecover at 28- MAR- 06
8. Open the database with the RESETLOGS option.
RMAN> al t er dat abase open r eset l ogs;
dat abase opened
9. Back up the current online redo log file and back up all the archived redo log files.
RMAN> SQL ' ALTER SYSTEM ARCHI VE LOG CURRENT' ;
usi ng t ar get dat abase cont r ol f i l e i nst ead of r ecover ycat al ogsql st at ement : ALTER SYSTEM ARCHI VE LOG CURRENTRMAN> backup archi vel og al l ;
Star t i ng backup at 10- APR- 06cur r ent l og ar chi vedal l ocat ed channel : ORA_DI SK_1channel ORA_DI SK_1: si d=159 devt ype=DI SKchannel ORA_DI SK_1: st ar t i ng archi ve l og backupsetchannel ORA_DI SK_1: speci f yi ng ar chi ve l og( s) i n backupseti nput archi ve l og t hread=1 sequence=15 reci d=53st amp=587378250i nput archi ve l og t hread=1 sequence=16 reci d=54st amp=587379659
i nput archi ve l og t hread=1 sequence=17 reci d=55st amp=587379860i nput archi ve l og t hread=1 sequence=18 reci d=56st amp=587379970i nput archi ve l og t hread=1 sequence=19 reci d=57st amp=587380091i nput archi ve l og t hread=1 sequence=20 reci d=58st amp=587380115i nput archi ve l og t hread=1 sequence=21 reci d=59st amp=587380409i nput archi ve l og t hread=1 sequence=22 reci d=65st amp=587386310i nput archi ve l og t hread=1 sequence=23 reci d=66st amp=587386310i nput archi ve l og t hread=1 sequence=24 reci d=67st amp=587386311channel ORA_DI SK_1: st ar t i ng pi ece 1 at 10- APR- 06channel ORA_DI SK_1: f i ni shed pi ece 1 at 10- APR- 06pi ecehandl e=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ backupset /
-
7/25/2019 Oracle Backup Recovery Student Guide
59/125
59
2006_04_10/ o1_mEchannel ORA_DI SK_1: backup set compl ete, el apsed t i me:00: 00: 26channel ORA_DI SK_1: st ar t i ng archi ve l og backupsetchannel ORA_DI SK_1: speci f yi ng ar chi ve l og( s) i n backupset
i nput archi ve l og t hread=1 sequence=1 r eci d=68st amp=587391539i nput archi ve l og t hread=1 sequence=2 r eci d=69st amp=587391580channel ORA_DI SK_1: st ar t i ng pi ece 1 at 10- APR- 06channel ORA_DI SK_1: f i ni shed pi ece 1 at 10- APR- 06pi ecehandl e=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ backupset /2006_04_10/ o1_mEchannel ORA_DI SK_1: backup set compl ete, el apsed t i me:00: 00: 02Fi ni shed backup at 10- APR- 06
Star t i ng Cont r ol Fi l e and SPFI LE Aut obackup at 10- APR- 06pi ecehandl e=/ u01/ app/ or acl e/ f l ash_r ecover y_area/ ORCL/ aut obackup/ 2006_04_10/ o1_EFi ni shed Cont r ol Fi l e and SPFI LE Aut obackup at 10- APR- 06
10.Create a whole database backup.
RMAN> backup dat abase;Star t i ng backup at 10- APR- 06r el eased channel : ORA_SBT_TAPE_1
usi ng channel ORA_DI SK_1channel ORA_DI SK_1: st ar t i ng f ul l dat af i l e backupsetchannel ORA_DI SK_1: speci f yi ng dat af i l e(s) i n backupseti nput dat af i l e f no=00001name=/ u01/ app/ or acl e/ oradata/ orcl / syst em01. dbfi nput dat af i l e f no=00003name=/ u01/ app/ or acl e/ or adata/ or cl / sysaux01. dbfi nput dat af i l e f no=00005name=/ u01/ app/ or acl e/ oradata/ orcl / exampl e01. dbfi nput dat af i l e f no=00002name=/ u01/ app/ or acl e/ or adata/ or cl / undot bs01. dbfi nput dat af i l e f no=00004name=/ u01/ app/ or acl e/ or adata/ or cl / users01. dbfi nput dat af i l e f no=00006name=/ u01/ app/ or acl e/ oradata/ orcl / exampl e02. dbfchannel ORA_DI SK_1: st ar t i ng pi ece 1 at 10- APR- 06channel ORA_DI SK_1: f i ni shed pi ece 1 at 10- APR- 06pi ecehandl e=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ backupset /2006_04_10/ o1_mE
-
7/25/2019 Oracle Backup Recovery Student Guide
60/125
60
channel ORA_DI SK_1: backup set compl ete, el apsed t i me:00: 01: 25Fi ni shed backup at 10- APR- 06Star t i ng Cont r ol Fi l e and SPFI LE Aut obackup at 10- APR- 06pi ecehandl e=/ u01/ app/ or acl e/ f l ash_r ecover y_area/ ORCL/ aut obackup
/ 2006_04_10/ o1_EFi ni shed Cont r ol Fi l e and SPFI LE Aut obackup at 10- APR- 06
-
7/25/2019 Oracle Backup Recovery Student Guide
61/125
61
Solutions for Practice 4-4: Delete Obsolete Backups
1) Use Recovery Manager to view obsolete backups.
Answer:
1. In your RMAN session, issue the REPORT OBSOLETE command to determine whether youhave any obsolete backups.Note: Your results may vary from the following output.
RMAN> r epor t obsol et e;
RMAN r etent i on pol i cy wi l l be appl i ed t o the commandRMAN r et ent i on pol i cy i s set t o redundancy 1Report of obsol ete backups and copi es
Type Key Compl et i on Ti meFi l ename/ Handl e- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - -
Ar chi ve Log 19 15- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_acAr chi ve Log 20 16- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_acAr chi ve Log 21 20- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_acAr chi ve Log 22 20- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_acAr chi ve Log 23 20- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_acAr chi ve Log 24 21- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_ac
Dat af i l e Copy 4 21- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_afBackup Set 5 21- MAR- 06Backup Pi ece 5 21- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_apBackup Set 7 22- MAR- 06Backup Pi ece 7 22- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_apBackup Set 9 22- MAR- 06Backup Pi ece 10 22- MAR- 06/ u01/ app/ or acl e/ f l ash_r ecover y_ap
2) Use Enterprise Manager Database Control to delete obsolete backups.Answer:
1. Invoke Enterprise Manager and log in as sys/ or acl e as SYSDBA.
2. Select Maintenance > High Availability > Backup/Recovery > Manage Current Backups.
-
7/25/2019 Oracle Backup Recovery Student Guide
62/125
62
3. Click Delete All Obsolete to remove obsolete backups.
4. Review the information on the Delete All Obsolete: Specify Job Parameters page andclick Submit Job.
5. You receive the Job submission succeeded message. You can click View Job tomonitor the job. After it completes successfully, return to the Database Home page.
6. Access the Manage Current Backups page again to view the backup sets and imagecopies that were retained.
3) You can also use RMAN to verify that your obsolete backups were deleted.
Answer:
1. In your RMAN session, execute the REPORT OBSOLETE command.
RMAN> r epor t obsol et e;
RMAN r etent i on pol i cy wi l l be appl i ed t o the commandRMAN r et ent i on pol i cy i s set t o redundancy 1
no obsol et e backups f ound
-
7/25/2019 Oracle Backup Recovery Student Guide
63/125
63
Practice Solutions for Lesson 5
In this practice, you use Oracle Flashback features to recover from errors in your database.
-
7/25/2019 Oracle Backup Recovery Student Guide
64/125
64
Solutions for Practice 5-1: Enable Flashback Database
1) Use Enterprise Manager to enable Flashback Database.
Answer:
1. Start Enterprise Manager and connect as SYS/ ORACLE as SYSDBA.
2. Click the Maintenance tab.
3. Select Recovery Settings in the Backup/Recovery Settings section.
4. Scroll to the Flash Recovery section.
5. Select Enable Flashback Database - flashback logging can be used for fast database point-in-time recovery and click Apply.
6. The Confirmation message is displayed. You must restart the database instance to enableFlashback Database. Click Yes to restart the database instance.
7. Supply the Host and Operating System credentials if they are not filled in by default. Click OK
-
7/25/2019 Oracle Backup Recovery Student Guide
65/125
65
8. The Restart Database: Confirmation page is displayed. Click Yes.
9. The Restart Database:Activity Information page is displayed. Wait a few minutes and clickRefresh.
10.Log in to Enterprise Manager as SYS/ ORACLE as SYSDBA.
2) Use the ALTER DATABASE command to enable supplemental logging.Answer:
1. In a terminal window, log in to SQL*Plus as SYSDBA.
[ or acl e@edr sr 10p1 or acl e] $ sql pl us / as sysdba
SQL*Pl us: Rel ease 10. 2. 0. 1. 0 - Product i on on Tue Apr 1809: 10: 07 2006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.Connect ed t o:
Or acl e Dat abase 10g Ent er pr i se Edi t i on Rel ease 10. 2. 0. 1. 0- Pr oduct i onWi t h t he Par t i t i oni ng, OLAP and Data Mi ni ng opt i ons
2. Execute the ALTER DATABASE command to enable supplemental logging.
SQL> ALTER DATABASE add suppl ement al l og data;
Database al t er ed.
-
7/25/2019 Oracle Backup Recovery Student Guide
66/125
66
Solutions for Practice 5-2: Set Restore Points and Perform Flashback TableRestore points are a way to bookmark database points in time. Set a restore point to
remember a significant change so that you can quickly recover to that point in timewithout having to record an SCN or time.
1) You must enable row movement to use restore points. Use Enterprise Manager to
enable row movement for the HR. LOCATI ONS table.Answer:
1. Navigate to the Administration page. Select Tables in the Database Objects section.
2. Enter HR in the Schema field and LOCATI ONS in the Object Name field. Click Go.
3. Select the HR. LOCATI ONS table and click Edit.
4. Select the Options subtab.
5. Select Yes in the Enable Row Movement menu. Click Apply.
-
7/25/2019 Oracle Backup Recovery Student Guide
67/125
67
6. The Update Message is displayed indicating that the change has been made to the
HR. LOCATI ONS table.
7. Click the Database tab to return to the home page.
2) Create a normal restore point.
Answer:
1. Select the Maintenance tab.
2. Select Manage Restore Points in the Backup/Recovery section.
3. Click Create on the Manage Restore Points page.
4. Enter Bef ore_LOC_Updat e in the Restore Point Name field. Ensure that Normal RestorePoint is selected. Click OK.
5. Your restore point has been created.
-
7/25/2019 Oracle Backup Recovery Student Guide
68/125
68
3) Use SQL*Plus to query the POSTAL_CODE column in the HR. LOCATI ONS table.Answer:
1. Log in to SQL*Plus as SYSDBA.
2. Execute the l ab_05_02_03_02. sql script to query the POSTAL_CODE column of the
HR. LOCATI ONS table.
SQL> @l ab_05_02_03_02SQL> SELECT uni que ( post al _code)
2 FROM hr . l ocat i ons3 /
POSTAL_CODE- - - - - - - - - - - -10934
YSW 9T2
290126192M5V 2L701307- 002173030959923680925
23 r ows sel ected.
4) Execute the l ab_05_02_04_01. sql script to update the POSTAL_CODE columnin the HR. LOCATI ONS table so that all postal codes are set to 11111.Answer:
1. Execute the l ab_05_02_04_01. sql script.
SQL> @l ab_05_02_04_01SQL> UPDATE hr . l ocat i ons
2 SET post al _code = 111113 /
23 r ows updat ed.
5) Execute the l ab_05_02_05_01. sql script to query the POSTAL_CODE columnin the HR. LOCATI ONS table again.
Answer:
1. Execute the l ab_05_02_05_01. sql script.
-
7/25/2019 Oracle Backup Recovery Student Guide
69/125
69
SQL> @l ab_05_02_05_01SQL> SELECT uni que ( post al _code)
2 FROM hr . l ocat i ons3 /
POSTAL_CODE
- - - - - - - - - - - -11111
6) Restore the POSTAL_CODE column values using the restore point.Answer:
1. Return to your Enterprise Manager session.
2. Copy the SCN value in the Creation SCN field to the buffer.
3. Click the database instance link to return to the Maintenance page.
4. Click Perform Recovery.
5. In the Object Level Recovery section, select Tables in the Object Type menu. Click PerformObject Level Recovery.
-
7/25/2019 Oracle Backup Recovery Student Guide
70/125
70
6. Select Flashback to a known SCN and paste the SCN that you copied in step 2.Click Next.
7. Click Add Tables to add the HR. LOCATI ONS table.
8. Enter HR in the Schema Name field and LOCATI ONS in the Table field. Click Search.
9. Select the HR. LOCATI ONS table and click OK.
-
7/25/2019 Oracle Backup Recovery Student Guide
71/125
71
10.The HR. LOCATI ONS table is added to the Tables to Flashback field. Click
11.Accept the default of Cascade: Flashback the selected tables and all dependent tableson the Dependency Options page. Click Next.
12.On the Perform Object Level Recovery: Review page, confirm the information. ClickSubmit.
13.The Confirmation page is displayed. Click OK to return to the Maintenance page.
7) Return to your SQL*Plus session. Execute the l ab_05_02_07_01. sql script toquery the POSTAL_CODE column in HR. LOCATI ONS again to be sure the correctvalues have been restored.
Answer:
-
7/25/2019 Oracle Backup Recovery Student Guide
72/125
72
1. Execute the l ab_05_02_07_01. sql script.
SQL> @l ab_05_02_07_01SQL> SELECT uni que ( post al _code)
2 FROM hr . l ocat i ons3 /
POSTAL_CODE- - - - - - - - - - - -10934
YSW 9T29923680925
23 r ows sel ected.
-
7/25/2019 Oracle Backup Recovery Student Guide
73/125
73
Solutions for Practice 5-3: Use Flashback Query and FlashbackVersions Query
1) Execute the l ab_05_03_01_01. sql script to query the HR. LOCATI ONS tablefor location ID 1400.
Answer:
1. In SQL*Plus, execute the l ab_05_03_01_01. sql script.
SQL> @l ab_05_03_01_01SQL> SELECT *
2 FROM hr . l ocat i ons3 WHERE l ocat i on_i d = 14004 /
LOCATI ON_I D STREET_ADDRESSPOSTAL_CODE- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -CI TY STATE_PROVI NCECO- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
1400 2014 J abberwocky Rd 26192Sout hl ake TexasUS
2) Execute the l ab_05_03_02_01. sql script to update the POSTAL_CODE columnin the HR. LOCATI ONS table, simulating user error.
Answer:
1. Invoke SQL*Plus and execute the l ab_05_03_02_01. sql script.
SQL> @l ab_05_03_02_01SQL> UPDATE hr . l ocat i ons
2 SET post al _code = post al _code + 1003 WHERE l ocat i on_i d = 14004 /
1 r ow updat ed.
SQL> commi t2 /
Commi t compl et e.
3) Execute the l ab_05_03_03_01. sql script to query the POSTAL_CODE columnin HR. LOCATI ONS and view the change.Answer:
1. Execute the l ab_05_03_03_01. sql script.
-
7/25/2019 Oracle Backup Recovery Student Guide
74/125
74
SQL> @l ab_05_03_03_01SQL> SELECT *
2 FROM hr . l ocat i ons3 WHERE l ocat i on_i d = 14004 /
LOCATI ON_I D STREET_ADDRESSPOSTAL_CODE- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - -CI TY STATE_PROVI NCECO- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --1400 2014 J abberwocky Rd 26292Sout hl ake TexasUS
4) Execute the l ab_05_03_04_01. sql script to update the POSTAL_CODE columnin the HR. LOCATI ONS
Answer:
1. Execute the l ab_05_03_04_01. sql script.
SQL> @l ab_05_03_04_01SQL> UPDATE hr . l ocat i ons
2 SET post al _code = post al _code + 1003 WHERE l ocat i on_i d = 14004 /
1 r ow updat ed.
SQL> commi t2 /
Commi t compl et e.
5) Use Enterprise Manager to perform Flashback Versions Query to correct the usererrors.
Answer:
1. Navigate to the Administration page.
2. Select Tables in the Database Objects section.
3. Enter HR in the Schema Name field and LOCATI ONS in the Table field. Click Go.
-
7/25/2019 Oracle Backup Recovery Student Guide
75/125
75
4. Select the HR. LOCATI ONS table. Select Flashback Versions Query in the Actionsmenu. Click Go.
5. Choose all the columns by selecting each in the Available Columns list and clicking
Move to move it to the Selected Columns list.
6. Enter wher e l ocat i on_i d = 1400 in the Bind the Row Value field. Click Next
-
7/25/2019 Oracle Backup Recovery Student Guide
76/125
76
7. Select the oldest change to the table and click Next.
8. Confirm the flashback information. Click Next.
9. Accept the default of Cascade: Flashback the selected tables and all dependent tables. ClickNext.
10.Review the information. Click Submit.
-
7/25/2019 Oracle Backup Recovery Student Guide
77/125
77
11.The Confirmation page is displayed. Click OK.
6) Return to your SQL*Plus session. Query the HR. LOCATI ONS table to confirm theFlashback operation.
Answer:
1. Execute the l ab_05_03_06_01. sql script to query the HR. LOCATI ONS table.
SQL> @l ab_05_03_06_01SQL> SELECT *
2 FROM hr . l ocat i ons3 WHERE l ocat i on_i d = 14004 /
LOCATI ON_I D STREET_ADDRESSPOSTAL_CODE- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - -
CI TY STATE_PROVI NCECO- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
1400 2014 J abberwocky Rd 26192Sout hl ake TexasUS
-
7/25/2019 Oracle Backup Recovery Student Guide
78/125
78
Solutions for Practice 5-4: Use Flashback Database
1) Use Enterprise Manager to verify that Flashback Database is enabled.
Answer:
1. Navigate to the Maintenance page.
2. Select Recovery Settings in the Backup/Recovery Settings section. Scroll to the Flash Recoverysection. Verify that Flashback Database is enabled.
3. Click the Database Instance link to return to the Maintenance page.
2) Use Enterprise Manager to create a Guaranteed Restore Point.
Answer:
1. Select Manage Restore Points in the Backup/Recovery section.
2. Click Create to create a new restore point.
3. Enter Bef ore_Tr uncat e in the Restore Point Name field. Select Guaranteed RestorePoint. Click OK.
-
7/25/2019 Oracle Backup Recovery Student Guide
79/125
79
4. The Restore Point is created.
3) Execute the l ab_05_04_03_01. sql script to determine the number of rows inthe HR. J OB_HI STORY table. Record the number of rows: ___________
Answer:
1. Execute the l ab_05_04_03_01. sql script to determine the number of rows in theHR. J OB_HI STORY table.
SQL> @l ab_05_04_03_01SQL> SELECT count ( *)
2 FROM hr . j ob_hi st or y3 /
COUNT( *)- - - - - - - - - -
10
4) Execute the l ab_05_04_04_01. sql script to truncate the HR. J OB_HI STORYtable.
Answer:
1. Execute the l ab_05_04_04_01. sql script.
SQL> @l ab_05_04_04_01SQL> t r uncat e tabl e hr . j ob_hi st or y
2 /
Tabl e t r uncat ed.
5) Execute the l ab_05_04_05_01. sql script to determine the number of rows inthe HR. J OB_HI STORY table.Answer:
-
7/25/2019 Oracle Backup Recovery Student Guide
80/125
80
1. Execute the l ab_05_04_05_01. sql script.
SQL> @l ab_05_04_05_01SQL> SELECT count ( *)
2 FROM hr . j ob_hi st or y3 /
COUNT( *)- - - - - - - - - -0
6) Use Flashback Database to restore the HR. J OB_HI STORY table rows.Answer:
1. Return to your Enterprise Manager window.
2. Navigate to the Maintenance page.
3. Select Manage Restore Points in the Backup/Recovery section.
4. Select the BEFORE_TRUNCATE restore point. Click Recover Whole Database To.
5. Enter the host credential information. Click Yes.
6. The database is shut down. Click Refresh.
-
7/25/2019 Oracle Backup Recovery Student Guide
81/125
81
7. Click Perform Recovery.
8. Enter Host Credentials. Click Continue.
9. Enter Database login. Click Login.
10.Click Perform Whole Database Recovery.
11.Select Recover to a prior point in time.
12.Select Restore Point and click the Flashlight icon.
13.Select the BEFORE_TRUNCATE restore point. Click Select
14.The Restore Point field is populated. Click Next.
-
7/25/2019 Oracle Backup Recovery Student Guide
82/125
82
15.Select Yes. Click Next.
16.Review the information. Click Submit.
17.The Processing: Perform Whole Database Recovery page is displayed.
18.The operation is complete. You can scroll through the output to view the details of the operation.Click Open Database to open the database.
19.The The database has been opened successfully message is displayed. Click OK.
7) Return to your SQL*Plus session. Execute the l ab_05_04_07_02. sql script toquery the HR. J OB_HI STORY table again to be sure the data has been restored.Answer:
1. Invoke SQL*Plus and log in as SYS/ ORACLE as SYSDBA.
2. Execute the l ab_05_04_07_02. sql script.
-
7/25/2019 Oracle Backup Recovery Student Guide
83/125
83
SQL> @query_j ob_hi stSQL> SELECT count ( *)
2 FROM hr . j ob_hi st or y
3 /
COUNT( *)- - - - - - - - - -10
-
7/25/2019 Oracle Backup Recovery Student Guide
84/125
84
Practice Solutions for Lesson 6
In this practice, you create a duplicate database.
-
7/25/2019 Oracle Backup Recovery Student Guide
85/125
85
Solutions for Practice 6-1: Create a Duplicate DatabaseIn this practice, you use RMAN to create a duplicate database on the same host as your database.
1) Create an Oracle password file for your auxiliary instance.
Answer:
1. Change to the $ORACLE_HOME/ dbs directory and use the or apwd utility to create a
password file named orapwaux. Specify a password of or acl e and 10 for the number ofentries.
[ oracl e@edr sr 10p1 oracl e] $ cd $ORACLE_HOME/ dbs[ oracl e@edr sr 10p1 dbs] $ orapwd f i l e=orapwauxpassword=oracl e ent r i es=10[ oracl e@edr sr 10p1 dbs] $ l shc_or cl . dat i ni t . or a or apwaux snapcf _or cl . fi ni t dw. or a l kORCL or apwor cl spf i l eor cl . or a
2) Use Oracle Net Manager to create an entry calledAUXDB in the t nsnames. ora file.Answer:
1. Open a terminal window and enter net mgr at the operating system prompt.
[ oracl e@edr sr 10p1 oracl e]$ net mgr
2. The Oracle Net Manager window appears.
3. Expand Local and Service Naming.
4. Select Service Naming and click the green plus sign to create a new Net service name.
-
7/25/2019 Oracle Backup Recovery Student Guide
86/125
86
5. Enter auxdb in the Net Service Name field and click Next.
6. Select TCP/IP (default) as the protocol. Click Next.
7. Enter the host name of your PC in the Host Name field. Accept the default of 1521 for the portnumber. Click Next.
8. Enter aux. or acl e. com in the Service Name field. Click Next.
-
7/25/2019 Oracle Backup Recovery Student Guide
87/125
87
9. Click Finish.
10.Select File and Save Network Configuration to save the changes you made.
11. Click File and Exit to exit from Oracle Net Manager.
12. You can view your updated t nsnames. ora file in the/ u01/ app/ or acl e/ pr oduct / 10. 2. 0/ db_1/ net wor k/ admi n directory.
AUXDB =( DESCRI PTI ON =
( ADDRESS = ( PROTOCOL = TCP) ( HOST =edr sr 10p1. us. oracl e. com) ( PORT = 1521) )
( CONNECT_DATA =( SERVER = DEDI CATED)( SERVI CE_NAME = aux. or acl e. com)
)
3) Create an initialization parameter file for the auxiliary instance.Answer:
1. Create a text initialization parameter file named initAUX.ora from your server parameter file
in the $HOME/ auxi nst ance directory.
[ oracl e@edr sr 10p1 or acl e]$ cd $HOME/ auxi nst ance[ oracl e@edr sr 10p1 auxi nst ance]$ sql pl us / as sysdba
SQL*Pl us: Rel ease 10. 2. 0. 1. 0 - Product i on on Wed Mar 2910: 51: 53 2006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.
Connect ed t o:Or acl e Dat abase 10g Ent er pr i se Edi t i on Rel ease 10. 2. 0. 1. 0- Pr oduct i onWi t h t he Par t i t i oni ng, OLAP and Data Mi ni ng opt i ons
SQL> cr eat e pf i l e=' $HOME/ auxi nst ance/ i ni t AUX. or a' f r omspf i l e;
Fi l e creat ed.
2. Edit the initAUX.ora initialization parameter file to make the following changes for theauxiliary instance:
audi t _f i l e_dest =' / u01/ app/ or acl e/ admi n/ aux/ adump'background_dump_dest =' / u01/ app/ oracl e/ admi n/ aux/ bdumpcont r ol _f i l es=' / u01/ app/ or acl e/ or adat a/ aux/ cont r ol 01. ct l ' , ' / u01/ app/ or ac l e/ oradata/ aux/ cont r ol 02. ct l ' , ' / u01/
-
7/25/2019 Oracle Backup Recovery Student Guide
88/125
88
app/ or acl e/ or adat a/ aux/ cont r ol 03. ctl 'db_name=' aux'user_dump_dest =' / u01/ app/ oracl e/ admi n/ aux/ udump'
Add the following parameters:DB_FI LE_NAME_CONVERT= / u01/ app/ oracl e/ oradata/ orcl ,
/ u01/ app/ or acl e/ or adat a/ auxLOG_FI LE_NAME_CONVERT= / u01/ app/ oracl e/ oradat a/ orcl , / u01/ app/ or acl e/ or adat a/ auxRemove the lines at the beginning of the file that begin with orc l . __ .
Add the comment character, #, to this line:*. di spat cher s=' ( PROTOCOL=TCP) ( SERVI CE=orcl XDB) '
4) Start the auxiliary instance in NOMOUNT mode using the i ni t AUX. or a file.Answer:
1. Set the ORACLE_SI D environment variable to aux.
[ oracl e@edr sr 10p1 oracl e] $ ORACLE_SI D=aux[ oracl e@edr sr 10p1 oracl e] $ echo $ORACLE_SI DAux
2. Invoke SQL*Plus and connect as SYSDBA.
[ or acl e@edr sr 10p1 or acl e] $ sql pl us / as sysdba
SQL*Pl us: Rel ease 10. 2. 0. 1. 0 - Product i on on Wed Mar 2911: 38: 53 2006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.
Connect ed t o an i dl e i nst ance.
3. Start the instance in NOMOUNT mode using the initialization parameter file you created in step 2.
SQL> st art up nomount pf i l e=' $HOME/ auxi nst ance/ i ni t AUX. ora'ORACLE i nst ance st ar t ed.
Tot al Syst em Gl obal Ar ea 285212672 byt esFi xed Si ze 1218992 bytesVar i abl e Si ze 92276304 byt es
Dat abase Buf f ers 188743680 bytesRedo Buf f ers 2973696 byt es
5) Create a server parameter file (SPFILE).
Answer:
-
7/25/2019 Oracle Backup Recovery Student Guide
89/125
89
1. Create a server parameter file with the default name of spf i l eaux. or a from the textinitialization parameter file.
SQL> cr eat e spf i l e f r ompf i l e=' $HOME/ auxi nst ance/ i ni t AUX. or a' ;Fi l e creat ed.
2. Exit from SQL*Plus.
6) Verify that your target database (orc l database) is mounted or open.Answer:
1. Set your ORACLE_SI D to orcl .
[ oracl e@edr sr 10p1 or acl e]$ ORACLE_SI D=orcl[ oracl e@edr sr 10p1 oracl e] $ echo $ORACLE_SI Dorc l[ oracl e@edr sr 10p1 or acl e]$
2. Log in to SQL*Plus as SYSDBA.
3. Query V$DATABASE to determine whether your database is open.
SQL> sel ect open_mode f r om v$dat abase;
OPEN_MODE- - - - - - - - - -READ WRI TE
4. Exit from SQL*Plus.
7) Start RMAN with a connection to the target database (orcl ) and the auxiliary instance.Answer:
1. Set your ORACLE_SI D to aux. Invoke RMAN and connect as SYSDBA.Connect to the targetdatabase.
[ oracl e@edr sr 10p1 oracl e] $ ORACLE_SI D=aux[ oracl e@edr sr 10p1 oracl e] $ echo $ORACLE_SI Daux[ oracl e@edr sr 10p1 oracl e]$ rman
Recover y Manager : Rel ease 10. 2. 0. 1. 0 - Product i on on Thu
Mar 30 07: 34: 06 2006
Copyri ght ( c) 1982, 2005, Or acl e. Al l r i ght s reser ved.
RMAN> connect auxi l i ar y sys/ or acl e
connect ed t o auxi l i ary dat abase: AUX ( not mount ed)
-
7/25/2019 Oracle Backup Recovery Student Guide
90/125
90
RMAN> connect t arget sys/ oracl e@orcl
connect ed to t arget database: ORCL ( DBI D=1090770270)
8) Create the duplicate database by executing the DUPLI CATE command.
Answer:
1. Create a RUN block to allocate the auxiliary channel and execute the DUPLI CATE command.
RMAN> r un2> {3> al l ocat e auxi l i ar y channel aux1 devi ce t ype di sk;4> dupl i cat e tar get database t o aux;5> }al l ocated channel : aux1channel aux1: si d=156 devt ype=DI SK
Star t i ng Dupl i cat e Db at 30- MAR- 06al l ocated channel : ORA_AUX_DI SK_1channel ORA_AUX_DI SK_1: si d=154 devt ype=DI SKusi ng channel ORA_AUX_SBT_TAPE_1
cont ents of Memory Scr i pt :{
set unt i l scn 4236965;set newname f or dataf i l e 1 t o
" / u01/ app/ or acl e/ or adat a/ aux/ system01. dbf ";set newname f or dataf i l e 2 t o
" / u01/ app/ or acl e/ or adat a/ aux/ undot bs01. dbf " ;
set newname f or dataf i l e 3 t o" / u01/ app/ or acl e/ or adat a/ aux/ sysaux01. dbf ";set newname f or dataf i l e 4 t o
" / u01/ app/ or acl e/ or adat a/ aux/ user s01. dbf ";set newname f or dataf i l e 5 t o
" / u01/ app/ or acl e/ or adat a/ aux/ exampl e01. dbf " ;r est or echeck r eadonl ycl one database;
}execut i ng Memory Scr i ptexecut i ng command: SET unt i l cl ause
execut i ng command: SET NEWNAME
execut i ng command: SET NEWNAME
execut i ng command: SET NEWNAME
-
7/25/2019 Oracle Backup Recovery Student Guide
91/125
91
execut i ng command: SET NEWNAME
execut i ng command: SET NEWNAME
St ar t i ng rest or e at 30- MAR- 06usi ng channel ORA_AUX_DI SK_1
usi ng channel ORA_AUX_SBT_TAPE_1channel aux1: r est or i ng dataf i l e 00001i nput dat af i l e copy r eci d=23 st amp=586270526f i l ename=/ u01/ app/ or acl e/ f l ash_r ecfdest i nat i on f or r est or e of dat af i l e 00001:/ u01/ app/ or acl e/ or adat a/ aux/ syst em01fchannel ORA_AUX_DI SK_1: r est or i ng dataf i l e 00002i nput dat af i l e copy r eci d=20 st amp=586270521f i l ename=/ u01/ app/ or acl e/ f l ash_r ecfdest i nat i on f or r est or e of dat af i l e 00002:/ u01/ app/ or acl e/ or adat a/ aux/ undot bs0fchannel ORA_AUX_DI SK_1: copi ed dat af i l e copy of dat af i l e
00002out put f i l ename=/ u01/ app/ oracl e/ or adat a/ aux/ undot bs01. dbfchannel ORA_AUX_DI SK_1: r est or i ng dataf i l e 00003i nput dat af i l e copy r eci d=22 st amp=586270526f i l ename=/ u01/ app/ or acl e/ f l ash_r ecfdest i nat i on f or r est or e of dat af i l e 00003:/ u01/ app/ or acl e/ or adat a/ aux/ sysaux01fchannel aux1: copi ed dat af i l e copy of dat af i l e 00001out put f i l ename=/ u01/ app/ oracl e/ or adat a/ aux/ syst em01. dbfchannel aux1: r est or i ng dataf i l e 00004i nput dat af i l e copy r eci d=19 st amp=586270517f i l ename=/ u01/ app/ or acl e/ f l ash_r ecfdest i nat i on f or r est or e of dat af i l e 00004:/ u01/ app/ or acl e/ or adat a/ aux/ user s01. fchannel ORA_AUX_DI SK_1: copi ed dat af i l e copy of dat af i l e00003out put f i l ename=/ u01/ app/ oracl e/ or adat a/ aux/ sysaux01. dbfchannel ORA_AUX_DI SK_1: r est or i ng dataf i l e 00005i nput dat af i l e copy r eci d=21 st amp=586270521f i l ename=/ u01/ app/ or acl e/ f l ash_r ecfdest i nat i on f or r est or e of dat af i l e 00005:/ u01/ app/ or acl e/ or adat a/ aux/ exampl e0fchannel aux1: copi ed dat af i l e copy of dat af i l e 00004out put f i l ename=/ u01/ app/ oracl e/ or adat a/ aux/ users01. dbfchannel ORA_AUX_DI SK_1: copi ed dat af i l e copy of dat af i l e
00005out put f i l ename=/ u01/ app/ oracl e/ or adat a/ aux/ exampl e01. dbfFi ni shed r est ore at 30- MAR- 06sql st at ement : CREATE CONTROLFI LE REUSE SET DATABASE "AUX"RESETLOGS ARCHI VELOG
MAXLOGFI LES 16MAXLOGMEMBERS 3
-
7/25/2019 Oracle Backup Recovery Student Guide
92/125
92
MAXDATAFI LES 100MAXI NSTANCES 8MAXLOGHI STORY 292
LOGFI LEGROUP 1 ( ' / u01/ app/ or acl e/ or adata/ aux/ r edo01. l og' )
SI ZE 50 M REUSE,
GROUP 2 ( ' / u01/ app/ or acl e/ or adata/ aux/ r edo02. l og' )SI ZE 50 M REUSE,
GROUP 3 ( ' / u01/ app/ or acl e/ or adata/ aux/ r edo03. l og' )SI ZE 50 M REUSE
DATAFI LE' / u01/ app/ or acl e/ or adat a/ aux/ syst em01. dbf '
CHARACTER SET AL32UTF8cont ents of Memory Scr i pt :{
Swi t ch cl one dat af i l e al l ;}execut i ng Memory Scr i pt
r el eased channel : ORA_AUX_DI SK_1r el eased channel : ORA_AUX_SBT_TAPE_1dat af i l e 2 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=1 st amp=586438014f i l ename=/ u01/ app/ or acl e/ oradat a/ aufdat af i l e 3 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=2 st amp=586438014f i l ename=/ u01/ app/ or acl e/ oradat a/ aufdat af i l e 4 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=3 st amp=586438014f i l ename=/ u01/ app/ or acl e/ oradat a/ aufdat af i l e 5 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=4 st amp=586438014f i l ename=/ u01/ app/ or acl e/ oradat a/ auf
cont ents of Memory Scr i pt :{
set unt i l scn 4236965;r ecovercl one database
del et e ar chi vel og;
}execut i ng Memory Scr i pt
execut i ng command: SET unt i l cl ause
Star t i ng r ecover at 30- MAR- 06channel aux1: st ar t i ng i ncr ement al dat af i l e backupsetr est or echannel aux1: speci f yi ng dat af i l e( s) t o r est or e f r om
-
7/25/2019 Oracle Backup Recovery Student Guide
93/125
93
backup setdest i nat i on f or r est or e of dat af i l e 00001:/ u01/ app/ or acl e/ or adat a/ aux/ syst em01fdest i nat i on f or r est or e of dat af i l e 00002:/ u01/ app/ or acl e/ or adat a/ aux/ undot bs0fdest i nat i on f or r est or e of dat af i l e 00003:
/ u01/ app/ or acl e/ or adat a/ aux/ sysaux01fdest i nat i on f or r est or e of dat af i l e 00004:/ u01/ app/ or acl e/ or adat a/ aux/ user s01. fdest i nat i on f or r est or e of dat af i l e 00005:/ u01/ app/ or acl e/ or adat a/ aux/ exampl e0fchannel aux1: r eadi ng f r om backup pi ece/ u01/ app/ or acl e/ f l ash_recovery_area/ ORCpchannel aux1: r est or ed backup pi ece 1pi ecehandl e=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ backupset /2006_03_28/ o1_m4channel aux1: r est or e compl ete, el apsed t i me: 00: 00: 16
st ar t i ng medi a r ecover yarchi ve l og t hr ead 1 sequence 1 i s al r eady on di sk as f i l e/ u01/ app/ or acl e/ f l ascarchi ve l og t hr ead 1 sequence 2 i s al r eady on di sk as f i l e/ u01/ app/ or acl e/ f l ascar chi ve l ogf i l ename=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ ar chi velog/ 2006_01ar chi ve l ogf i l ename=/ u01/ app/ or acl e/ f l ash_r ecover y_ar ea/ ORCL/ ar chi velog/ 2006_02medi a r ecover y compl ete, el apsed t i me: 00: 00: 05Fi ni shed r ecover at 10- APR- 06
cont ents of Memory Scr i pt :{
shut down cl one;st ar t up cl one nomount ;
}execut i ng Memory Scr i ptdatabase di smount edOr acl e i nst ance shut down
connect ed t o auxi l i ar y dat abase (not st ar t ed)
Or acl e i nst ance st ar t ed
Tot al Syst em Gl obal Ar ea 285212672 byt es
Fi xed Si ze 1218992 byt esVar i abl e Si ze 92276304 byt esDat abase Buf f ers 188743680 byt es
-
7/25/2019 Oracle Backup Recovery Student Guide
94/125
94
Redo Buf f ers 2973696 byt essql st at ement : CREATE CONTROLFI LE REUSE SET DATABASE "AUX"RESETLOGS ARCHI VELOG
MAXLOGFI LES 16MAXLOGMEMBERS 3MAXDATAFI LES 100
MAXI NSTANCES 8MAXLOGHI STORY 292
LOGFI LEGROUP 1 ( ' / u01/ app/ or acl e/ or adata/ aux/ r edo01. l og' )
SI ZE 50 M REUSE,GROUP 2 ( ' / u01/ app/ or acl e/ or adata/ aux/ r edo02. l og' )
SI ZE 50 M REUSE,GROUP 3 ( ' / u01/ app/ or acl e/ or adata/ aux/ r edo03. l og' )
SI ZE 50 M REUSEDATAFI LE
' / u01/ app/ or acl e/ or adat a/ aux/ system01. dbf 'CHARACTER SET AL32UTF8
cont ents of Memory Scr i pt :{
set newname f or t empf i l e 1 t o" / u01/ app/ or acl e/ or adat a/ aux/ t emp01. dbf ";
swi t ch cl one t empf i l e al l ;cat al og cl one dat af i l ecopy
" / u01/ app/ or acl e/ or adat a/ aux/ undot bs01. dbf " ;cat al og cl one dat af i l ecopy
" / u01/ app/ or acl e/ or adat a/ aux/ sysaux01. dbf ";cat al og cl one dat af i l ecopy
" / u01/ app/ or acl e/ or adat a/ aux/ user s01. dbf ";cat al og cl one dat af i l ecopy
" / u01/ app/ or acl e/ or adat a/ aux/ exampl e01. dbf " ;cat al og cl one dat af i l ecopy
" / u01/ app/ or acl e/ or adat a/ aux/ exampl e02. dbf " ;swi t ch cl one dat af i l e al l ;
}execut i ng Memory Scr i pt
execut i ng command: SET NEWNAME
r enamed t empor ary f i l e 1 t o/ u01/ app/ or acl e/ or adat a/ aux/ t emp01. dbf i n cont r ol f ecat al oged dat af i l e copy
dat af i l e copyf i l ename=/ u01/ app/ or acl e/ oradata/ aux/ undotbs01. dbf r eci d=1st amp=8
cat al oged dat af i l e copydat af i l e copy
-
7/25/2019 Oracle Backup Recovery Student Guide
95/125
95
f i l ename=/ u01/ app/ or acl e/ oradat a/ aux/ sysaux01. dbf r eci d=2st amp=59
cat al oged dat af i l e copydat af i l e copyf i l ename=/ u01/ app/ or acl e/ oradat a/ aux/ users01. dbf r eci d=3
st amp=589
cat al oged dat af i l e copydat af i l e copyf i l ename=/ u01/ app/ or acl e/ oradata/ aux/ exampl e01. dbf r eci d=4st amp=9
cat al oged dat af i l e copydat af i l e copyf i l ename=/ u01/ app/ or acl e/ oradata/ aux/ exampl e02. dbf r eci d=5st amp=9
dat af i l e 2 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=1 st amp=587391888f i l ename=/ u01/ app/ or acl e/ oradat a/ aufdat af i l e 3 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=2 st amp=587391889f i l ename=/ u01/ app/ or acl e/ oradat a/ aufdat af i l e 4 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=3 st amp=587391889f i l ename=/ u01/ app/ or acl e/ oradat a/ aufdat af i l e 5 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=4 st amp=587391889f i l ename=/ u01/ app/ or acl e/ oradat a/ aufdat af i l e 6 swi t ched t o dat af i l e copyi nput dat af i l e copy r eci d=5 st amp=587391889f i l ename=/ u01/ app/ or acl e/ oradat a/ auf
cont ents of Memory Scr i pt :{
Al t er cl one dat abase open r eset l ogs;}execut i ng Memory Scr i pt
dat abase openedFi ni shed Dupl i cat e Db at 10- APR- 06
2. After the DUPLI CATE DATABASE operation completes, exit from RMAN.
9) Use SQL*Plus to log in to your AUX database and execute a query against the HR. REGI ONS table.Answer:
1. Verify that ORACLE_SI D is set