Rman:简单的数据还原
这里罗列下一个简单的Rman数据还原过程。
Rman登录目标库以及恢复目录库:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[oracle@rhel6 ~]$ rman Recovery Manager: Release 12.1.0.1.0 - Production on Mon Oct 26 19:19:51 2015 Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved. RMAN> connect target / connected to target database: ORCL (DBID=1421336293) RMAN> connect catalog system/oracle@orcl; connected to recovery catalog database RMAN> |
继续操作前,SQL*Plus查看下当前的数据库表空间的状态:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
SQL> select tablespace_name,status from dba_tablespaces order by tablespace_name; TABLESPACE_NAME STATUS ------------------------------ --------- RMAN_ME ONLINE SYSAUX ONLINE SYSTEM ONLINE TEMP ONLINE UNDOTBS1 ONLINE USERS ONLINE 6 rows selected. SQL> |
Rman,将users表空间:下线
1 2 3 4 5 6 7 |
RMAN> sql 'alter tablespace users offline'; sql statement: alter tablespace users offline starting full resync of recovery catalog full resync complete RMAN> |
这时候,表空间的状态已经是offline了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
SQL> run 1* select tablespace_name,status from dba_tablespaces order by tablespace_name TABLESPACE_NAME STATUS ------------------------------ --------- RMAN_ME ONLINE SYSAUX ONLINE SYSTEM ONLINE TEMP ONLINE UNDOTBS1 ONLINE USERS OFFLINE 6 rows selected. SQL> |
从Rman的备份集的专有格式中提取需要恢复的目标数据(Restore):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
RMAN> restore tablespace users; Starting restore at 26-OCT-15 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=74 device type=DISK 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 00006 to /u01/app/oracle/oradata/orcl/users01.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_26/o1_mf_nnndf_TAG20151026T004458_c2vphttj_.bkp channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2015_10_26/o1_mf_nnndf_TAG20151026T004458_c2vphttj_.bkp tag=TAG20151026T004458 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 26-OCT-15 RMAN> |
还原目标数据(recover):
1 2 3 4 5 6 7 8 9 10 11 |
RMAN> recover tablespace users; Starting recover at 26-OCT-15 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 26-OCT-15 RMAN> |
重新让users表空间:上线
1 2 3 4 5 6 7 |
RMAN> sql 'alter tablespace users online'; sql statement: alter tablespace users online starting full resync of recovery catalog full resync complete RMAN> |
再看一下表空间的状态(SQL*Plus):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
SQL> run 1* select tablespace_name,status from dba_tablespaces order by tablespace_name TABLESPACE_NAME STATUS ------------------------------ --------- RMAN_ME ONLINE SYSAUX ONLINE SYSTEM ONLINE TEMP ONLINE UNDOTBS1 ONLINE USERS ONLINE 6 rows selected. SQL> |
————————————————————————————
Done。