一、备份原库
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=suq log_archive_dest_1='location=/arch' pga_aggregate_target=400000000 sga_target=800000000 control_files='/oradata/control.ctl'
启动单实例到nomount
[[email protected] dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Fri Dec 12 20:39:56 2014 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> SQL> startup nomount ORACLE instance started. Total System Global Area 797523968 bytes Fixed Size 2257472 bytes Variable Size 222301632 bytes Database Buffers 566231040 bytes Redo Buffers 6733824 bytes
三、恢复控制文件
[[email protected] ~]$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 12 20:40:14 2014 Copyright (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-14 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=171 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/oradata/control.ctl Finished restore at 12-DEC-14 RMAN> SQL> startup mount ORACLE instance started. Total System Global Area 797523968 bytes Fixed Size 2257472 bytes Variable Size 222301632 bytes Database Buffers 566231040 bytes Redo Buffers 6733824 bytes ORA-00201: control file version 11.2.0.4.0 incompatible with ORACLE version 11.2.0.0.0 ORA-00202: control file: '/oradata/control.ctl'
这里一个报错,需要在pfile中添加版本的参数
compatible='11.2.0.4.0'
SQL> startup mount ORACLE instance started. Total System Global Area 797523968 bytes Fixed Size 2257472 bytes Variable Size 222301632 bytes Database Buffers 566231040 bytes Redo Buffers 6733824 bytes Database 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 NEWNAME Starting restore at 12-DEC-14 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=170 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 00001 to /oradata/system.262.850940553 channel ORA_DISK_1: restoring datafile 00002 to /oradata/sysaux.263.850940565 channel ORA_DISK_1: restoring datafile 00003 to /oradata/undotbs1.264.850940573 channel ORA_DISK_1: restoring datafile 00004 to /oradata/undotbs2.266.850940597 channel ORA_DISK_1: restoring datafile 00005 to /oradata/users.267.853590391 channel ORA_DISK_1: reading from backup piece /home/oracle/backup/db_0bpq0k84_1_1_20141212.bak channel ORA_DISK_1: piece handle=/home/oracle/backup/db_0bpq0k84_1_1_20141212.bak tag=TAG20141212T194156 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:35 Finished restore at 12-DEC-14 datafile 1 switched to datafile copy input datafile copy RECID=6 STAMP=866148453 file name=/oradata/system.262.850940553 datafile 2 switched to datafile copy input datafile copy RECID=7 STAMP=866148453 file name=/oradata/sysaux.263.850940565 datafile 3 switched to datafile copy input datafile copy RECID=8 STAMP=866148453 file name=/oradata/undotbs1.264.850940573 datafile 4 switched to datafile copy input datafile copy RECID=9 STAMP=866148453 file name=/oradata/undotbs2.266.850940597 datafile 5 switched to datafile copy input datafile copy RECID=10 STAMP=866148453 file name=/oradata/users.267.853590391 RMAN> [[email protected] oradata]$ ls -l total 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 [[email protected] 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(*) ---------- 2 SQL> 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.
时间: 2024-10-19 11:41:40