oracle 11.2.0.4 rac 恢复到单实例

来源:互联网 发布:苏州十大网络教育机构 编辑:程序博客网 时间:2024/04/30 08:05

一、备份原库

run{backup database format '/home/oracle/backup/db_%U_%T.bak';backup current controlfile format '/home/oracle/backup/ctl_%U_%T.bak';backup spfile format '/home/oracle/backup/spfile_%U_%T.bak';backup archivelog from time 'sysdate -1' format  '/home/oracle/backup/arch_%U_%T.bak';}

二、修改单实例的参数文件

将备份的文件拷贝到单实例的相同目录

db_name=suqlog_archive_dest_1='location=/arch'pga_aggregate_target=400000000sga_target=800000000control_files='/oradata/control.ctl'

启动单实例到nomount

[oracle@11g1 dbs]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Fri Dec 12 20:39:56 2014Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to an idle instance.SQL> SQL> startup nomountORACLE instance started.Total System Global Area  797523968 bytesFixed Size    2257472 bytesVariable Size  222301632 bytesDatabase Buffers  566231040 bytesRedo Buffers    6733824 bytes


三、恢复控制文件

[oracle@11g1 ~]$ rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 12 20:40:14 2014Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.connected to target database: SUQ (not mounted)RMAN> restore controlfile from '/home/oracle/backup/clt_0dpq0ka5_1_1_20141212.bak';Starting restore at 12-DEC-14using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=171 device type=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/oradata/control.ctlFinished restore at 12-DEC-14RMAN> SQL> startup mountORACLE instance started.Total System Global Area  797523968 bytesFixed Size    2257472 bytesVariable Size  222301632 bytesDatabase Buffers  566231040 bytesRedo Buffers    6733824 bytesORA-00201: control file version 11.2.0.4.0 incompatible with ORACLE version11.2.0.0.0ORA-00202: control file: '/oradata/control.ctl'

这里一个报错,需要在pfile中添加版本的参数

compatible='11.2.0.4.0'

SQL> startup mountORACLE instance started.Total System Global Area  797523968 bytesFixed Size    2257472 bytesVariable Size  222301632 bytesDatabase Buffers  566231040 bytesRedo Buffers    6733824 bytesDatabase mounted.SQL> exit

四、修改日志文件的路径

alter database rename file '+BACKUP/suq/onlinelog/group_1.258.850940549' to '/oradata/group_1.258.850940549';alter database rename file '+BACKUP/suq/onlinelog/group_1.259.850940549' to '/oradata/group_1.259.850940549';alter database rename file '+BACKUP/suq/onlinelog/group_2.260.850940551' to '/oradata/group_2.260.850940551';alter database rename file '+BACKUP/suq/onlinelog/group_2.261.850940551' to '/oradata/group_2.261.850940551';alter database rename file '+BACKUP/suq/onlinelog/group_3.268.850941051' to '/oradata/group_3.268.850941051';alter database rename file '+BACKUP/suq/onlinelog/group_3.269.850941053' to '/oradata/group_3.269.850941053';alter database rename file '+BACKUP/suq/onlinelog/group_4.270.850941053' to '/oradata/group_4.270.850941053';Database altered.SQL> Database altered.SQL> Database altered.SQL> Database altered.SQL> Database altered.SQL> Database altered.SQL> Database altered.SQL> alter database rename file '+BACKUP/suq/onlinelog/group_4.271.850941053' to '/oradata/group_4.271.850941053';Database altered.

五、还原数据文件,需要指定scn号,可以list backup查看,需要写到你能恢复到的那个时间点

run{set newname for database to '/oradata/%b';set until scn 394762;restore database;switch datafile all;}executing command: SET NEWNAMEStarting restore at 12-DEC-14allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=170 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /oradata/system.262.850940553channel ORA_DISK_1: restoring datafile 00002 to /oradata/sysaux.263.850940565channel ORA_DISK_1: restoring datafile 00003 to /oradata/undotbs1.264.850940573channel ORA_DISK_1: restoring datafile 00004 to /oradata/undotbs2.266.850940597channel ORA_DISK_1: restoring datafile 00005 to /oradata/users.267.853590391channel ORA_DISK_1: reading from backup piece /home/oracle/backup/db_0bpq0k84_1_1_20141212.bakchannel ORA_DISK_1: piece handle=/home/oracle/backup/db_0bpq0k84_1_1_20141212.bak tag=TAG20141212T194156channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:35Finished restore at 12-DEC-14datafile 1 switched to datafile copyinput datafile copy RECID=6 STAMP=866148453 file name=/oradata/system.262.850940553datafile 2 switched to datafile copyinput datafile copy RECID=7 STAMP=866148453 file name=/oradata/sysaux.263.850940565datafile 3 switched to datafile copyinput datafile copy RECID=8 STAMP=866148453 file name=/oradata/undotbs1.264.850940573datafile 4 switched to datafile copyinput datafile copy RECID=9 STAMP=866148453 file name=/oradata/undotbs2.266.850940597datafile 5 switched to datafile copyinput datafile copy RECID=10 STAMP=866148453 file name=/oradata/users.267.853590391RMAN> [oracle@11g1 oradata]$ ls -ltotal 1765776-rw-r----- 1 oracle oinstall  18497536 Dec 12 20:48 control.ctl-rw-r----- 1 oracle oinstall 629153792 Dec 12 20:47 sysaux.263.850940565-rw-r----- 1 oracle oinstall 734011392 Dec 12 20:47 system.262.850940553-rw-r----- 1 oracle oinstall 209723392 Dec 12 20:47 undotbs1.264.850940573-rw-r----- 1 oracle oinstall 209723392 Dec 12 20:47 undotbs2.266.850940597-rw-r----- 1 oracle oinstall   5251072 Dec 12 20:46 users.267.853590391[oracle@11g1 oradata]$ SQL> select name from v$datafile;NAME--------------------------------------------------------------------------------/oradata/system.262.850940553/oradata/sysaux.263.850940565/oradata/undotbs1.264.850940573/oradata/undotbs2.266.850940597/oradata/users.267.853590391

六、打开数据库,一些后续操作

SQL> alter database open resetlogs;Database altered.SQL> select count(*) from test.t1;  COUNT(*)---------- 2SQL> alter database disable thread 2;Database altered.SQL> alter database disable thread 2;Database altered.SQL> SQL> SQL> SQL> alter database drop logfile group 3;Database altered.SQL> alter database drop logfile group 4;Database altered.



0 0