Restore missing datafile via RMAN

Аль нэг датафайл устсан, гэмтсэн үед rman backup авсан байсан тохиолдолд тухайн файлыг сэргээх боломжтой. Дараах жишээ дээр 4 дугаар бүхий Users датафайлыг хэрхэн сэргээх талаар харуулав.

[[email protected] ~]$ rman target /

RMAN> run {
2> SQL 'ALTER TABLESPACE users OFFLINE IMMEDIATE';
3> RESTORE TABLESPACE users;
4> RECOVER TABLESPACE users;
5> SQL 'ALTER TABLESPACE users ONLINE';
6> }

sql statement: ALTER TABLESPACE users OFFLINE IMMEDIATE

Starting restore at 18-DEC-16
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/DB11G/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DB11G/backupset/2016_12_18/o1_mf_nnndf_TAG20161218T093343_d5csvscs_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DB11G/backupset/2016_12_18/o1_mf_nnndf_TAG20161218T093343_d5csvscs_.bkp tag=TAG20161218T093343
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 18-DEC-16

Starting recover at 18-DEC-16
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 18-DEC-16

sql statement: ALTER TABLESPACE users ONLINE

Дээрх коммандыг ажлуулахаас өмнө 4 дугаартай users01.dbf файлын нэрийг сольсон бөгөөд RMAN комманд уг файлыг нөөцөөс буцаан сэргээсэн.

[[email protected] ~]$ cd /u01/app/oracle/oradata/DB11G
[[email protected] DB11G]$ mv users01.dbf users01.dbf.bak
[[email protected] DB11G]$
[[email protected] DB11G]$
[[email protected] DB11G]$ ls
control01.ctl  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf.bak
redo01.log     redo03.log  system01.dbf  undotbs01.dbf
[[email protected] DB11G]$ ls -la
total 2252068
drwxr-x---. 2 oracle oinstall      4096 Dec 18 10:17 .
drwxr-x---. 3 oracle oinstall      4096 Dec 17 09:52 ..
-rw-r-----. 1 oracle oinstall   9748480 Dec 18 10:17 control01.ctl
-rw-r-----. 1 oracle oinstall  52429312 Dec 18 10:17 redo01.log
-rw-r-----. 1 oracle oinstall  52429312 Dec 18 08:26 redo02.log
-rw-r-----. 1 oracle oinstall  52429312 Dec 18 08:26 redo03.log
-rw-r-----. 1 oracle oinstall 629153792 Dec 18 10:16 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 786440192 Dec 18 10:17 system01.dbf
-rw-r-----. 1 oracle oinstall  61874176 Dec 18 08:32 temp01.dbf
-rw-r-----. 1 oracle oinstall 702554112 Dec 18 10:16 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Dec 18 10:17 users01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Dec 18 10:16 users01.dbf.bak
[[email protected] DB11G]$ rm users01.dbf.bak