Académique Documents
Professionnel Documents
Culture Documents
D22057GC10
Production 1.0
June 2006
D46524
Authors
Donna Keesling
Maria Billings
Technical Contributors
and Reviewers
Christopher Andrews
Tammy Bednar
Tom Best
Harald van Breederode
Mary Jane Bryksa
Marielle Canning
Tim Chien
Donna Cooksey
Judy Ferstenberg
Gerlinde Frenzen
Joel Goodman
Pete Jones
Isabelle Marchand
Sabiha Miri
Manish Pawar
Jim Spiller
George Stabler
Anthony Woodell
Editor
Daniel Milne
Graphic Designer
Satish Bettegowda
Publisher
Jobi Varghese
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 in
Enterprise Manager Database Control..
10
11
12
13
14
15
16
17
18
19
20
21
Note: You will not perform another tablespace point-in-recovery in this practice.
You would need to disable the DEPT_LOC_ID_FK constraint that was added to your
HRTEST.DEPARTMENTS table or you would need to add
23
24
7) In preparation for later practices, use RMAN to unregister your database from the
recovery catalog.
25
26
27
28
Practice Solutions
29
Table of Contents
Solutions for Practice 2-1: Configure Your Database .................................................... 5
Solutions for Practice 3-1: Use RMAN to Create and Manage Backups ..................... 10
Solutions for Practice 4-1: Use RMAN to Recover a Datafile ..................................... 17
Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover a Datafile
...................................................................................................................................... 21
Solutions for Practice 4-3: Recover Control Files ........................................................ 26
Solutions for Practice 4-4: Delete Obsolete Backups ................................................... 33
Solutions for Practice 5-1: Enable Flashback Database ............................................... 36
Solutions for Practice 5-2: Set Restore Points and Perform Flashback Table.............. 38
Solutions for Practice 5-3: Use Flashback Query and Flashback Versions Query....... 46
Solutions for Practice 5-4: Use Flashback Database .................................................... 52
Solutions for Practice 6-1: Create a Duplicate Database .............................................. 60
Solutions for Practice 7-1: Use Tablespace Point-in-time Recovery............................ 74
Solutions 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
30
31
32
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. In
the Host Credentials section, enter oracle in the Username and Password fields.
In the Database Credentials section, enter SYS in the Username field and
oracle 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.
33
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 the
Maintenance 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: system
Normal Password: oracle
SYSDBA Username: sys
SYSDBA Password: oracle
Host Username: oracle
Host Password: oracle
5. Click Test. The Credentials successfully verified for orcl.oracle.com message is displayed. If
you 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 database
identifier (DBID) of your database.
Database Identifier: ____________________________
Answer:
34
36
37
Solutions for Practice 3-1: Use RMAN to Create and Manage Backups
1) Use Enterprise Manager Database Control to configure autobackup of the control file
and the server parameter 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 Automatically backup the control file and
server parameter file (SPFILE) with every backup and database structural
change. Click OK.
38
3. On the Schedule Oracle-Suggested Backup: Destination page, select Disk. Click Next.
4. Review the information on the Schedule Oracle-Suggested Backup: Setup page. Note that a full
database copy will be performed during the first backup. After that, an incremental backup to disk
will be performed every day. Click Next.
39
5. On the Schedule Oracle-Suggested Backup: Schedule page, you can specify the time for your
backups. Set the Time Zone field to correspond to your time zone.
9. In the output log, you can see that RMAN has made a datafile copy backup of
each datafile in your database.
40
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 the
backup.
41
7
B F A DISK
NO
TAG200607
8
B F A DISK
NO
TAG200603
9
B F A DISK
NO
TAG200608
RMAN> **end-of-file**
RMAN> exit
22-MAR-06
22-MAR-06
22-MAR-06
3. Review the information on the Crosscheck All: Specify Job Parameters page and
accept the default values. Click Submit Job.
4. You receive the Job submission succeeded message. You can click View Job to
monitor the cross-check job. After it completes successfully, return to the
Database Home page.
5. Log out of Enterprise Manager.
43
44
REGION_NAME
------------------------Europe
Americas
Asia
Middle East and Africa
46
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 is
displayed indicating that the recovery operation succeeded.
47
MK_REP
9000
HR_REP
9000
PR_REP
10500
JOB_TITLE
MIN_SALARY
----------------------------------- ---------President
20000
15000
Administration Assistant
3000
Finance Manager
8200
Marketing Representative
4000
4000
4500
19 rows selected.
48
Solutions for Practice 4-2: Use the Flash Recovery Area to Quickly Recover a
Datafile
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.REGIONS table. Make note of the number of rows in the
HR.REGIONS table.
Answer:
1. Log in to SQL*Plus and connect as the HR user with HR as the password.
2. Query the HR.REGIONS table.
3. Exit from SQL*Plus.
2) At the operating system prompt, execute the lab_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 labs directory and execute the
lab_04_02_02_01.sh script.
[oracle@edrsr10p1 labs]$ ./lab_04_02_02_01.sh
EXAMPLE tablespace file deleted
[oracle@edrsr10p1 labs]$
HR_REP
Human Resources Representative
PR_REP
Public Relations Representative
MIN_S MAX_SALARY
----- ---------20000
40000
15000
30000
4000
4500
9000
10500
19 rows selected.
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.
catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=129 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005
name=/u01/app/oracle/flash_recovery_area/ORCL/datafilef
output filename=/u01/app/oracle/oradata/orcl/example01.dbf
tag=TAG20060324T13447
channel ORA_DISK_1: datafile copy complete, elapsed time:
00:00:07
Finished backup at 24-MAR-06
Starting Control File and SPFILE Autobackup at 24-MAR-06
piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup
/2006_03_24/o1_E
Finished Control File and SPFILE Autobackup at 24-MAR-06
RMAN> **end-of-file**
53
You need some more information about your control files. Query
V$CONTROLFILE_RECORD_SECTION to learn more about the contents of your
control file.
Answer:
1. Log in to SQL*Plus as SYSDBA.
2. Query the V$CONTROLFILE_RECORD_SECTION view.
SQL> SELECT * FROM v$controlfile_record_section;
SELECT * FROM v$controlfile_record_section
*
ERROR at line 1:
ORA-00210: cannot open the specified control file
ORA-00202: control file:
'/u01/app/oracle/oradata/orcl/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
54
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.
[oracle@edrsr10p1 oracle]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 28
10:20:26 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
- Production
With the Partitioning, OLAP and Data Mining options
SQL> shutdown abort
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition
Release 10.2.0.1.0 - Pn
With the Partitioning, OLAP and Data Mining options
[oracle@edrsr10p1 oracle]$
2. Use RMAN to connect to your target database.
[oracle@edrsr10p1 oracle]$ rman
Recovery Manager: Release 10.2.0.1.0 - Production on Tue
Mar 28 10:23:17 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target /
connected to target database (not started)
RMAN>
sequence=9
media recovery complete, elapsed time: 00:00:02
Finished recover at 28-MAR-06
8. Open the database with the RESETLOGS option.
RMAN> alter database open resetlogs;
database opened
9. Back up the current online redo log file and back up all the archived redo log files.
RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
using target database control file instead of recovery
catalog
sql statement: ALTER SYSTEM ARCHIVE LOG CURRENT
RMAN> backup archivelog all;
Starting backup at 10-APR-06
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup
set
input archive log thread=1 sequence=15 recid=53
stamp=587378250
input archive log thread=1 sequence=16 recid=54
stamp=587379659
input archive log thread=1 sequence=17 recid=55
stamp=587379860
input archive log thread=1 sequence=18 recid=56
stamp=587379970
input archive log thread=1 sequence=19 recid=57
stamp=587380091
input archive log thread=1 sequence=20 recid=58
stamp=587380115
input archive log thread=1 sequence=21 recid=59
stamp=587380409
input archive log thread=1 sequence=22 recid=65
stamp=587386310
input archive log thread=1 sequence=23 recid=66
stamp=587386310
input archive log thread=1 sequence=24 recid=67
stamp=587386311
channel ORA_DISK_1: starting piece 1 at 10-APR-06
channel ORA_DISK_1: finished piece 1 at 10-APR-06
piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/
58
2006_04_10/o1_mE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:26
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup
set
input archive log thread=1 sequence=1 recid=68
stamp=587391539
input archive log thread=1 sequence=2 recid=69
stamp=587391580
channel ORA_DISK_1: starting piece 1 at 10-APR-06
channel ORA_DISK_1: finished piece 1 at 10-APR-06
piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/
2006_04_10/o1_mE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:02
Finished backup at 10-APR-06
Starting Control File and SPFILE Autobackup at 10-APR-06
piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup
/2006_04_10/o1_E
Finished Control File and SPFILE Autobackup at 10-APR-06
60
2)
61
4. Review the information on the Delete All Obsolete: Specify Job Parameters page and
click Submit Job.
5. You receive the Job submission succeeded message. You can click View Job to
monitor 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 image
copies 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> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
no obsolete backups found
62
63
6. The Confirmation message is displayed. You must restart the database instance to enable
Flashback 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
64
65
Solutions for 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 to
remember a significant change so that you can quickly recover to that point in time
without 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.LOCATIONS table.
Answer:
1. Navigate to the Administration page. Select Tables in the Database Objects section.
2. Enter HR in the Schema field and LOCATIONS in the Object Name field. Click Go.
3. Select the HR.LOCATIONS table and click Edit.
66
2)
6.
The Update Message is displayed indicating that the change has been made to the
HR.LOCATIONS table.
7.
4. Enter Before_LOC_Update in the Restore Point Name field. Ensure that Normal Restore
Point is selected. Click OK.
67
3)
@lab_05_02_03_02
SELECT unique (postal_code)
FROM hr.locations
/
POSTAL_CODE
-----------10934
YSW 9T2
2901
26192
M5V 2L7
01307-002
1730
3095
99236
80925
23 rows selected.
4)
@lab_05_02_04_01
UPDATE hr.locations
SET postal_code = 11111
/
23 rows updated.
5)
68
SQL>
SQL>
2
3
@lab_05_02_05_01
SELECT unique (postal_code)
FROM hr.locations
/
POSTAL_CODE
-----------11111
6)
69
6. Select Flashback to a known SCN and paste the SCN that you copied in step 2.
Click Next.
8. Enter HR in the Schema Name field and LOCATIONS in the Table field. Click Search.
70
10. The HR.LOCATIONS table is added to the Tables to Flashback field. Click
11. Accept the default of Cascade: Flashback the selected tables and all dependent tables
on the Dependency Options page. Click Next.
12. On the Perform Object Level Recovery: Review page, confirm the information. Click
Submit.
13. The Confirmation page is displayed. Click OK to return to the Maintenance page.
7)
@lab_05_02_07_01
SELECT unique (postal_code)
FROM hr.locations
/
POSTAL_CODE
-----------10934
YSW 9T2
99236
80925
23 rows selected.
72
2)
@lab_05_03_01_01
SELECT *
FROM hr.locations
WHERE location_id = 1400
/
LOCATION_ID STREET_ADDRESS
POSTAL_CODE
----------- ---------------------------------------- ----------CITY
STATE_PROVINCE
CO
------------------------------ ------------------------- 1400 2014 Jabberwocky Rd
26192
Southlake
Texas
US
Execute the lab_05_03_02_01.sql script to update the POSTAL_CODE column
in the HR.LOCATIONS table, simulating user error.
Answer:
1. Invoke SQL*Plus and execute the lab_05_03_02_01.sql script.
SQL>
SQL>
2
3
4
@lab_05_03_02_01
UPDATE hr.locations
SET postal_code = postal_code + 100
WHERE location_id = 1400
/
1 row updated.
SQL> commit
2 /
Commit complete.
3)
SQL>
SQL>
2
3
4
@lab_05_03_03_01
SELECT *
FROM hr.locations
WHERE location_id = 1400
/
LOCATION_ID STREET_ADDRESS
POSTAL_CODE
----------- ---------------------------------------- ----------CITY STATE_PROVINCE
CO
------------------------------ ------------------------- 1400 2014
Jabberwocky Rd 26292
Southlake Texas
US
4)
Answer:
1. Execute the lab_05_03_04_01.sql script.
SQL>
SQL>
2
3
4
@lab_05_03_04_01
UPDATE hr.locations
SET postal_code = postal_code + 100
WHERE location_id = 1400
/
1 row updated.
SQL> commit
2 /
Commit complete.
5)
Use Enterprise Manager to perform Flashback Versions Query to correct the user
errors.
Answer:
1. Navigate to the Administration page.
2. Select Tables in the Database Objects section.
3. Enter HR in the Schema Name field and LOCATIONS in the Table field. Click Go.
74
4. Select the HR.LOCATIONS table. Select Flashback Versions Query in the Actions
menu. 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 where location_id = 1400 in the Bind the Row Value field. Click Next
75
9. Accept the default of Cascade: Flashback the selected tables and all dependent tables. Click
Next.
10. Review the information. Click Submit.
76
Return to your SQL*Plus session. Query the HR.LOCATIONS table to confirm the
Flashback operation.
Answer:
1. Execute the lab_05_03_06_01.sql script to query the HR.LOCATIONS table.
SQL>
SQL>
2
3
4
@lab_05_03_06_01
SELECT *
FROM hr.locations
WHERE location_id = 1400
/
LOCATION_ID STREET_ADDRESS
POSTAL_CODE
----------- ---------------------------------------- ----------CITY
STATE_PROVINCE
CO
------------------------------ ------------------------- 1400 2014 Jabberwocky Rd
26192
Southlake
Texas
US
77
78
3)
@lab_05_04_03_01
SELECT count(*)
FROM hr.job_history
/
COUNT(*)
---------10
4)
5)
79
@lab_05_04_05_01
SELECT count(*)
FROM hr.job_history
/
COUNT(*)
---------0
6)
81
19. The The database has been opened successfully message is displayed. Click OK.
7)
SQL>
SQL>
2
3
@query_job_hist
SELECT count(*)
FROM hr.job_history
/
COUNT(*)
---------10
83
84
2)
Use Oracle Net Manager to create an entry called AUXDB in the tnsnames.ora file.
Answer:
1. Open a terminal window and enter netmgr at the operating system prompt.
[oracle@edrsr10p1 oracle]$ netmgr
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.
85
5. Enter auxdb in the Net Service Name field and click Next.
86
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 tnsnames.ora file in the
/u01/app/oracle/product/10.2.0/db_1/network/admin directory.
AUXDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
edrsr10p1.us.oracle.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = aux.oracle.com)
)
3)
audit_file_dest='/u01/app/oracle/admin/aux/adump'
background_dump_dest='/u01/app/oracle/admin/aux/bdump
control_files='/u01/app/oracle/oradata/aux/control01.c
tl','/u01/app/oracle/oradata/aux/control02.ctl','/u01/
87
app/oracle/oradata/aux/control03.ctl'
db_name='aux'
user_dump_dest='/u01/app/oracle/admin/aux/udump'
Add the following parameters:
DB_FILE_NAME_CONVERT=/u01/app/oracle/oradata/orcl,
/u01/app/oracle/oradata/aux
LOG_FILE_NAME_CONVERT=/u01/app/oracle/oradata/orcl,
/u01/app/oracle/oradata/aux
Remove the lines at the beginning of the file that begin with orcl.__.
Add the comment character, #, to this line:
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
4) Start the auxiliary instance in NOMOUNT mode using the initAUX.ora file.
Answer:
1. Set the ORACLE_SID environment variable to aux.
[oracle@edrsr10p1 oracle]$ ORACLE_SID=aux
[oracle@edrsr10p1 oracle]$ echo $ORACLE_SID
Aux
2. Invoke SQL*Plus and connect as SYSDBA.
[oracle@edrsr10p1 oracle]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 29
11:38:53 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
3. Start the instance in NOMOUNT mode using the initialization parameter file you created in step 2.
SQL> startup nomount pfile='$HOME/auxinstance/initAUX.ora'
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
5)
88
1. Create a server parameter file with the default name of spfileaux.ora from the text
initialization parameter file.
SQL> create spfile from
pfile='$HOME/auxinstance/initAUX.ora';
File created.
2. Exit from SQL*Plus.
6)
7) Start RMAN with a connection to the target database (orcl) and the auxiliary instance.
Answer:
1. Set your ORACLE_SID to aux. Invoke RMAN and connect as SYSDBA.Connect to the target
database.
[oracle@edrsr10p1 oracle]$ ORACLE_SID=aux
[oracle@edrsr10p1 oracle]$ echo $ORACLE_SID
aux
[oracle@edrsr10p1 oracle]$ rman
Recovery Manager: Release 10.2.0.1.0 - Production on Thu
Mar 30 07:34:06 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect auxiliary sys/oracle
connected to auxiliary database: AUX (not mounted)
89
8)
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/aux/redo01.log' )
SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/aux/redo02.log' )
SIZE 50 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/aux/redo03.log' )
SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/aux/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
Switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
released channel: ORA_AUX_SBT_TAPE_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=586438014
filename=/u01/app/oracle/oradata/auf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=586438014
filename=/u01/app/oracle/oradata/auf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=586438014
filename=/u01/app/oracle/oradata/auf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=586438014
filename=/u01/app/oracle/oradata/auf
contents of Memory Script:
{
set until scn 4236965;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 30-MAR-06
channel aux1: starting incremental datafile backupset
restore
channel aux1: specifying datafile(s) to restore from
92
backup set
destination for restore of datafile 00001:
/u01/app/oracle/oradata/aux/system01f
destination for restore of datafile 00002:
/u01/app/oracle/oradata/aux/undotbs0f
destination for restore of datafile 00003:
/u01/app/oracle/oradata/aux/sysaux01f
destination for restore of datafile 00004:
/u01/app/oracle/oradata/aux/users01.f
destination for restore of datafile 00005:
/u01/app/oracle/oradata/aux/example0f
channel aux1: reading from backup piece
/u01/app/oracle/flash_recovery_area/ORCp
channel aux1: restored backup piece 1
piece
handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/
2006_03_28/o1_m4
channel aux1: restore complete, elapsed time: 00:00:16
starting media recovery
archive log thread 1 sequence 1 is already on disk as file
/u01/app/oracle/flasc
archive log thread 1 sequence 2 is already on disk as file
/u01/app/oracle/flasc
archive log
filename=/u01/app/oracle/flash_recovery_area/ORCL/archivel
og/2006_01
archive log
filename=/u01/app/oracle/flash_recovery_area/ORCL/archivel
og/2006_02
media recovery complete, elapsed time: 00:00:05
Finished recover at 10-APR-06
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area
285212672 bytes
Fixed Size
Variable Size
Database Buffers
1218992 bytes
92276304 bytes
188743680 bytes
93
Redo Buffers
2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUX"
RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/aux/redo01.log' )
SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/aux/redo02.log' )
SIZE 50 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/aux/redo03.log' )
SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/aux/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/aux/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/undotbs01.dbf";
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/sysaux01.dbf";
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/users01.dbf";
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/example01.dbf";
catalog clone datafilecopy
"/u01/app/oracle/oradata/aux/example02.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to
/u01/app/oracle/oradata/aux/temp01.dbf in control fe
cataloged datafile copy
datafile copy
filename=/u01/app/oracle/oradata/aux/undotbs01.dbf recid=1
stamp=8
cataloged datafile copy
datafile copy
94
filename=/u01/app/oracle/oradata/aux/sysaux01.dbf recid=2
stamp=59
cataloged datafile copy
datafile copy
filename=/u01/app/oracle/oradata/aux/users01.dbf recid=3
stamp=589
cataloged datafile copy
datafile copy
filename=/u01/app/oracle/oradata/aux/example01.dbf recid=4
stamp=9
cataloged datafile copy
datafile copy
filename=/u01/app/oracle/oradata/aux/example02.dbf recid=5
stamp=9
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=587391888
filename=/u01/app/oracle/oradata/auf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=587391889
filename=/u01/app/oracle/oradata/auf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=587391889
filename=/u01/app/oracle/oradata/auf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=587391889
filename=/u01/app/oracle/oradata/auf
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=587391889
filename=/u01/app/oracle/oradata/auf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 10-APR-06
2. After the DUPLICATE DATABASE operation completes, exit from RMAN.
9)
Use SQL*Plus to log in to your AUX database and execute a query against the HR.REGIONS table.
Answer:
1. Verify that ORACLE_SID is set to aux.
95
2. Log in to SQL*Plus as SYSDBA and execute a query against the HR.REGIONS table.
SQL> select * from hr.regions;
REGION_ID REGION_NAME
---------- ------------------------1 Europe
2 Americas
3 Asia
4 Middle East and Africa
10) Now that you have completed the test recovery by creating a duplicate database, shutdown the aux
instance.
Answer:
1. Connect as SYSDBA and execute the SHUTDOWN IMMEDIATE command.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
96
97
. . exported "HR"."DEPARTMENTS"
6.632 KB
27 rows
. . exported "HR"."EMPLOYEES"
15.76 KB
107 rows
. . exported "HR"."JOBS"
6.609 KB
19 rows
. . exported "HR"."JOB_HISTORY"
6.585 KB
10 rows
. . exported "HR"."LOCATIONS"
7.710 KB
23 rows
. . exported "HR"."REGIONS"
5.289 KB
4 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully
loaded/unloaded
**********************************************************
********************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
/u01/app/oracle/product/10.2.0/db_1/rdbms/log/hrexp.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed
at 13:03:44
2)
3)
100
. . imported "HRTEST"."EMPLOYEES"
15.76 KB 107 rows
. . imported "HRTEST"."JOBS"
6.609 KB 19 rows
. . imported "HRTEST"."JOB_HISTORY"
6.585 KB 10 rows
Processing object type
SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type
SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type
SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type
SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/VIEW/VIEW
ORA-39082: Object type VIEW:"HRTEST"."EMP_DETAILS_VIEW"
created with compilatios
Processing object type
SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
ORA-39083: Object type REF_CONSTRAINT failed to create
with error:
ORA-00942: table or view does not exist
Failing sql is:
ALTER TABLE "HRTEST"."DEPARTMENTS" ADD CONSTRAINT
"DEPT_LOC_FK" FOREIGN KEY ("LE
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
Processing object type
SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 3
error(s) at 07:08:54
4)
5)
6)
7)
8)
@lab_07_01_08_01
update hrtest.employees
set salary = salary * 1.25
where department_id = 60
/
5 rows updated.
SQL> select employee_id, last_name, salary
2 from hrtest.employees
3 where department_id = 60
4 /
EMPLOYEE_ID LAST_NAME
SALARY
----------- ------------------------- ---------103 Hunold
11250
104 Ernst
7500
105 Austin
6000
106 Pataballa
6000
107 Lorentz
5250
103
9)
You now want to perform TSPITR for the HRTEST tablespace to return it to the state
prior to the updates. Execute the lab_07_01_09_01.sql script to determine
whether there are any dependencies that will prevent the TSPITR operation.
Answer:
1. Execute the lab_07_01_09_01.sql script.
SQL>
SQL>
2
3
4
5
6
7
8
9
@lab_07_01_09_01
SELECT obj1_owner, obj1_name, obj1_type, ts1_name,
obj2_owner, obj2_name, obj2_type, ts2_name,
constraint_name, reason
FROM SYS.TS_PITR_CHECK
WHERE (TS1_NAME IN ('HRTEST')
AND TS2_NAME NOT IN ('HRTEST'))
OR (TS1_NAME NOT IN ('HRTEST')
AND TS2_NAME IN ('HRTEST'))
/
no rows selected
You can use Enterprise Manager Database Control or RMAN command line to
perform tablespace point-in-time recovery.
Answer:
The answer presents the solution using Enterprise Manager Database Control.
If you want to use RMAN command line, refer to the course notes for detailed
information and execute the RECOVER TABLESPACE command as follows:
RECOVER TABLESPACE hrtest UNTIL SCN <scn>
AUXILIARY DESTINATION /u01/app/oracle/oradata/tspitr;
1. Invoke Enterprise Manager Database Control and log in as SYS/ORACLE as SYSDBA.
2. Select the Maintenance page.
3. Select Perform Recovery in the Backup/Recovery section.
4. Select Tablespaces in the Object Level Recovery section. The page refreshes. Accept the
default selection Recover to current time or a previous point-in-time. Click Perform
Object Level Recovery.
104
5. Select Recover to a prior point-in-time and specify the SCN you recorded earlier. Click
Next.
105
106
9. Accept No. Restore the files to the default location. On the Perform Object Level Recovery:
Rename page. Click Next.
107
12)
13)
LOCATIONS
TABLE
110
EXAMPLE
HRTEST
DEPARTMENTS
TABLE
HRTEST
DEPT_NAME_NN
constraint between tables not contained in recovery set
15)
If you wanted to complete the tablespace point-in-time recovery for the HRTEST
tablespace now, what would you need to do?
Note: You will not perform another tablespace point-in-recovery in this practice.
Answer:
You would need to disable the DEPT_LOC_ID_FK constraint that was added to your
HRTEST.DEPARTMENTS table or you would need to add the tablespace that
contains the HR.LOCATIONS table to your recovery set.
111
112
Solutions for Practice 8-1: Create the Recovery Catalog and Register the Database
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 appropriate
recovery catalog owner name (if you are using PC01, connect as RCUSER01) using
RMAN. Create the recovery catalog in your assigned tablespace. (If you are using
PC01, your assigned tablespace is RCTS01.) The service name is RCDB.
Answer: This example uses RCUSER10 as the username and password. Your
assigned username and password may differ from this example.
[oracle@edrsr10p1 oracle]$ rman catalog
rcuser10/rcuser10@rcdb
Recovery Manager: Release 10.2.0.1.0 - Production on Thu
Mar 16 13:58:52 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to recovery catalog database
RMAN> create catalog
recovery catalog created
RMAN> exit
Recovery Manager complete.
2)
Using RMAN, connect to your target database and the recovery catalog database.
Answer:
[oracle@edrsr10p1 oracle]$ rman target / catalog
rcuser10/rcuser10@rcdb
Recovery Manager: Release 10.2.0.1.0 - Production on Thu
Mar 16 14:22:04 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1090770270)
connected to recovery catalog database
RMAN>
3)
Using RMAN, execute the command to resynchronize the control file and recovery
113
Register the target database in the recovery catalog. You can use RMAN commandline
or Enterprise Manager for this step.
Answer: Use RMAN command-line OR Enterprise Manager Database Control.
1. Using RMAN:
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>
2. Using Enterprise Manager:
Select Recovery Catalog Settings on the Maintenance Page. Select Add Recovery
Catalog on the Recovery Catalog Settings page.
114
The Add Recovery Catalog: Database page is displayed. On this page, enter the
information requested for the recovery catalog database. Click Next.
Review the information on the Add Recovery Catalog: Review page and click
Finish.
The Processing: Configure Catalog page is displayed. After processing completes,
you are returned to the Recovery Catalog Settings page. Select Use Recovery
Catalog and click OK.
115
116
5)
6)
Use the PRINT command to query the recovery catalog and verify the creation of
your whole_backup script.
RMAN> PRINT SCRIPT whole_backup;
printing stored script: whole_backup
{BACKUP DATABASE;
}
RMAN>
7)
In preparation for later practices, use RMAN to unregister your database from the
recovery catalog.
Answer:
1. Connect to your target database and the recovery catalog.
2. Execute the UNREGISTER DATABASE command.
RMAN> unregister database;
database name is "ORCL" and DBID is 1090770270
Do you really want to unregister the database (enter YES
or NO)? yes
database unregistered from the recovery catalog
117
118
Solutions for Practice 9-1: Use SQL to Monitor the Progress of RMAN Backups
1)
Deleted 18 objects
RMAN>
119
2)
Open a second terminal window. Change to the labs directory. Invoke SQL*Plus
and connect as SYSDBA. You will use this second session to monitor a database
backup.
3)
Return to your first terminal window. In your RMAN session, begin a whole database
backup.
Answer:
1. Execute the RMAN BACKUP DATABASE command.
RMAN> backup database;
Starting backup at 17-APR-06
released channel: ORA_SBT_TAPE_1
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001
name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003
name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005
name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002
name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004
name=/u01/app/oracle/oradata/orcl/users01.dbf
input datafile fno=00007
name=/u01/app/oracle/oradata/orcl/hrtest01.dbf
input datafile fno=00006
name=/u01/app/oracle/oradata/orcl/example02.dbf
channel ORA_DISK_1: starting piece 1 at 17-APR-06
4)
Use your SQL*Plus session to monitor the progress of the whole database backup by
querying the V$SESSION_LONGOPS view. By using this view you can determine
whether the backup is progressing normally or hanging. If the backup is progressing
normally, the TIME_REMAINING column should be decreasing. Execute the
lab_09_01_04_01.sql script to query V$SESSION_LONGOPS.
Answer:
121
6. You can view additional information by clicking the links in the Logs section.
122
4. Select Full Backup in the Backup Type section. Select Online Backup in the Backup Mode
section. Deselect Also back up all archived logs on disk in the Advanced section. Select
Delete obsolete backups in the Advanced section. Click Next.
5. On the Schedule Customized Backup: Settings page, select Disk. Click Next.
6. Accept the default values on the Schedule Customized Backup: Schedule page. Click Next.
7. Click Submit Job.
123
124
10. You can view detailed information about each job step. Click the Job Run link to return
to the Job page.
125