oracle 11g rac 恢复到单实例

一:在单实例上安装数据库软件不建数据库。

二:创建 initsid.ora文件

shell>cp cp /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/init{,sid}.ora
修改initsid.ora中的为他的路径
db_name='sid'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/sid/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
db_recovery_file_dest_size=15G
# 恢复目录要足够大,不然的话在恢复的时候会报错。
diagnostic_dest='/u01/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=sidXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = (ora_control1, ora_control2)
compatible ='11.2.0'
"/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initsid.ora" 66L, 2856C written   

二:创建恢复目录,将全备和归档日志解压放到该目录下:
[oracle@ha1 ~]$ mkdir /u01/app/oracle/flash_recovery_area
[oracle@ha1 ~]$ mkdir /u01/app/oracle/admin
[oracle@ha1 ~]$ mkdir /u01/app/oracle/sid
[oracle@ha1 ~]$ mkdir /u01/app/oracle/sid/adump
[oracle@ha1 ~]$ vim /u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initsid.ora  
#     ghallmar   12/02/91 -  add global_names=true, db_directory=us.acme.com 
#     thayes     11/27/91 -  Change default for cache_clone 
#     jloaiza    08/13/91 -         merge changes from branch 1.7.100.1 
#     jloaiza    07/31/91 -         add debug stuff 
#     rlim       04/29/91 -         removal of char_is_varchar2 
#   Bridge     03/12/91 - log_allocation no longer exists
#   Wijaya     02/05/91 - remove obsolete parameters
#
##############################################################################
# Example INIT.ORA file
#
# This file is provided by Oracle Corporation to help you start by providing
# a starting point to customize your RDBMS installation for your site. 
# 
# NOTE: The values that are used in this file are only intended to be used
# as a starting point. You may want to adjust/tune those values to your
# specific hardware and needs. You may also consider using Database
# Configuration Assistant tool (DBCA) to create INIT file and to size your
# initial set of tablespaces based on the user input.
###############################################################################

# Change '' to point to the oracle base (the one you specify at
# install time)

