您的位置:首页 > 数据库 > Oracle

《Oracle从入门到精通》读书笔记第十五章 Oracle数据备份与恢复之二

2014-03-18 12:53 344 查看
15.3.3 增量备份1、0级差异增量备份RMAN> run{2> allocate channel ch_1 type disk;3> backup incremental level=04> format '/ora/backup/ora11g_%m_%d_%c.bak'5> tablespace ts_1;6> }released channel: ORA_DISK_1allocated channel: ch_1channel ch_1: SID=43 device type=DISKStarting backup at 07-JAN-14channel ch_1: starting incremental level 0 datafile backup setchannel ch_1: specifying datafile(s) in backup setinput datafile file number=00010 name=/ora/app/oracle/oradata/stone1/ts1.dbfchannel ch_1: starting piece 1 at 07-JAN-14channel ch_1: finished piece 1 at 07-JAN-14piece handle=/ora/backup/ora11g_%m_STONE1_1.bak tag=TAG20140107T101302 comment=NONEchannel ch_1: backup set complete, elapsed time: 00:00:01Finished backup at 07-JAN-14released channel: ch_1
2、1级差异增量备份RMAN> backup incremental level=12> format '/ora/backup/ora11g_%d_%c.bak'3> tablespace ts_1;Starting backup at 07-JAN-14using channel ORA_DISK_1channel ORA_DISK_1: starting incremental level 1 datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00010 name=/ora/app/oracle/oradata/stone1/ts1.dbfchannel ORA_DISK_1: starting piece 1 at 07-JAN-14channel ORA_DISK_1: finished piece 1 at 07-JAN-14piece handle=/ora/backup/ora11g_STONE1_1.bak tag=TAG20140107T101811 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 07-JAN-14
3、2级累积增量备份RMAN> backup incremental level=2 cumulative tablespace ts_1;Starting backup at 07-JAN-14using channel ORA_DISK_1channel ORA_DISK_1: starting incremental level 2 datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00010 name=/ora/app/oracle/oradata/stone1/ts1.dbfchannel ORA_DISK_1: starting piece 1 at 07-JAN-14channel ORA_DISK_1: finished piece 1 at 07-JAN-14piece handle=/ora/app/oracle/product/11.2.0/dbhome_1/dbs/0fotfeu3_1_1 tag=TAG20140107T115131 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 07-JAN-14
15.4 使用rman工具完全恢复15.4.1 恢复处于noarchivelog模式的数据库SQL> select log_mode from v$database;LOG_MODE------------ARCHIVELOGSQL> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination /ora/app/oracle/oradata/stone1/archive4Oldest online log sequence 56Next log sequence to archive 58Current log sequence 58
SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.
SQL> startup mountORACLE instance started.Total System Global Area 342388736 bytesFixed Size 2213216 bytesVariable Size 209717920 bytesDatabase Buffers 125829120 bytesRedo Buffers 4628480 bytesDatabase mounted.
SQL> alter database noarchivelog;Database altered.SQL> alter database open;Database altered.SQL> archive log list;Database log mode No Archive ModeAutomatic archival DisabledArchive destination /ora/app/oracle/oradata/stone1/archive4Oldest online log sequence 57Current log sequence 59
SQL> select log_mode from v$database;LOG_MODE------------NOARCHIVELOG
[oracle@localhost ~]$ rman target sys/123456 nocatalog;Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jan 7 17:25:10 2014Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.connected to target database: STONE1 (DBID=2830852830)using target database control file instead of recovery catalogRMAN> shutdown immediate;database closeddatabase dismountedOracle instance shut downRMAN> startup mountconnected to target database (not started)Oracle instance starteddatabase mountedTotal System Global Area 342388736 bytesFixed Size 2213216 bytesVariable Size 209717920 bytesDatabase Buffers 125829120 bytesRedo Buffers 4628480 bytesRMAN> run{2> allocate channel ch_1 type disk;3> backup database format '/ora/backup/stone1_%t_%u.bak';4> }allocated channel: ch_1channel ch_1: SID=18 device type=DISKStarting backup at 07-JAN-14channel ch_1: starting full datafile backup setchannel ch_1: specifying datafile(s) in backup setinput datafile file number=00001 name=/ora/app/oracle/oradata/stone1/system01.dbfinput datafile file number=00002 name=/ora/app/oracle/oradata/stone1/sysaux01.dbfinput datafile file number=00005 name=/ora/app/oracle/oradata/stone1/example01.dbfinput datafile file number=00003 name=/ora/app/oracle/oradata/stone1/undotbs01.dbfinput datafile file number=00009 name=/ora/app/oracle/oradata/stone1/datafile4.dbfinput datafile file number=00011 name=/ora/app/oracle/oradata/stone1/datafilebig.dbfinput datafile file number=00014 name=/ora/app/oracle/oradata/stone1/rman_tbsp.dbfinput datafile file number=00006 name=/ora/app/oracle/oradata/stone1/datafile1.dbfinput datafile file number=00007 name=/ora/app/oracle/oradata/stone1/datafile2.dbfinput datafile file number=00008 name=/ora/app/oracle/oradata/stone1/datafile3.dbfinput datafile file number=00010 name=/ora/app/oracle/oradata/stone1/ts1.dbfinput datafile file number=00012 name=/ora/app/oracle/oradata/stone1/ts2.dbfinput datafile file number=00013 name=/ora/app/oracle/oradata/stone1/ts3.dbfinput datafile file number=00004 name=/ora/app/oracle/oradata/stone1/users01.dbfchannel ch_1: starting piece 1 at 07-JAN-14channel ch_1: finished piece 1 at 07-JAN-14piece handle=/ora/backup/stone1_836242032_0gotg2jg.bak tag=TAG20140107T172712 comment=NONEchannel ch_1: backup set complete, elapsed time: 00:00:56channel ch_1: starting full datafile backup setchannel ch_1: specifying datafile(s) in backup setincluding current control file in backup setincluding current SPFILE in backup setchannel ch_1: starting piece 1 at 07-JAN-14channel ch_1: finished piece 1 at 07-JAN-14piece handle=/ora/backup/stone1_836242089_0hotg2l9.bak tag=TAG20140107T172712 comment=NONEchannel ch_1: backup set complete, elapsed time: 00:00:01Finished backup at 07-JAN-14released channel: ch_1RMAN> shutdown immediatedatabase dismountedOracle instance shut down
[oracle@localhost ~]$ rm -f /ora/app/oracle/oradata/stone1/users01.dbfRMAN> startupconnected to target database (not started)Oracle instance starteddatabase mountedRMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of startup command at 01/07/2014 17:40:46ORA-01157: cannot identify/lock data file 4 - see DBWR trace fileORA-01110: data file 4: '/ora/app/oracle/oradata/stone1/users01.dbf'RMAN> run{2> allocate channel ch_1 type disk;3> restore database;4> }allocated channel: ch_1channel ch_1: SID=18 device type=DISKStarting restore at 07-JAN-14skipping datafile 1; already restored to file /ora/app/oracle/oradata/stone1/system01.dbfskipping datafile 2; already restored to file /ora/app/oracle/oradata/stone1/sysaux01.dbfskipping datafile 3; already restored to file /ora/app/oracle/oradata/stone1/undotbs01.dbfskipping datafile 5; already restored to file /ora/app/oracle/oradata/stone1/example01.dbfskipping datafile 6; already restored to file /ora/app/oracle/oradata/stone1/datafile1.dbfskipping datafile 7; already restored to file /ora/app/oracle/oradata/stone1/datafile2.dbfskipping datafile 8; already restored to file /ora/app/oracle/oradata/stone1/datafile3.dbfskipping datafile 9; already restored to file /ora/app/oracle/oradata/stone1/datafile4.dbfskipping datafile 10; already restored to file /ora/app/oracle/oradata/stone1/ts1.dbfskipping datafile 11; already restored to file /ora/app/oracle/oradata/stone1/datafilebig.dbfskipping datafile 12; already restored to file /ora/app/oracle/oradata/stone1/ts2.dbfskipping datafile 13; already restored to file /ora/app/oracle/oradata/stone1/ts3.dbfskipping datafile 14; already restored to file /ora/app/oracle/oradata/stone1/rman_tbsp.dbfchannel ch_1: starting datafile backup set restorechannel ch_1: specifying datafile(s) to restore from backup setchannel ch_1: restoring datafile 00004 to /ora/app/oracle/oradata/stone1/users01.dbfchannel ch_1: reading from backup piece /ora/backup/stone1_836242032_0gotg2jg.bakchannel ch_1: piece handle=/ora/backup/stone1_836242032_0gotg2jg.bak tag=TAG20140107T172712channel ch_1: restored backup piece 1channel ch_1: restore complete, elapsed time: 00:00:04Finished restore at 07-JAN-14released channel: ch_1RMAN> alter database open;database opened
15.4.2 恢复处于archivelog模式的数据库SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.
SQL> startup mount;ORACLE instance started.Total System Global Area 342388736 bytesFixed Size 2213216 bytesVariable Size 209717920 bytesDatabase Buffers 125829120 bytesRedo Buffers 4628480 bytesDatabase mounted.
SQL> alter database archivelog;Database altered.SQL> select log_mode from v$database;LOG_MODE------------ARCHIVELOGSQL> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination /ora/app/oracle/oradata/stone1/archive4Oldest online log sequence 59Next log sequence to archive 61Current log sequence 61
SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ rman target sys/123456 nocatalog;Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jan 8 11:07:28 2014Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.connected to target database: STONE1 (DBID=2830852830, not open)using target database control file instead of recovery catalogRMAN> run{2> allocate channel ch_1 type disk;3> allocate channel ch_2 type disk;4> backup tablespace users5> format '/ora/backup/users_tablespace.bak';6> }allocated channel: ch_1channel ch_1: SID=20 device type=DISKallocated channel: ch_2channel ch_2: SID=21 device type=DISKStarting backup at 08-JAN-14channel ch_1: starting full datafile backup setchannel ch_1: specifying datafile(s) in backup setinput datafile file number=00004 name=/ora/app/oracle/oradata/stone1/users01.dbfchannel ch_1: starting piece 1 at 08-JAN-14channel ch_1: finished piece 1 at 08-JAN-14piece handle=/ora/backup/users_tablespace.bak tag=TAG20140108T110843 comment=NONEchannel ch_1: backup set complete, elapsed time: 00:00:01Finished backup at 08-JAN-14released channel: ch_1released channel: ch_2
[oracle@localhost ~]$ ll /ora/app/oracle/oradata/stone1/us*-rw-r----- 1 oracle oinstall 5251072 1月 8 10:59 /ora/app/oracle/oradata/stone1/users01.dbf[oracle@localhost ~]$ rm -f /ora/app/oracle/oradata/stone1/users01.dbf
RMAN> shutdown immediatedatabase dismountedOracle instance shut downRMAN> startup mountconnected to target database (not started)Oracle instance starteddatabase mountedTotal System Global Area 342388736 bytesFixed Size 2213216 bytesVariable Size 209717920 bytesDatabase Buffers 125829120 bytesRedo Buffers 4628480 bytesRMAN> run{2> allocate channel ch_1 type disk;3> restore tablespace users;4> recover tablespace users;5> }allocated channel: ch_1channel ch_1: SID=18 device type=DISKStarting restore at 08-JAN-14channel ch_1: starting datafile backup set restorechannel ch_1: specifying datafile(s) to restore from backup setchannel ch_1: restoring datafile 00004 to /ora/app/oracle/oradata/stone1/users01.dbfchannel ch_1: reading from backup piece /ora/backup/users_tablespace.bakchannel ch_1: piece handle=/ora/backup/users_tablespace.bak tag=TAG20140108T110843channel ch_1: restored backup piece 1channel ch_1: restore complete, elapsed time: 00:00:03Finished restore at 08-JAN-14Starting recover at 08-JAN-14starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 08-JAN-14released channel: ch_1RMAN> alter database open;database opened
15.5 使用RMAN工具部分恢复15.5.1 基于时间的不完全恢复在对数据库执行不完全恢复后,必须使用RESETLOGS选项打开数据库,将导致以前的任何重做日志文件失效。故在不完全恢复之前,需要备份控制文件,数据文件及重做日志文件,以便再次尝试恢复。(1)连接rman,关闭数据库RMAN> shutdown immediatedatabase closeddatabase dismountedOracle instance shut down(2)重启数据库到mount状态RMAN> startup mountconnected to target database (not started)Oracle instance starteddatabase mountedTotal System Global Area 342388736 bytesFixed Size 2213216 bytesVariable Size 209717920 bytesDatabase Buffers 125829120 bytesRedo Buffers 4628480 bytes(3)创建数据库备份RMAN> run{2> allocate channel ch_1 type disk;3> allocate channel ch_2 type disk;4> backup database format '/ora/backup/database_%t_%u_%c.bak';5> backup archivelog all format '/ora/backup/archive_%t_%u_%c.bak';6> }allocated channel: ch_1channel ch_1: SID=18 device type=DISKallocated channel: ch_2channel ch_2: SID=19 device type=DISKStarting backup at 08-JAN-14channel ch_1: starting full datafile backup setchannel ch_1: specifying datafile(s) in backup setinput datafile file number=00001 name=/ora/app/oracle/oradata/stone1/system01.dbfinput datafile file number=00009 name=/ora/app/oracle/oradata/stone1/datafile4.dbfinput datafile file number=00014 name=/ora/app/oracle/oradata/stone1/rman_tbsp.dbfinput datafile file number=00007 name=/ora/app/oracle/oradata/stone1/datafile2.dbfinput datafile file number=00010 name=/ora/app/oracle/oradata/stone1/ts1.dbfinput datafile file number=00013 name=/ora/app/oracle/oradata/stone1/ts3.dbfinput datafile file number=00004 name=/ora/app/oracle/oradata/stone1/users01.dbfchannel ch_1: starting piece 1 at 08-JAN-14channel ch_2: starting full datafile backup setchannel ch_2: specifying datafile(s) in backup setinput datafile file number=00002 name=/ora/app/oracle/oradata/stone1/sysaux01.dbfinput datafile file number=00005 name=/ora/app/oracle/oradata/stone1/example01.dbfinput datafile file number=00003 name=/ora/app/oracle/oradata/stone1/undotbs01.dbfinput datafile file number=00011 name=/ora/app/oracle/oradata/stone1/datafilebig.dbfinput datafile file number=00006 name=/ora/app/oracle/oradata/stone1/datafile1.dbfinput datafile file number=00008 name=/ora/app/oracle/oradata/stone1/datafile3.dbfinput datafile file number=00012 name=/ora/app/oracle/oradata/stone1/ts2.dbfchannel ch_2: starting piece 1 at 08-JAN-14channel ch_1: finished piece 1 at 08-JAN-14piece handle=/ora/backup/database_836306978_0joti212_1.bak tag=TAG20140108T112937 comment=NONEchannel ch_1: backup set complete, elapsed time: 00:00:56channel ch_1: starting full datafile backup setchannel ch_1: specifying datafile(s) in backup setchannel ch_2: finished piece 1 at 08-JAN-14piece handle=/ora/backup/database_836306978_0koti212_1.bak tag=TAG20140108T112937 comment=NONEchannel ch_2: backup set complete, elapsed time: 00:00:56channel ch_2: starting full datafile backup setchannel ch_2: specifying datafile(s) in backup setincluding current SPFILE in backup setchannel ch_2: starting piece 1 at 08-JAN-14including current control file in backup setchannel ch_1: starting piece 1 at 08-JAN-14channel ch_1: finished piece 1 at 08-JAN-14piece handle=/ora/backup/database_836307034_0loti22q_1.bak tag=TAG20140108T112937 comment=NONEchannel ch_1: backup set complete, elapsed time: 00:00:01channel ch_2: finished piece 1 at 08-JAN-14piece handle=/ora/backup/database_836307034_0moti22q_1.bak tag=TAG20140108T112937 comment=NONEchannel ch_2: backup set complete, elapsed time: 00:00:01Finished backup at 08-JAN-14Starting backup at 08-JAN-14channel ch_1: starting archived log backup setchannel ch_1: specifying archived log(s) in backup setinput archived log thread=1 sequence=41 RECID=72 STAMP=835631691input archived log thread=1 sequence=42 RECID=73 STAMP=835789452input archived log thread=1 sequence=43 RECID=80 STAMP=835869068input archived log thread=1 sequence=44 RECID=78 STAMP=835869032input archived log thread=1 sequence=45 RECID=82 STAMP=836069052input archived log thread=1 sequence=46 RECID=86 STAMP=836069052input archived log thread=1 sequence=47 RECID=89 STAMP=836070033channel ch_1: starting piece 1 at 08-JAN-14channel ch_2: starting archived log backup setchannel ch_2: specifying archived log(s) in backup setinput archived log thread=1 sequence=48 RECID=91 STAMP=836071724input archived log thread=1 sequence=49 RECID=94 STAMP=836071724input archived log thread=1 sequence=50 RECID=97 STAMP=836072080input archived log thread=1 sequence=51 RECID=101 STAMP=836073218input archived log thread=1 sequence=52 RECID=103 STAMP=836073218input archived log thread=1 sequence=53 RECID=106 STAMP=836159317input archived log thread=1 sequence=54 RECID=110 STAMP=836215262input archived log thread=1 sequence=55 RECID=113 STAMP=836215265input archived log thread=1 sequence=56 RECID=116 STAMP=836215526input archived log thread=1 sequence=57 RECID=118 STAMP=836215641channel ch_2: starting piece 1 at 08-JAN-14channel ch_1: finished piece 1 at 08-JAN-14piece handle=/ora/backup/archive_836307036_0noti22s_1.bak tag=TAG20140108T113036 comment=NONEchannel ch_1: backup set complete, elapsed time: 00:00:07channel ch_1: starting archived log backup setchannel ch_1: specifying archived log(s) in backup setinput archived log thread=1 sequence=61 RECID=122 STAMP=836306072input archived log thread=1 sequence=62 RECID=125 STAMP=836306077channel ch_1: starting piece 1 at 08-JAN-14channel ch_2: finished piece 1 at 08-JAN-14piece handle=/ora/backup/archive_836307036_0ooti22s_1.bak tag=TAG20140108T113036 comment=NONEchannel ch_2: backup set complete, elapsed time: 00:00:07channel ch_1: finished piece 1 at 08-JAN-14piece handle=/ora/backup/archive_836307043_0poti233_1.bak tag=TAG20140108T113036 comment=NONEchannel ch_1: backup set complete, elapsed time: 00:00:01Finished backup at 08-JAN-14released channel: ch_1released channel: ch_2(4)打开数据库RMAN> alter database open;database opened
(5)进入sqlplus,查看当前时间[oracle@localhost ~]$ sqlplus / as sysdba;SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 8 11:31:51 2014Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select to_char(sysdate,'hh24:mi:ss') from dual;TO_CHAR(--------11:33:04(6)修改表中数据SQL> select * from scott.emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 9000 STONE 20 7369 SMITH CLERK 7902 17-DEC-80 2758.33 20 7499 ALLEN SALESMAN 7698 20-FEB-81 2758.33 300 30 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 7521 WARD SALESMAN 7698 22-FEB-81 2758.33 500 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 2758.33 1400 30 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 7839 KING PRESIDENT 17-NOV-81 5000 10 7844 TURNER SALESMAN 7698 08-SEP-81 2758.33 0 30 7876 ADAMS CLERK 7788 23-MAY-87 2758.33 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 7900 JAMES CLERK 7698 03-DEC-81 2758.33 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7934 MILLER CLERK 7782 23-JAN-82 2758.33 1015 rows selected.SQL> alter session set nls_date_format='yyyy-mm-dd';Session altered.SQL> insert into scott.emp(empno,ename,job,hiredate,sal) 2 values(1234,'east','manager','1975-01-12',5000);1 row created.SQL> insert into scott.emp(empno,ename,job,hiredate,sal) 2 values(6789,'west','salesman','1980-12-12',3000);1 row created.SQL> select * from scott.emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ---------- ---------- ---------- DEPTNO---------- 9000 STONE 20 1234 east manager 1975-01-12 5000 6789 west salesman 1980-12-12 3000 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ---------- ---------- ---------- DEPTNO---------- 7369 SMITH CLERK 7902 1980-12-17 2758.33 20 7499 ALLEN SALESMAN 7698 1981-02-20 2758.33 300 30 7521 WARD SALESMAN 7698 1981-02-22 2758.33 500 30 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ---------- ---------- ---------- DEPTNO---------- 7566 JONES MANAGER 7839 1981-04-02 2975 20 7654 MARTIN SALESMAN 7698 1981-09-28 2758.33 1400 30 7698 BLAKE MANAGER 7839 1981-05-01 2850 30 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ---------- ---------- ---------- DEPTNO---------- 7782 CLARK MANAGER 7839 1981-06-09 2450 10 7788 SCOTT ANALYST 7566 1987-04-19 3000 20 7839 KING PRESIDENT 1981-11-17 5000 10 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ---------- ---------- ---------- DEPTNO---------- 7844 TURNER SALESMAN 7698 1981-09-08 2758.33 0 30 7876 ADAMS CLERK 7788 1987-05-23 2758.33 20 7900 JAMES CLERK 7698 1981-12-03 2758.33 30 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ---------- ---------- ---------- DEPTNO---------- 7902 FORD ANALYST 7566 1981-12-03 3000 20 7934 MILLER CLERK 7782 1982-01-23 2758.33 1017 rows selected.SQL> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options
(7)关闭数据库RMAN> shutdown immediate;database closeddatabase dismountedOracle instance shut down(8)使用操作系统创建数据库的一个脱机备份,包括控制文件的所有副本,数据文件和归档的重做日志文件,以防止不完全恢复失败
(9)启动数据库实例到mount状态RMAN> startup mountconnected to target database (not started)Oracle instance starteddatabase mountedTotal System Global Area 342388736 bytesFixed Size 2213216 bytesVariable Size 209717920 bytesDatabase Buffers 125829120 bytesRedo Buffers 4628480 bytes(10)执行基于时间的不完全恢复RMAN> run{2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';3> allocate channel ch_1 type disk;4> allocate channel ch_2 type disk;5> set until time '2014-01-08 11:33:04';6> restore database;7> recover database;8> sql 'alter database open resetlogs';9> }sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"allocated channel: ch_1channel ch_1: SID=18 device type=DISKallocated channel: ch_2channel ch_2: SID=19 device type=DISKexecuting command: SET until clauseStarting restore at 08-JAN-14channel ch_1: starting datafile backup set restorechannel ch_1: specifying datafile(s) to restore from backup setchannel ch_1: restoring datafile 00002 to /ora/app/oracle/oradata/stone1/sysaux01.dbfchannel ch_1: restoring datafile 00003 to /ora/app/oracle/oradata/stone1/undotbs01.dbfchannel ch_1: restoring datafile 00005 to /ora/app/oracle/oradata/stone1/example01.dbfchannel ch_1: restoring datafile 00006 to /ora/app/oracle/oradata/stone1/datafile1.dbfchannel ch_1: restoring datafile 00008 to /ora/app/oracle/oradata/stone1/datafile3.dbfchannel ch_1: restoring datafile 00011 to /ora/app/oracle/oradata/stone1/datafilebig.dbfchannel ch_1: restoring datafile 00012 to /ora/app/oracle/oradata/stone1/ts2.dbfchannel ch_1: reading from backup piece /ora/backup/database_836306978_0koti212_1.bakchannel ch_2: starting datafile backup set restorechannel ch_2: specifying datafile(s) to restore from backup setchannel ch_2: restoring datafile 00001 to /ora/app/oracle/oradata/stone1/system01.dbfchannel ch_2: restoring datafile 00004 to /ora/app/oracle/oradata/stone1/users01.dbfchannel ch_2: restoring datafile 00007 to /ora/app/oracle/oradata/stone1/datafile2.dbfchannel ch_2: restoring datafile 00009 to /ora/app/oracle/oradata/stone1/datafile4.dbfchannel ch_2: restoring datafile 00010 to /ora/app/oracle/oradata/stone1/ts1.dbfchannel ch_2: restoring datafile 00013 to /ora/app/oracle/oradata/stone1/ts3.dbfchannel ch_2: restoring datafile 00014 to /ora/app/oracle/oradata/stone1/rman_tbsp.dbfchannel ch_2: reading from backup piece /ora/backup/database_836306978_0joti212_1.bakchannel ch_1: piece handle=/ora/backup/database_836306978_0koti212_1.bak tag=TAG20140108T112937channel ch_1: restored backup piece 1channel ch_1: restore complete, elapsed time: 00:01:48channel ch_2: piece handle=/ora/backup/database_836306978_0joti212_1.bak tag=TAG20140108T112937channel ch_2: restored backup piece 1channel ch_2: restore complete, elapsed time: 00:01:50Finished restore at 08-JAN-14Starting recover at 08-JAN-14starting media recoverymedia recovery complete, elapsed time: 00:00:01Finished recover at 08-JAN-14sql statement: alter database open resetlogsreleased channel: ch_1released channel: ch_2
(11)验证[oracle@localhost ~]$ sqlplus / as sysdba;SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 8 11:53:05 2014Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select * from scott.emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 9000 STONE 20 7369 SMITH CLERK 7902 17-DEC-80 2758.33 20 7499 ALLEN SALESMAN 7698 20-FEB-81 2758.33 300 30 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 7521 WARD SALESMAN 7698 22-FEB-81 2758.33 500 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 2758.33 1400 30 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 7839 KING PRESIDENT 17-NOV-81 5000 10 7844 TURNER SALESMAN 7698 08-SEP-81 2758.33 0 30 7876 ADAMS CLERK 7788 23-MAY-87 2758.33 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ------------ ---------- ---------- DEPTNO---------- 7900 JAMES CLERK 7698 03-DEC-81 2758.33 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7934 MILLER CLERK 7782 23-JAN-82 2758.33 1015 rows selected.
15.5.2 基于SCN的不完全恢复本文出自 “石头记” 博客,请务必保留此出处http://stonebox.blog.51cto.com/5409313/1378520
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: