ITPub博客

首页 > Linux操作系统 > Linux操作系统 > rman完全恢复与不完全恢复

rman完全恢复与不完全恢复

原创 Linux操作系统 作者:gaiguoxiang 时间:2012-05-20 13:29:30 0 删除 编辑

------------查看数据-----------------

SQL> select * from gx;

NAME
----------
guoxiang
ggx

-------------删除数据---------------
SQL> delete gx;

2 rows deleted.

SQL> select * from gx;

no rows selected

-------------关闭数据库--------------
SQL> shutdown immediate;
Database closed.
Database dismounted.

ORACLE instance shut down.

---------------使用rman恢复数据库时需要把数据库启动到mount状态---------------

SQL> startup mount;
ORACLE instance started.

Total System Global Area 159383552 bytes
Fixed Size 1218268 bytes
Variable Size 79694116 bytes
Database Buffers 75497472 bytes
Redo Buffers 2973696 bytes
Database mounted.

--------------------------修复数据库-------------------------

RMAN> restore database;

Starting restore at 24-JUL-2011 09:16:14
using target database control file instead of recovery catalog
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 /u01/oracle/oradata/orcldb1/system01.dbf
restoring datafile 00005 to /u01/oracle/oradata/orcldb1/ggx1
channel ORA_DISK_1: reading from backup piece /home/oracle/ggx2/FULLBAK_ORCLDB1_20110723_530_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/ggx2/FULLBAK_ORCLDB1_20110723_530_1 tag=TAG20110723T225510
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/oracle/oradata/orcldb1/undotbs01.dbf
restoring datafile 00003 to /u01/oracle/oradata/orcldb1/sysaux01.dbf
restoring datafile 00004 to /u01/oracle/oradata/orcldb1/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/ggx2/FULLBAK_ORCLDB1_20110723_531_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/ggx2/FULLBAK_ORCLDB1_20110723_531_1 tag=TAG20110723T225510
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 24-JUL-2011 09:17:26

---------------------------------做完全恢复---------------------------------

recover database;

恢复完成。

---------------------------------不完全恢复。------在修复数据库后直接恢复到一个时间点------------

需要设置一个时间格式:

需要注意''yyyy-mm-dd hh24:mi:ss'' 中的不是双引号,而是连个单引号。

RMAN> run { sql "alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";}

sql statement: alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''

-------------------------------恢复一个时间点---------------------------------

RMAN> recover database until time '2011-07-23 23:50:00';

Starting recover at 24-JUL-2011 09:27:23
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 4 is already on disk as file /u01/oracle/archive/1_4_757291390.dbf
archive log thread 1 sequence 5 is already on disk as file /u01/oracle/archive/1_5_757291390.dbf
archive log thread 1 sequence 6 is already on disk as file /u01/oracle/archive/1_6_757291390.dbf
archive log thread 1 sequence 7 is already on disk as file /u01/oracle/archive/1_7_757291390.dbf
archive log filename=/u01/oracle/archive/1_4_757291390.dbf thread=1 sequence=4
archive log filename=/u01/oracle/archive/1_5_757291390.dbf thread=1 sequence=5
media recovery complete, elapsed time: 00:00:05
Finished recover at 24-JUL-2011 09:27:31

-----------------------------------打开数据库-----------------------------------
SQL> alter database open resetlogs;

Database altered.

恢复完成。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25517773/viewspace-730292/,如需转载,请注明出处,否则将追究法律责任。

下一篇: swap修改
请登录后发表评论 登录
全部评论

注册时间:2011-06-22

  • 博文量
    41
  • 访问量
    110464