rman 非归档模式下停库备份与恢复

一 非归档模式

SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 31
Current log sequence 33

二 关闭数据库,挂载数据库进行一致性备份

RMAN> shutdown immediate;
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area 1252663296 bytes

Fixed Size 2212936 bytes
Variable Size 805309368 bytes
Database Buffers 436207616 bytes
Redo Buffers 8933376 bytes

RMAN> run{
2> allocate channel c1 type disk format '/home/oracle/rman/chen_%U';
3> backup database include current controlfile;
4> }

allocated channel: c1
channel c1: SID=133 device type=DISK

Starting backup at 07-JUL-15
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/ogg1/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ogg1/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ogg1/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ogg1/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ogg1/users01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/ogg1/chen01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/ogg1/test01.dbf
channel c1: starting piece 1 at 07-JUL-15
channel c1: finished piece 1 at 07-JUL-15
piece handle=/home/oracle/rman/chen_0gqbf543_1_1 tag=TAG20150707T153219 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:35
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 07-JUL-15
channel c1: finished piece 1 at 07-JUL-15
piece handle=/home/oracle/rman/chen_0hqbf557_1_1 tag=TAG20150707T153219 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 07-JUL-15

Starting Control File and SPFILE Autobackup at 07-JUL-15
piece handle=/u01/app/oracle/flash_recovery_area/OGG1/autobackup/2015_07_07/o1_mf_s_884446096_bsq059ok_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-JUL-15
released channel: c1

三 备份结束后打开数据库,生成测试表,插入数据

RMAN> startup

database is already started
database opened

SQL> conn chen/chen
Connected.

SQL> insert into t1 values(20000);
SQL> commit;

SQL> select * from t1;
ID


10000
10000
20000

四 剪切数据库文件到其他目录,模拟数据库故障

SQL> shutdown immediate

[oracle@ogg1 ~]$ cd /u01/app/oracle/oradata/ogg1/

[oracle@ogg1 ogg1]$ cd ..

[oracle@ogg1 oradata]$ mv ogg1/ /home/oracle/

五 启动数据库失败

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1252663296 bytes
Fixed Size 2212936 bytes
Variable Size 805309368 bytes
Database Buffers 436207616 bytes
Redo Buffers 8933376 bytes

数据库挂载失败(找不到控制文件)

SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info

查看警告日志文件

[oracle@ogg1 ~]$ vim /u01/app/oracle/diag/rdbms/ogg1/ogg1/trace/alert_ogg1.log
Tue Jul 07 15:41:46 2015
alter database mount
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/ogg1/control01.ctl'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Tue Jul 07 15:41:46 2015
Checker run found 1 new persistent data failures
ORA-205 signalled during: alter database mount...

六 关闭数据库,rman恢复

[oracle@ogg1 ~]$ cd /u01/app/oracle/oradata/

[oracle@ogg1 oradata]$ mkdir ogg1

RMAN> shutdown immediate

Oracle instance shut down

RMAN> startup nomount

connected to target database (not started)
Oracle instance started

Total System Global Area 1252663296 bytes

Fixed Size 2212936 bytes
Variable Size 805309368 bytes
Database Buffers 436207616 bytes
Redo Buffers 8933376 bytes

先将控制文件恢复出来

RMAN> restore controlfile from autobackup;

Starting restore at 07-JUL-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK

recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: OGG1
channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/flash_recovery_area/OGG1/autobackup/2015_07_07/o1_mf_s_884446096_bsq059ok_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/flash_recovery_area/OGG1/autobackup/2015_07_07/o1_mf_s_884446096_bsq059ok_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/ogg1/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/ogg1/control02.ctl
Finished restore at 07-JUL-15

挂载数据库,进行数据库恢复

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> run{
2> restore database;
3> recover database;
4> }

......
starting media recovery
RMAN-08187: WARNING: media recovery until SCN 1590816 complete
Finished recover at 07-JUL-15

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 07/07/2015 15:56:43
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open resetlogs;

database opened

SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 1

SQL> conn chen/chen
Connected.

恢复成功,丢失一部分数据

SQL> select * from t1;

ID

----------
10000
10000

转载自chenoracle

最后修改:2022 年 02 月 27 日
如果觉得我的文章对你有用,请随意赞赏