Rman recovery test of data files

Source: Internet
Author: User

Here is a test of rman backup and recovery:

The database is in the mount status and cannot be connected by other users:
SQL> select status from v $ instance;

STATUS
------------
MOUNTED

SQL> conn scott/Oracle
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress

Warning: You are no longer connected to ORACLE.
SQL>

Okay. Switch to the sys user to test:

-----
Take a look at the parameters:
RMAN> startup mount;

Oracle instance started
Database mounted

Total System Global Area 335544320 bytes

Fixed Size 1219280 bytes
Variable Size 83887408 bytes
Database Buffers 247463936 bytes
Redo Buffers 2973696 bytes


Enable rman auobackup on and set the path. Experiment:
[Oracle @ aoracle rman] $ ls-lrt
Total 0
[Oracle @ aoracle rman] $ pwd
/U02/rman
[Oracle @ aoracle rman] $

RMAN> show all;

RMAN configuration parameters are:
Configure retention policy to redundancy 1; # default
Configure backup optimization off; # default
Configure default device type to disk; # default
Configure controlfile autobackup on;
Configure controlfile autobackup format for device type disk to '/u02/rman/ctl _ % F ';
Configure device type disk parallelism 1 backup type to backupset; # default
Configure datafile backup copies for device type disk to 1; # default
Configure archivelog backup copies for device type disk to 1; # default
Configure maxsetsize to unlimited; # default
Configure encryption for database off; # default
Configure encryption algorithm 'aes128 '; # default
Configure archivelog deletion policy to none; # default
Configure snapshot controlfile name to '/u01/pp/oracle/product/10.2/db_1/dbs/snapcf_ezhou.f'; # default

Okay. perform the following experiment:

Back up a database:

RMAN> backup database format'/u02/rman/ezhou _ % U. bak ';

Starting backup at 16---11
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: sid = 152 devtype = DISK
Channel ORA_DISK_1: starting full datafile backupset
Channel ORA_DISK_1: specifying datafile (s) in backupset
Input datafile fno = 00001 name =/u02/ezhou/system01.dbf
Input datafile fno = 00002 name =/u02/ezhou/undotbs01.dbf
Input datafile fno = 00003 name =/u02/ezhou/sysaux01.dbf
Input datafile fno = 00005 name =/u02/ezhou/example01.dbf
Input datafile fno = 00004 name =/u02/ezhou/users01.dbf
Input datafile fno = 00006 name =/u02/ezhou/example02.dbf
Channel ORA_DISK_1: starting piece 1 at 16-OCT-11
Channel ORA_DISK_1: finished piece 1 at 16-OCT-11
Piece handle =/u02/rman/ezhou_09mp76h8_00001.bak tag = TAG20111016T021256 comment = NONE
Channel ORA_DISK_1: backup set complete, elapsed time: 00:02:20
Finished backup at 16-OCT-11

Starting Control File and SPFILE Autobackup at 16-OCT-11
Piece handle =/u02/rman/ctl_c-4046377924-20111016-00 comment = NONE
Finished Control File and SPFILE Autobackup at 16-OCT-11

Take a closer look at log:
A channel is displayed, and the generated file is placed in:
/U02/rman/ezhou_09mp76h8_1_1.bak
/U02/rman/ctl_c-4046377924-20111016-00

The above is the database, and the following is the control file and spfile, which are automatically backed up.
Because the above control file autobackup is on.

Okay. Take a look at the generated file:
[Oracle @ aoracle rman] $ ls-lrt
Total 898088
-Rw-r ----- 1 oracle oinstall 911589376 Oct 16 ezhou_09mp76h8_00001.bak
-Rw-r ----- 1 oracle oinstall 7143424 Oct 16 ctl_c-4046377924-20111016-00

To restore the data file:
Let's take a look at the location of the data file:

RMAN> report schema;

Report of database schema

List of Permanent Datafiles
======================================
File Size (MB) Tablespace RB segs Datafile Name
---------------------------------------------------------------
1 480 SYSTEM ***/u02/ezhou/system01.dbf
2 285 UNDOTBS1 ***/u02/ezhou/undotbs01.dbf
3 250 SYSAUX ***/u02/ezhou/sysaux01.dbf
4 25 USERS ***/u02/ezhou/users01.dbf
5 100 EXAMPLE ***/u02/ezhou/example01.dbf
6 10 EXAMPLE ***/u02/ezhou/example02.dbf

List of Temporary Files
======================================
File Size (MB) Tablespace Maxsize (MB) Tempfile Name
---------------------------------------------------------------
1 20 TEMP 32767/u02/ezhou/temp01.dbf

[Oracle @ aoracle ezhou] $ ls-lrt
Total 1371388
Drwxr-xr-x 3 oracle oinstall 4096 Sep 28 patch
-Rw-r ----- 1 oracle oinstall 20979712 Oct 15 temp01.dbf
-Rw-r ----- 1 oracle oinstall 52429312 Oct 15 redo01.log
-Rw-r ----- 1 oracle oinstall 52429312 Oct 15 redo02.log
-Rw-r ----- 1 oracle oinstall 26222592 Oct 16 users01.dbf
-Rw-r ----- 1 oracle oinstall 298852352 Oct 16 undotbs01.dbf
-Rw-r ----- 1 oracle oinstall 503324672 Oct 16 system01.dbf
-Rw-r ----- 1 oracle oinstall 262152192 Oct 16 sysaux01.dbf
-Rw-r ----- 1 oracle oinstall 52429312 Oct 16 redo03.log
-Rw-r ----- 1 oracle oinstall 10493952 Oct 16 example02.dbf
-Rw-r ----- 1 oracle oinstall 104865792 Oct 16 example01.dbf
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control03.ctl
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control02.ctl
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control01.ctl
[Oracle @ aoracle ezhou] $ rm-rf *. dbf
[Oracle @ aoracle ezhou] $ ls-lrt
Total 174508
Drwxr-xr-x 3 oracle oinstall 4096 Sep 28 patch
-Rw-r ----- 1 oracle oinstall 52429312 Oct 15 redo01.log
-Rw-r ----- 1 oracle oinstall 52429312 Oct 15 redo02.log
-Rw-r ----- 1 oracle oinstall 52429312 Oct 16 redo03.log
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control03.ctl
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control02.ctl
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control01.ctl

