0% found this document useful (0 votes)
23 views

Lab-03-Using RMAN

Uploaded by

Arif Ahmad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Lab-03-Using RMAN

Uploaded by

Arif Ahmad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Oracle Internal & Oracle Academy Use Only

Practices for Lesson 3: Using


Recovery Manager (RMAN)
Practices for Lesson 3: Overview

Overview
In these practices, you will verify the default backup destination, set the RMAN display data and
time format, verify that control file autobackup is configured, and verify the backup retention
policy.

Oracle Internal & Oracle Academy Use Only

Copyright © 2022, Oracle and/or its affiliates.

32 Practices for Lesson 3: Using Recovery Manager (RMAN)


Practice 3-1: Configuring the Default Backup Destination

Overview
In this practice, you determine the default backup destination setting and create a backup in the
default location.

Timing Estimate
It should take approximately 5 minutes to complete this practice.

Tasks
1. Open a terminal window and run the setup03-01.sh script to prepare the environment for
this practice.

Oracle Internal & Oracle Academy Use Only


$ /home/oracle/labs/admin/setup03-01.sh
...
$ unset NLS_LANG NLS_DATE_FORMAT
$
2. The DB_RECOVERY_FILE_DEST parameter specifies the default location for the fast
recovery area. View the parameter value by logging in to SQL*Plus and using the SHOW
PARAMETER command.
$ sqlplus / as sysdba

SQL> show parameter db_recovery_file_dest

NAME TYPE VALUE


----------------------------------- ----------- ---------------
db_recovery_file_dest string
/u01/app/oracle/fast_recovery_area
db_recovery_file_dest_size big integer 12G

SQL> exit
$
3. Log in to RMAN, execute the BACKUP DATABASE command, and then exit RMAN.
$ rman target "'/ as sysbackup'"

RMAN> BACKUP DATABASE;
Starting backup at 18-JUN-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1

Finished backup at 18-JUN-19

Copyright © 2022, Oracle and/or its affiliates.

Practices for Lesson 3: Using Recovery Manager (RMAN) 33


Finished Control File and SPFILE Autobackup at 18-JUN-19
RMAN> exit
4. Run the cleanup03-01.sh script to reset the environment.
$ /home/oracle/labs/admin/cleanup03-01.sh
$
5. Close the terminal window.

Oracle Internal & Oracle Academy Use Only

Copyright © 2022, Oracle and/or its affiliates.

34 Practices for Lesson 3: Using Recovery Manager (RMAN)


Practice 3-2: Setting the Date and Time Format for RMAN

Overview
In this practice, you set the date/time format that RMAN uses for displaying time stamps. The
default date format does not include the time of day information. You will be performing several
backups and recoveries in the same day, and in some cases, you will need to determine which
backup to use.

Assumptions
You completed Practice 3-1.

Timing Estimate

Oracle Internal & Oracle Academy Use Only


It should take approximately 10 minutes to complete this practice.

Tasks
1. (Catchup Step) If you skipped the Practice 3-1, run the prep03-02.sh script and then
proceed to step 3, otherwise proceed to step 2.
$ /home/oracle/labs/admin/prep03-02.sh
...
$
2. Open a terminal window to run the setup03-02.sh script to prepare the environment for
this practice.
$ /home/oracle/labs/admin/setup03-02.sh
$
3. Open a new terminal window to set the NLS_LANG and NLS_DATE_FORMAT variables so
that RMAN includes time information in any time stamp values.
Use the editor of your choice (vi, gedit) and add the following two lines to the end of the
~oracle/.bashrc file:
export NLS_LANG=american_america.al32utf8
export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss"
a. In a terminal window, invoke your editor. This example uses the gedit editor.
$ gedit ~oracle/.bashrc
b. Copy and paste by using the mouse buttons and icons in the editor, save your changes,
and then close the gedit window.
Note: If you are not copying and pasting the variables, double-check that the
NLS_LANG value is written correctly with a letter “l”, not a digit “1”.
c. View the modified file by using the cat command and apply the new settings.
$ cat ~oracle/.bashrc
# .bashrc

Copyright © 2022, Oracle and/or its affiliates.

Practices for Lesson 3: Using Recovery Manager (RMAN) 35



export NLS_LANG=american_america.al32utf8
export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss"

$ . /home/oracle/.bashrc
$
4. Verify the settings by starting RMAN and listing the backups in the recovery catalog or from
the control file.
a. Log in to RMAN.
$ rman target "'/ as sysbackup'"

connected to target database: ORCLCDB (DBID=2778750799)

Oracle Internal & Oracle Academy Use Only


RMAN>
b. List the backups and note the time stamp format. The output shows the most recent
backups.
RMAN> list backup;
using target database control file instead of recovery catalog

List of Backup Sets


===================

BS Key Type LV Size Device Type Elapsed Time Completion