db_name='pos'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
db_recovery_file_dest_size=20G
diagnostic_dest='/u01/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=posXDB)'
open_cursors=300
"/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/initpos.ora" 66L, 2855C written
三:rman连接数据库,启动数据库到nomount阶段,恢复控制文件                                    
[oracle@ha1 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 17 07:53:52 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 08/17/2012 07:54:08
RMAN-04014: startup failed: ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9925

RMAN> exit


Recovery Manager complete.


[oracle@ha1 ~]$ ls /u01/app/oracle/admin/
[oracle@ha1 ~]$ mkdir /u01/app/oracle/admin/sid
[oracle@ha1 ~]$ mkdir /u01/app/oracle/admin/sid/adump

[oracle@ha1 ~]$ ls /u01/app/oracle/
admin  checkpoints  diag  flash_recovery_area  sid product
[oracle@ha1 ~]$ ls /u01/app/oracle/sid/
adump
[oracle@ha1 ~]$ ls /u01/app/oracle/sid/adump/
[oracle@ha1 ~]$ rm  /u01/app/oracle/sid -rf


[oracle@ha1 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 17 07:56:11 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: POS (not mounted)

RMAN> startup nomount;

database is already started

RMAN> restore controlfile  from '/u01/app/oracle/flash_recovery_area/control_hcoe6feh_1_1.bak';

Starting restore at 17-AUG-2012 08:02:36
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=193 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/ora_control1
output file name=/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/ora_control2
Finished restore at 17-AUG-2012 08:02:38

RMAN> exit

四:查询数据文件路径,日志文件路径,通过rman修改文件路径,启动数据库。
Recovery Manager complete.
[oracle@ha1 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 17 08:02:50 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: POS (not mounted)

RMAN> mount database;

using target database control file instead of recovery catalog
database mounted

RMAN> catalog start with '/u01/app/oracle/flash_recovery_area'
2> ;

Starting implicit crosscheck backup at 17-AUG-2012 08:08:49
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=193 device type=DISK
Crosschecked 1000 objects
Finished implicit crosscheck backup at 17-AUG-2012 08:08:54

Starting implicit crosscheck copy at 17-AUG-2012 08:08:54
using channel ORA_DISK_1
Finished implicit crosscheck copy at 17-AUG-2012 08:08:54

searching for all files in the recovery area
cataloging files...
no files cataloged

searching for all files that match the pattern /u01/app/oracle/flash_recovery_area

List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/flash_recovery_area/arch_sid_hhoe6fik_1_1
File Name: /u01/app/oracle/flash_recovery_area/full_sid_hgoe6fgf_1_1
File Name: /u01/app/oracle/flash_recovery_area/full_sid_hfoe6fgd_1_1
File Name: /u01/app/oracle/flash_recovery_area/control_hcoe6feh_1_1.bak
File Name: /u01/app/oracle/flash_recovery_area/full_sid_hdoe6fel_1_1
File Name: /u01/app/oracle/flash_recovery_area/full_sid_heoe6fem_1_1
File Name: /u01/app/oracle/flash_recovery_area/arch_sid_hjoe6fv1_1_1
File Name: /u01/app/oracle/flash_recovery_area/arch_sid_hioe6fik_1_1

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/arch_sid_hhoe6fik_1_1
File Name: /u01/app/oracle/flash_recovery_area/full_sid_hgoe6fgf_1_1
File Name: /u01/app/oracle/flash_recovery_area/full_sid_hfoe6fgd_1_1
File Name: /u01/app/oracle/flash_recovery_area/control_hcoe6feh_1_1.bak
File Name: /u01/app/oracle/flash_recovery_area/full_sid_hdoe6fel_1_1
File Name: /u01/app/oracle/flash_recovery_area/full_sid_heoe6fem_1_1
File Name: /u01/app/oracle/flash_recovery_area/arch_sid_hjoe6fv1_1_1
File Name: /u01/app/oracle/flash_recovery_area/arch_sid_hioe6fik_1_1

RMAN> exit


Recovery Manager complete.

[oracle@ha1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 17 08:09:38 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> set pageszie 999
SP2-0158: unknown SET option "pageszie"
SQL> set pagesize 999
SQL> col name for a65
SQL> select file#,name from v$datafile;

     FILE# NAME
---------- -----------------------------------------------------------------
         1 +DATA/sid/datafile/system.260.786294989
         2 +DATA/sid/datafile/sysaux.261.786294999
         3 +DATA/sid/datafile/undotbs1.262.786295005
         4 +DATA/sid/datafile/undotbs2.264.786295013
         5 +DATA/sid/datafile/users.265.786295017
         6 +DATA/sid/datafile/pos.271.787751783
         7 +DATA/sid/datafile/pospadm.272.789650741

7 rows selected.

SQL> col member for a65
SQL> select member from v$logfile;

MEMBER
-----------------------------------------------------------------
+DATA/sid/onlinelog/group_1.257.786294959
+RECOVERY/sid/onlinelog/group_1.257.786294963
+DATA/sid/onlinelog/group_2.258.786294969
+RECOVERY/sid/onlinelog/group_2.258.786294973
+DATA/pos/onlinelog/group_5.259.786294979
+RECOVERY/sid/onlinelog/group_5.259.786294983
+DATA/sid/onlinelog/group_3.266.786297193
+RECOVERY/sid/onlinelog/group_3.260.786297197
+DATA/sid/onlinelog/group_4.267.786297203
+RECOVERY/pos/onlinelog/group_4.261.786297207
+DATA/sid/onlinelog/group_6.268.786297213
+RECOVERY/sid/onlinelog/group_6.262.786297219

12 rows selected.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ha1 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 17 08:12:42 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: POS (DBID=804043370, not open)

RMAN> run {
2> SET NEWNAME FOR DATAFILE 1 to '/u01/app/oracle/oradata/sid/system01.dbf';
3> SET NEWNAME FOR DATAFILE 2 to '/u01/app/oracle/oradata/sid/sysaux.dbf';
4> SET NEWNAME FOR DATAFILE 3 to '/u01/app/oracle/oradata/sid/undotbs01.dbf';
5> SET NEWNAME FOR DATAFILE 4 to '/u01/app/oracle/oradata/sid/undotbs02.dbf';
6> SET NEWNAME FOR DATAFILE 5 to '/u01/app/oracle/oradata/sid/users01.dbf';
7> SET NEWNAME FOR DATAFILE 6 to '/u01/app/oracle/oradata/sid/sid01.dbf';
8> SET NEWNAME FOR DATAFILE 7 to '/u01/app/oracle/oradata/sid/sidpadm.dbf';
9> SET NEWNAME FOR TEMPFILE 1 to '/u01/app/oracle/oradata/sid/tmp.dbf';
10> restore database;
11> SWITCH DATAFILE ALL; 
12> }

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 17-AUG-2012 08:19:02
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=193 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 /u01/app/oracle/oradata/sid/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/sid/sysaux.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/sid/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/sid/pos01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/full_sid_heoe6fem_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/full_sid_heoe6fem_1_1 tag=BACKUPDATABASE
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
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 00004 to /u01/app/oracle/oradata/sid/undotbs02.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/sid/users01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/pos/pospadm.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/full_sid_hdoe6fel_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/full_sid_hdoe6fel_1_1 tag=BACKUPDATABASE
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 17-AUG-2012 08:20:43

datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=791540444 file name=/u01/app/oracle/oradata/sid/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=9 STAMP=791540444 file name=/u01/app/oracle/oradata/sid/sysaux.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=791540444 file name=/u01/app/oracle/oradata/sid/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=791540444 file name=/u01/app/oracle/oradata/sid/undotbs02.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=12 STAMP=791540444 file name=/u01/app/oracle/oradata/sid/users01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=13 STAMP=791540444 file name=/u01/app/oracle/oradata/sid/pos01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=14 STAMP=791540444 file name=/u01/app/oracle/oradata/sid/pospadm.dbf

RMAN> exit


Recovery Manager complete.
[oracle@ha1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 17 08:27:49 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter database rename file '+DATA/sid/onlinelog/group_1.257.786294959' to '/u01/app/oracle/oradata/sid/redo01_1.log';

Database altered.

SQL> alter database rename file '+RECOVERY/sid/onlinelog/group_1.257.786294963' to '/u01/app/oracle/oradata/sid/redo01_2.log'
  2  ;

Database altered.

SQL> alter database rename file '+DATA/sid/onlinelog/group_2.258.786294969' to '/u01/app/oracle/oradata/sid/redo02_1.log'
  2  ;

Database altered.

SQL> alter database rename file '+RECOVERY/sid/onlinelog/group_2.258.786294973' to '/u01/app/oracle/oradata/sid/redo02_2.log'
  2  ;

Database altered.

SQL> alter database rename file '+DATA/sid/onlinelog/group_5.259.786294979' to '/u01/app/oracle/oradata/sid/redo05_1.log'
  2  ;

Database altered.

SQL> alter database rename file '+RECOVERY/sid/onlinelog/group_5.259.786294983' to '/u01/app/oracle/oradata/sid/redo05_2.log'
  2  ;

Database altered.

SQL> alter database rename file '+DATA/sid/onlinelog/group_3.266.786297193' to '/u01/app/oracle/oradata/sid/redo03_1.log'
  2  ;

Database altered.

SQL> alter database rename file '+RECOVERY/sid/onlinelog/group_3.260.786297197' to '/u01/app/oracle/oradata/sid/redo03_2.log'
  2  ;

Database altered.

SQL> alter database rename file '+DATA/sid/onlinelog/group_4.267.786297203' to '/u01/app/oracle/oradata/sid/redo04_1.log'
  2  ;

Database altered.

SQL> alter database rename file '+RECOVERY/sid/onlinelog/group_4.261.786297207'  to 'u01/app/oracle/oradata/sid/redo04_2.log'
  2  ;

Database altered.

SQL> alter database rename file '+DATA/sid/onlinelog/group_6.268.786297213' to 'u01/app/oracle/oradata/sid/redo06_1.log'
  2  ;

Database altered.

SQL> alter database rename file '+RECOVERY/sid/onlinelog/group_6.262.786297219' to 'u01/app/oracle/oradata/sid/redo06_2.log'
  2  ;

Database altered.


12 rows selected.

SQL> select member from v$logfile;
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/sid/redo01_1.log
/u01/app/oracle/oradata/sid/redo01_2.log
/u01/app/oracle/oradata/sid/redo02_1.log
/u01/app/oracle/oradata/sid/redo02_2.log
/u01/app/oracle/oradata/sid/redo05_1.log
/u01/app/oracle/oradata/sid/redo05_2.log
/u01/app/oracle/oradata/sid/redo03_1.log
/u01/app/oracle/oradata/sid/redo03_2.log
/u01/app/oracle/oradata/sid/redo04_1.log
/u01/app/oracle/oradata/sid/redo04_2.log
/u01/app/oracle/oradata/sid/redo06_1.log

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/sid/redo06_2.log

12 rows selected.

SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done


SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ha1 ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Aug 17 08:54:10 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: POS (DBID=804043370, not open)

RMAN> recover database;

Starting recover at 17-AUG-2012 08:54:21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=193 device type=DISK

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=639
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=644
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=640
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=645
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/arch_sid_hjoe6fv1_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/arch_sid_hjoe6fv1_1_1 tag=BACKUPARCH
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
archived log file name=/u01/app/oracle/flash_recovery_area/sid/archivelog/2012_08_17/o1_mf_1_639_82v5l28d_.arc thread=1 sequence=639
archived log file name=/u01/app/oracle/flash_recovery_area/sid/archivelog/2012_08_17/o1_mf_2_644_82v5l243_.arc thread=2 sequence=644
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/sid/archivelog/2012_08_17/o1_mf_1_639_82v5l28d_.arc RECID=1277 STAMP=791542
archived log file name=/u01/app/oracle/flash_recovery_area/sid/archivelog/2012_08_17/o1_mf_1_640_82v5l2g6_.arc thread=1 sequence=640
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/sod/archivelog/2012_08_17/o1_mf_2_644_82v5l243_.arc RECID=1278 STAMP=791542520
archived log file name=/u01/app/oracle/flash_recovery_area/sid/archivelog/2012_08_17/o1_mf_2_645_82v5l28p_.arc thread=2 sequence=645
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/sid/archivelog/2012_08_17/o1_mf_2_645_82v5l28p_.arc RECID=1275 STAMP=791542466
unable to find archived log
archived log thread=2 sequence=646
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 08/17/2012 08:55:23
RMAN-06054: media recovery requesting unknown archived log for thread 2 with sequence 646 and starting SCN of 191410319

RMAN> exit


Recovery Manager complete.
[oracle@ha1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 17 08:55:42 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter database open resetlogs;

Database altered.


 

 



 

你可能感兴趣的:(oracle)