To recover the database:
Check the database status:
SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> select status from v $ instance;
Select status from v $ instance
*
ERROR at line 1:
A ORA-01034: ORACLE not available


SQL> startup;
ORACLE instance started.

Total System Global Area 335544320 bytes
Fixed Size 1219280 bytes
Variable Size 83887408 bytes
Database Buffers 247463936 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1-see DBWR trace file
ORA-01110: data file 1: '/u02/ezhou/system01.dbf'

The database does not have data files:
The current status is mounted:
RMAN> run {
2> restore database;
3> recover database;
4>}

Starting restore at 16---11
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: sid = 155 devtype = DISK

Channel ORA_DISK_1: starting datafile backupset restore
Channel ORA_DISK_1: specifying datafile (s) to restore from backup set
Restoring datafile 00001 to/u02/ezhou/system01.dbf
Restoring datafile 00002 to/u02/ezhou/undotbs01.dbf
Restoring datafile 00003 to/u02/ezhou/sysaux01.dbf
Restoring datafile 00004 to/u02/ezhou/users01.dbf
Restoring datafile 00005 to/u02/ezhou/example01.dbf
Restoring datafile 00006 to/u02/ezhou/example02.dbf
Channel ORA_DISK_1: reading from backup piece/u02/rman/ezhou_09mp76h8_1_1.bak
Channel ORA_DISK_1: restored backup piece 1
Piece handle =/u02/rman/ezhou_09mp76h8_00001.bak tag = TAG20111016T021256
Channel ORA_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 16-OCT-11

Starting recover at 16---11
Using channel ORA_DISK_1

Starting media recovery
Media recovery complete, elapsed time: 00:00:00

Finished recover at 16-OCT-11

Take a look at the data file: recovered:
[Oracle @ aoracle ezhou] $ ls-lrt
Total 1353340
Drwxr-xr-x 3 oracle oinstall 4096 Sep 28 patch
-Rw-r ----- 1 oracle oinstall 52429312 Oct 15 redo01.log
-Rw-r ----- 1 oracle oinstall 52429312 Oct 15 redo02.log
-Rw-r ----- 1 oracle oinstall 52429312 Oct 16 redo03.log
-Rw-r ----- 1 oracle oinstall 10493952 Oct 16 example02.dbf
-Rw-r ----- 1 oracle oinstall 26222592 Oct 16 users01.dbf
-Rw-r ----- 1 oracle oinstall 104865792 Oct 16 example01.dbf
-Rw-r ----- 1 oracle oinstall 262152192 Oct 16 sysaux01.dbf
-Rw-r ----- 1 oracle oinstall 298852352 Oct 16 undotbs01.dbf
-Rw-r ----- 1 oracle oinstall 503324672 Oct 16 system01.dbf
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control03.ctl
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control02.ctl
-Rw-r ----- 1 oracle oinstall 7061504 Oct 16 control01.ctl

Open the database:
SQL> alter database open;

Database altered.

Take a look at the backup records:
BS Key Type LV Size Device Type Elapsed Time Completion Time
-------------------------------------------------------------
8 Full 869.35 m disk 00:02:18 16-OCT-11
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20111016T021256
Piece Name:/u02/rman/ezhou_09mp76h8_00001.bak
List of Datafiles in backup set 8
File LV Type Ckp SCN Ckp Time Name
---------------------------------
1 Full 5483534 16-OCT-11/u02/ezhou/system01.dbf
2 Full 5483534 16-OCT-11/u02/ezhou/undotbs01.dbf
3 Full 5483534 16-OCT-11/u02/ezhou/sysaux01.dbf
4 Full 5483534 16-OCT-11/u02/ezhou/users01.dbf
5 Full 5483534 16-OCT-11/u02/ezhou/example01.dbf
6 Full 5483534 16-OCT-11/u02/ezhou/example02.dbf

-----------

The following describes how to change the date format:
Alter system set nls_date_format = 'yyyy-mm-dd hh24: mi: ss' scope = spfile;

SQL> select sysdate from dual;

SYSDATE
---------
16---11

SQL> show parameter format;

NAME TYPE VALUE
-----------------------------------------------------------------------------
Log_archive_format string % t _ % s _ % r. dbf
Nls_date_format string
Nls_time_format string
Nls_time_tz_format string
Nls_timestamp_format string
Nls_timestamp_tz_format string
Star_transformation_enabled string FALSE
SQL> alter system set nls_date_format = 'yyyy-mm-dd hh24: mi: ss' scope = spfile;

System altered.

SQL> select sysdate from dual;

SYSDATE
---------
16---11

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> select sysdate from dual;
Select sysdate from dual
*
ERROR at line 1:
A ORA-01034: ORACLE not available


SQL> startup nomount;
ORACLE instance started.

Total System Global Area 335544320 bytes
Fixed Size 1219280 bytes
Variable Size 83887408 bytes
Database Buffers 247463936 bytes
Redo Buffers 2973696 bytes
SQL> select sysdate from dual;

SYSDATE
-------------------
2011-10-16 02:56:41

SQL>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.