Time
------- ---- -- ---------- ----------- ------------ ------------
-------
1 Full 1.37G DISK 00:00:11 2019-06-
18:17:21:59
BP Key: 1 Status: AVAILABLE Compressed: NO Tag:
TAG20190618T172148
Piece Name:
/u01/app/oracle/fast_recovery_area/ORCLCDB/backupset/2019_06_18/
o1_mf_nnndf_TAG20190618T172148_gjl7fdf3_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse
Name
---- -- ---- ---------- ------------------- ----------- ------
----
1 Full 3133091 2019-06-18:17:21:48 NO
/u01/app/oracle/oradata/ORCLCDB/system01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion
Time

Copyright © 2022, Oracle and/or its affiliates.

36 Practices for Lesson 3: Using Recovery Manager (RMAN)


------- ---- -- ---------- ----------- ------------ ------------
-------
5 Full 17.95M DISK 00:00:01 2019-06-
18:17:22:59
BP Key: 5 Status: AVAILABLE Compressed: NO Tag:
TAG20190618T172258
Piece Name:
/u01/app/oracle/fast_recovery_area/ORCLCDB/autobackup/2019_06_18
/o1_mf_s_1011288178_gjl7hm7n_.bkp
SPFILE Included: Modification time: 2019-06-18:14:56:57
SPFILE db_unique_name: ORCLCDB
Control File Included: Ckp SCN: 3133134 Ckp time: 2019-
06-18:17:22:58

Oracle Internal & Oracle Academy Use Only


RMAN>
5. Tip: Because the output of the RMAN commands can be quite long, consider using the
RMAN SPOOL LOG TO <file> command to direct the output to your specified file.
a. Optionally, enter SPOOL LOG TO /tmp/test.log in your RMAN window.
b. Repeat the previous LIST BACKUP command.
c. Note that the output is not displayed in your window. In a second terminal window,
enter cat /tmp/test.log to view the output.
d. Use SPOOL LOG OFF to stop directing output to the file.
6. Close all terminal windows.

Copyright © 2022, Oracle and/or its affiliates.

Practices for Lesson 3: Using Recovery Manager (RMAN) 37


Practice 3-3: Configuring RMAN Settings

Overview
In this practice, you configure or confirm RMAN settings for the following tasks:
 To back up the control file and server parameter file (SPFILE) each time RMAN takes a
backup of anything in the orclcdb database
 To ensure that one redundant backup is kept
Then you perform a tablespace backup to verify these settings.

Timing Estimate
It should take approximately 5 minutes to complete this practice.

Oracle Internal & Oracle Academy Use Only


Tasks
1. Open a terminal window and log in to RMAN. Verify that control file autobackup is enabled.
$ rman target "'/ as sysbackup'"

RMAN> show controlfile autobackup;

RMAN configuration parameters for database with db_unique_name


ORCLCDB are:
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default

RMAN>
2. View the current retention policy setting to verify that it is set to 1.
RMAN> show retention policy;

RMAN configuration parameters for database with db_unique_name


ORCLCDB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

RMAN>
3. Determine which data file belongs to the USERS tablespace in ORCLPDB1.
RMAN> REPORT SCHEMA;
Report of database schema for database with db_unique_name
ORCLCDB

List of Permanent Datafiles


===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ---------------------

Copyright © 2022, Oracle and/or its affiliates.

38 Practices for Lesson 3: Using Recovery Manager (RMAN)


1 920 SYSTEM YES
/u01/app/oracle/oradata/ORCLCDB/system01.dbf
3 850 SYSAUX NO
/u01/app/oracle/oradata/ORCLCDB/sysaux01.dbf

12 342 ORCLPDB1:USERS NO
/u01/app/oracle/oradata/ORCLCDB/orclpdb1/users01.dbf

4 36 ORCLPDB2:TEMP 32767
/u01/app/oracle/oradata/ORCLCDB/orclpdb2/temp01.dbf

RMAN>
4. Back up the USERS tablespace in both the CDB and ORCLPDB1.

Oracle Internal & Oracle Academy Use Only


RMAN> BACKUP TABLESPACE users, ORCLPDB1:USERS;
Starting backup at 2019-06-18:18:04:29
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00012
name=/u01/app/oracle/oradata/ORCLCDB/orclpdb1/users01.dbf

Finished backup at 2019-06-18:18:04:31

Starting Control File and SPFILE Autobackup at 2019-06-


18:18:04:31
piece
handle=/u01/app/oracle/fast_recovery_area/ORCLCDB/autobackup/201
9_06_18/o1_mf_s_1011290671_gjl9xhwf_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2019-06-
18:18:04:32

RMAN>
5. Exit RMAN.
RMAN> exit

Recovery Manager complete.


$
6. Close the terminal window.

Copyright © 2022, Oracle and/or its affiliates.

Practices for Lesson 3: Using Recovery Manager (RMAN) 39


Oracle Internal & Oracle Academy Use Only

Copyright © 2022, Oracle and/or its affiliates.

40 Practices for Lesson 3: Using Recovery Manager (RMAN)

You might also like