如果自己搞不定可以找诗檀软件专业ORACLE数据库修复团队成员帮您恢复!
诗檀软件专业数据库修复团队
服务热线 : 13764045638 QQ号:47079569 邮箱:[email protected]
本节我们会回顾使用RMAN恢复数据库的例子,我们将讨论从冷备份中对整个数据库恢复,然后讨论从热备份中对表空间恢复的例子。
恢复冷备份
在这个例子中,我们假设备份到NOARCHIVELOG 的数据库由于多媒体故障丢失,这要求对数据库进行完全恢复,下面的例子是这种类型恢复的示例,首先,恢复了控制文件,然后复原了数据库数据文件,最后,使用ALTER DATABASE OPEN RESETLOGS命令打开数据库,这种恢复示例假设数据库处于NOMOUNT状态,确保了实例启动和运行,为节省空间,已经移动一些从RMAN的导出,只留下重要的细节 。
RMAN> run {
allocate channel t1 type disk;
restore controlfile to ‘/ora05/oracle/data/testo82/control01.ctl’;
restore controlfile to ‘/ora05/oracle/data/testo82/control02.ctl’;
restore controlfile to ‘/ora05/oracle/data/testo82/control03.ctl’;
sql “alter database mount”;
restore database;
sql “alter database open resetlogs”;
}
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: t1
RMAN-03022: compiling command: restore
RMAN-03023: executing command: IRESTORE
RMAN-08016: channel t1: starting datafile backupset restore
RMAN-08021: channel t1: restoring controlfile
RMAN-08505: output filename=/ora05/oracle/data/testo82/control01.ctl
RMAN-08505: output filename=/ora05/oracle/data/testo82/control02.ctl
RMAN-08505: output filename=/ora05/oracle/data/testo82/control03.ctl
RMAN-08024: channel t1: restore complete
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: alter database mount
RMAN-03023: executing command: sql
RMAN-03022: compiling command: restore
RMAN-03025: performing implicit partial resync of recovery catalog
RMAN-03023: executing command: IRESTORE
RMAN-08016: channel t1: starting datafile backupset restore
RMAN-08509: destination for restore of datafile 1:
/ora01/oracle/admin/testo82/link/testo82_system_01.dbf
RMAN-08019: channel t1: restoring datafile 2
RMAN-08509: destination for restore of datafile 2:
/ora01/oracle/admin/testo82/link/new_tbs.dbf
RMAN-08023: channel t1: restored backup piece 1
RMAN-08511: piece handle=
/tmp/backup_dir/db_t378856462_s16_p1 params=NULL
RMAN-08024: channel t1: restore complete
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: alter database open resetlogs
RMAN-03023: executing command: sql
RMAN-08031: released channel: t1
表空间和数据文件的恢复
RMAN使得你可以恢复表空间和数据文件备份,例如,假设你尝试在一个表空间中创建一个名为NEW_TBS的表,收到下列错误:
SQL> create table robert
2 (test number)
3 tablespace new_tbs;
create table robert
*
ERROR at line 1:
ORA-00376: file 2 cannot be read at this time
ORA-01110: data file 2: ‘/ora01/oracle/admin/testo82/link/new_tbs.dbf’
好像 NEW_TBS 表空间已经丢失了一个数据文件 (事实上, 该数据文件是唯一一个指定到这个表空间的),在下面的例子中,你将恢复整个表空间而不是单个数据文件 (尽管你可以很容易地恢复数据文件),要再次注意一些RMAN的输出已经消除。
run {
allocate channel t1 type disk;
restore tablespace new_tbs;
recover tablespace new_tbs;
sql “alter tablespace new_tbs online”;
}
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: t1
RMAN-03022: compiling command: restore
RMAN-03023: executing command: IRESTORE
RMAN-08509: destination for restore of datafile 2:
/ora01/oracle/admin/testo82/link/new_tbs.dbf
RMAN-03023: executing command: partial resync
RMAN-08003: starting partial resync of recovery catalog
RMAN-08005: partial resync complete
RMAN-03022: compiling command: recover
RMAN-08054: starting media recovery
RMAN-08055: media recovery complete
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: alter tablespace new_tbs online
RMAN-03023: executing command: sql
RMAN-08031: released channel: t1
现在,让我们再次尝试创建表,观察发生什么,该操作的结果显示如下:
SQL> CREATE TABLE robert
2 (test NUMBER)
3 TABLESPACE new_tbs;
Table created.
在这个例子中,RMAN实际上给我们提供了很多从问题中恢复的选择,不是复原和恢复表空间,你可能只是恢复了破坏的数据文件,进行这种类型的恢复的例子如下:
run {
allocate channel t1 type disk;
restore datafile 2;
recover tablespace new_tbs;
sql “alter tablespace new_tbs online”;
}
最后, 如果不止一个数据文件已损坏,你可能会选择下面例子中的恢复形式:
run {
allocate channel t1 type disk;
restore datafile 2;
recover datafile 2;
sql “alter tablespace new_tbs online”;
}
上述所有证明的恢复操作会导致同样的行为: 数据库的恢复。注意你可以在数据库启动和运行时进行恢复操作,因此你的用户可能不知道出现了问题 。
Leave a Reply