Oracle 数据库恢复一、停止ORACLE数据库用oracle用户登录,用sqlplus的sysdba用户登录,执行shutdown immediateoracle@JSBC-SIHUA-DB01:~> sqlplus /nologSQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 6 14:02:45 2012Copyright (c) 1982, 2005, Oracle. All rights reserved.SQL> conn /as sysdbaConnected.SQL> shutdown immediateSQL>quit停止监听oracle@JSBC-SIHUA-DB01:~> lsnrctl stoporacle@JSBC-SIHUA-DB01:~> ps -ef |grep oraroot 4655 4524 0 Nov11 ? 00:00:48 hald-addon-storage: polling /dev/sr0 (every 16 sec) root 42514 42162 0 11:40 pts/0 00:00:00 su - oracleoracle 42515 42514 0 11:40 pts/0 00:00:00 -bashroot 42853 42815 0 12:02 pts/2 00:00:00 su - oracleoracle 42854 42853 0 12:02 pts/2 00:00:00 -bashroot 42924 42889 0 12:03 pts/1 00:00:00 su - oracleoracle 42925 42924 0 12:03 pts/1 00:00:00 -bashoracle 42975 42854 0 12:09 pts/2 00:00:00 ps -eforacle 42976 42854 0 12:09 pts/2 00:00:00 grep ora二、数据库备份#root用户,创建sihua.bak目录JSBC-SIHUA-DB01:/oradata # mkdir sihua.bakJSBC-SIHUA-DB01:/oradata # chown oracle:dba /oradata/sihua.bakJSBC-SIHUA-DB01:/oradata # lltotal 24drwx------ 2 root root 16384 Sep 16 11:53 lost+founddrwxr-x--- 4 oracle dba 4096 Nov 8 14:16 sihuadrwxr-xr-x 2 oracle dba 4096 Nov 28 12:15 sihua.bak#oracle用户JSBC-SIHUA-DB01:/oradata # su - oracleoracle@JSBC-SIHUA-DB01:~> cd /oradataoracle@JSBC-SIHUA-DB01:/oradata> cp -r sihua sihua.bakoracle@JSBC-SIHUA-DB01:/oradata> cd sihua.bak/oracle@JSBC-SIHUA-DB01:/oradata/sihua.bak> cd sihua/oracle@JSBC-SIHUA-DB01:/oradata/sihua.bak/sihua> lltotal 2358432drwxr-x--- 2 oracle dba 4096 2011-11-28 12:17 controlfile-rw-r----- 1 oracle dba 925900800 2011-11-28 12:17 icms01.dbfdrwxr-x--- 2 oracle dba 4096 2011-11-28 12:17 redo-rw-r----- 1 oracle dba 440410112 2011-11-28 12:17 sysaux01.dbf-rw-r----- 1 oracle dba 524296192 2011-11-28 12:17 system01.dbf-rw-r----- 1 oracle dba 20979712 2011-11-28 12:17 temp01.dbf-rw-r----- 1 oracle dba 477110272 2011-11-28 12:17 undotbs01.dbf-rw-r----- 1 oracle dba 22028288 2011-11-28 12:17 urs01.dbf-rw-r----- 1 oracle dba 5251072 2011-11-28 12:17 users01.dbf#确认备份文件的大小oracle@JSBC-SIHUA-DB01:/oradata> du -sh ./*du: cannot read directory `./lost+found': Permission denied16K ./lost+found2.5G ./sihua2.5G ./sihua.bak三、数据库恢复oracle@JSBC-SIHUA-DB01:/oradata> sqlplus /nologSQL*Plus: Release 10.2.0.1.0 - Production on Mon Nov 28 12:22:52 2011Copyright (c) 1982, 2005, Oracle. All rights reserved.SQL> conn / as sysdbaConnected to an idle instance.SQL> startup mount;ORACLE instance started.Total System Global Area 2147483648 bytesFixed Size 2022144 bytesVariable Size 603981056 bytesDatabase Buffers 1526726656 bytesRedo Buffers 14753792 bytesDatabase mounted.SQL> exitDisconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining optionsoracle@JSBC-SIHUA-DB01:/oradata> rmanRecovery Manager: Release 10.2.0.1.0 - Production on Mon Nov 28 12:25:30 2011Copyright (c) 1982, 2005, Oracle. All rights reserved.RMAN> connect catalog rman/rman@sihua2connected to recovery catalog databaseRMAN> connect target /connected to target database: SIHUA (DBID=2229474680, not open)RMAN> 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> set until time = '2011-11-28 10:30:00';RMAN-00571: ========================================================== RMAN-00569: ============= ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: ========================================================== RMAN-03031: this option of set command needs to be used inside a run blockRMAN> run {sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';set until time = '2011-11-28 10:30:00';restore database;recover database;}2> 3> 4> 5> 6> ;sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"executing command: SET until clauseStarting restore at 28-NOV-11allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=428 devtype=DISKchannel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00001 to /oradata/sihua/system01.dbfrestoring datafile 00005 to /oradata/sihua/urs01.dbfchannel ORA_DISK_1:reading from backup piece /orabak/DB_Backup/111127/level0_SIHUA_20111127_444_1.bak channel ORA_DISK_1: restored backup piece 1piece handle=/orabak/DB_Backup/111127/level0_SIHUA_20111127_444_1.bak tag=LEVEL0 channel ORA_DISK_1: restore complete, elapsed time: 00:00:04channel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00002 to /oradata/sihua/undotbs01.dbfrestoring datafile 00003 to /oradata/sihua/sysaux01.dbfchannel ORA_DISK_1:reading from backup piece /orabak/DB_Backup/111127/level0_SIHUA_20111127_445_1.bak channel ORA_DISK_1: restored backup piece 1piece handle=/orabak/DB_Backup/111127/level0_SIHUA_20111127_445_1.bak tag=LEVEL0 channel ORA_DISK_1: restore complete, elapsed time: 00:00:04channel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00004 to /oradata/sihua/users01.dbfrestoring datafile 00006 to /oradata/sihua/icms01.dbfchannel ORA_DISK_1:channel ORA_DISK_1: restored backup piece 1piece handle=/orabak/DB_Backup/111127/level0_SIHUA_20111127_443_1.bak tag=LEVEL0 channel ORA_DISK_1: restore complete, elapsed time: 00:00:08Finished restore at 28-NOV-11Starting recover at 28-NOV-11using channel ORA_DISK_1channel ORA_DISK_1: starting incremental datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setdestination for restore of datafile 00001: /oradata/sihua/system01.dbfdestination for restore of datafile 00005: /oradata/sihua/urs01.dbfchannel ORA_DISK_1:reading from backup piece /orabak/DB_Backup/111128/level1_SIHUA_20111128_450_1.bak channel ORA_DISK_1: restored backup piece 1piece handle=/orabak/DB_Backup/111128/level1_SIHUA_20111128_450_1.bak tag=LEVEL1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02channel ORA_DISK_1: starting incremental datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setdestination for restore of datafile 00002: /oradata/sihua/undotbs01.dbfdestination for restore of datafile 00003: /oradata/sihua/sysaux01.dbfchannel ORA_DISK_1:reading from backup piece /orabak/DB_Backup/111128/level1_SIHUA_20111128_451_1.bak channel ORA_DISK_1: restored backup piece 1piece handle=/orabak/DB_Backup/111128/level1_SIHUA_20111128_451_1.bak tag=LEVEL1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02channel ORA_DISK_1: starting incremental datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setdestination for restore of datafile 00004: /oradata/sihua/users01.dbfdestination for restore of datafile 00006: /oradata/sihua/icms01.dbfchannel ORA_DISK_1:reading from backup piece /orabak/DB_Backup/111128/level1_SIHUA_20111128_449_1.bak channel ORA_DISK_1: restored backup piece 1piece handle=/orabak/DB_Backup/111128/level1_SIHUA_20111128_449_1.bak tag=LEVEL1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03starting media recoverychannel ORA_DISK_1: starting archive log restore to default destinationchannel ORA_DISK_1: restoring archive logarchive log thread=1 sequence=566channel ORA_DISK_1: restoring archive logarchive log thread=1 sequence=567channel ORA_DISK_1:channel ORA_DISK_1: restored backup piece 1piece handle=/orabak/DB_Backup/111128/arc_SIHUA_20111128_454_1.bak tag=TAG20111128T021512 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02archive log filename=/orabak/sihua/arclogs/1_566_762001210.log thread=1 sequence=566 archive log filename=/orabak/sihua/arclogs/1_567_762001210.log thread=1 sequence=567 channel ORA_DISK_1: starting archive log restore to default destinationchannel ORA_DISK_1: restoring archive logarchive log thread=1 sequence=568channel ORA_DISK_1:reading from backup piece /orabak/DB_Backup/111128/arc_SIHUA_20111128_460_1.bak channel ORA_DISK_1: restored backup piece 1piece handle=/orabak/DB_Backup/111128/arc_SIHUA_20111128_460_1.bak tag=TAG20111128T115248 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02archive log filename=/orabak/sihua/arclogs/1_568_762001210.log thread=1 sequence=568 media recovery complete, elapsed time: 00:00:04Finished recover at 28-NOV-11RMAN-00571: ========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ============= RMAN-00571: ========================================================== RMAN-00558: error encountered while parsing input commandsRMAN-01009: syntax error: found ";": expecting one of: "allocate, alter, backup, beginline, blockrecover, catalog, change, connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, flashback, host, {, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, reset, restore, resync, rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate"RMAN-01007: at line 0 column 2 file: standard inputRMAN> alter database open resetlogs;database openednew incarnation of database registered in recovery catalogstarting full resync of recovery catalogfull resync completeRMAN>exitoracle@JSBC-SIHUA-DB01:~> lsnrctl start。