單例項恢復RAC資料庫步驟(一)

yangtingkun發表於2011-02-25

簡單描述在測試伺服器的單機環境恢復RAC產品資料庫的步驟。

這一篇介紹資料庫準備過程。

 

 

首先複製RMAN備份檔案:

登入RAC資料庫伺服器,利用rman獲取最新的備份資訊:

$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Mon Jan 17 10:28:16 2011

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

connected to target database: ORCL (DBID=1264586523)

RMAN> list backup of database;

using target database control file instead of recovery catalog

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
144     Full    1.46G      DISK        00:00:15     15-JAN-11     
        BP Key: 144   Status: AVAILABLE  Compressed: NO  Tag: TAG20110115T044017
        Piece Name: /rman/backup/orcl/4um2565i_1_1
  List of Datafiles in backup set 144
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  4       Full 912068321  15-JAN-11 +DATADG/orcl/datafile/undotbs2.264.736805825
  10      Full 912068321  15-JAN-11 +DATADG/orcl/datafile/tsp_comm.274.736807163
  15      Full 912068321  15-JAN-11 +DATADG/orcl/datafile/tsp_hhpacs.279.736807169
  16      Full 912068321  15-JAN-11 +DATADG/orcl/datafile/tsp_hisaccount.280.736807171
  19      Full 912068321  15-JAN-11 +DATADG/orcl/datafile/tsp_inpadm.283.736807173
  21      Full 912068321  15-JAN-11 +DATADG/orcl/datafile/tsp_insurance.285.736807257
  24      Full 912068321  15-JAN-11 +DATADG/orcl/datafile/tsp_material.288.736807297
  25      Full 912068321  15-JAN-11 +DATADG/orcl/datafile/tsp_medadm.289.736807297
  34      Full 912068321  15-JAN-11 +DATADG/orcl/datafile/tsp_temp.298.736807465

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
145     Full    3.77G      DISK        00:00:30     15-JAN-11     
.
.
.

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
171     Full    772.09M    DISK        00:00:10     17-JAN-11     
        BP Key: 171   Status: AVAILABLE  Compressed: NO  Tag: TAG20110117T044028
        Piece Name: /rman/backup/orcl/5pm2aets_1_1
  List of Datafiles in backup set 171
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  4       Full 913655386  17-JAN-11 +DATADG/orcl/datafile/undotbs2.264.736805825
  10      Full 913655386  17-JAN-11 +DATADG/orcl/datafile/tsp_comm.274.736807163
  15      Full 913655386  17-JAN-11 +DATADG/orcl/datafile/tsp_hhpacs.279.736807169
  16      Full 913655386  17-JAN-11 +DATADG/orcl/datafile/tsp_hisaccount.280.736807171
  19      Full 913655386  17-JAN-11 +DATADG/orcl/datafile/tsp_inpadm.283.736807173
  21      Full 913655386  17-JAN-11 +DATADG/orcl/datafile/tsp_insurance.285.736807257
  24      Full 913655386  17-JAN-11 +DATADG/orcl/datafile/tsp_material.288.736807297
  25      Full 913655386  17-JAN-11 +DATADG/orcl/datafile/tsp_medadm.289.736807297
  34      Full 913655386  17-JAN-11 +DATADG/orcl/datafile/tsp_temp.298.736807465

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
172     Full    3.11G      DISK        00:00:30     17-JAN-11     
        BP Key: 172   Status: AVAILABLE  Compressed: NO  Tag: TAG20110117T044028
        Piece Name: /rman/backup/orcl/5qm2aets_1_1
  List of Datafiles in backup set 172
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 913655392  17-JAN-11 +DATADG/orcl/datafile/system.260.736805807
  2       Full 913655392  17-JAN-11 +DATADG/orcl/datafile/undotbs1.261.736805813
  6       Full 913655392  17-JAN-11 +DATADG/orcl/datafile/tsp_acct.270.736807161
  9       Full 913655392  17-JAN-11 +DATADG/orcl/datafile/tsp_card.273.736807163
  11      Full 913655392  17-JAN-11 +DATADG/orcl/datafile/tsp_econstat.275.736807165
  13      Full 913655392  17-JAN-11 +DATADG/orcl/datafile/tsp_evaluate.277.736807165
  14      Full 913655392  17-JAN-11 +DATADG/orcl/datafile/tsp_exam.278.736807165
  17      Full 913655392  17-JAN-11 +DATADG/orcl/datafile/tsp_infect.281.736807171
  35      Full 913655392  17-JAN-11 +DATADG/orcl/datafile/user_data.299.736807479

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
173     Full    24.77G     DISK        00:03:50     17-JAN-11     
        BP Key: 173   Status: AVAILABLE  Compressed: NO  Tag: TAG20110117T044028
        Piece Name: /rman/backup/orcl/5sm2aev4_1_1
  List of Datafiles in backup set 173
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  3       Full 913655435  17-JAN-11 +DATADG/orcl/datafile/sysaux.262.736805823
  7       Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_back.271.736807161
  8       Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_bldbank.272.736807163
  12      Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_equipment.276.736807165
  20      Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_inpbill.284.736807175
  22      Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_interface.286.736807259
  23      Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_lab.287.736807261
  27      Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_medrec.291.736807299
  30      Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_outpbill.294.736807413
  32      Full 913655435  17-JAN-11 +DATADG/orcl/datafile/tsp_phyexam.296.736807465

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
174     Full    27.63G     DISK        00:04:17     17-JAN-11     
        BP Key: 174   Status: AVAILABLE  Compressed: NO  Tag: TAG20110117T044028
        Piece Name: /rman/backup/orcl/5rm2aeub_1_1
  List of Datafiles in backup set 174
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  5       Full 913655419  17-JAN-11 +DATADG/orcl/datafile/users.265.736805835
  18      Full 913655419  17-JAN-11 +DATADG/orcl/datafile/tsp_info.282.736807173
  26      Full 913655419  17-JAN-11 +DATADG/orcl/datafile/tsp_medicom.290.736807299
  28      Full 913655419  17-JAN-11 +DATADG/orcl/datafile/tsp_ordadm.292.736807303
  29      Full 913655419  17-JAN-11 +DATADG/orcl/datafile/tsp_outpadm.293.736807375
  31      Full 913655419  17-JAN-11 +DATADG/orcl/datafile/tsp_pharmacy.295.736807437
  33      Full 913655419  17-JAN-11 +DATADG/orcl/datafile/tsp_surgery.297.736807465

複製最新的備份檔案到目標伺服器,包括資料檔案備份、歸檔備份和控制檔案的自動備份。

$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Mon Jan 17 13:21:13 2011

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

connected to target database: ORCL (DBID=1264586523)

RMAN> run
2> { copy archivelog '+FRADG/ORCL/ARCHIVELOG/2011_01_17/thread_1_seq_870.306.740657241' to '/rman/backup/orcl/archive_1_870.log';
3> copy archivelog '+FRADG/ORCL/ARCHIVELOG/2011_01_17/thread_2_seq_13943.264.740651773' to '/rman/backup/orcl/archive_2_13943.log';
4> copy archivelog '+FRADG/ORCL/ARCHIVELOG/2011_01_17/thread_2_seq_13944.299.740654879' to '/rman/backup/orcl/archive_2_13944.log';
5> copy archivelog '+FRADG/ORCL/ARCHIVELOG/2011_01_17/thread_2_seq_13945.302.740657213' to '/rman/backup/orcl/archive_2_13945.log';
6> copy archivelog '+FRADG/ORCL/ARCHIVELOG/2011_01_17/thread_2_seq_13946.278.740660145' to '/rman/backup/orcl/archive_2_13946.log';
7> copy archivelog '+FRADG/ORCL/ARCHIVELOG/2011_01_17/thread_2_seq_13947.280.740660179' to '/rman/backup/orcl/archive_2_13947.log';
8> }

Starting backup at 17-JAN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1327 instance=orcl2 devtype=DISK
channel ORA_DISK_1: starting archive copy
input archive log thread=1 sequence=870 recid=141 stamp=740657240
output filename=/rman/backup/orcl/archive_1_870.log recid=145 stamp=740668924
channel ORA_DISK_1: archivelog copy complete, elapsed time: 00:00:02
Finished backup at 17-JAN-11

Starting backup at 17-JAN-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive copy
input archive log thread=2 sequence=13943 recid=139 stamp=740651778
output filename=/rman/backup/orcl/archive_2_13943.log recid=146 stamp=740669098
channel ORA_DISK_1: archivelog copy complete, elapsed time: 00:00:04
Finished backup at 17-JAN-11

.
.
.

Starting backup at 17-JAN-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive copy
input archive log thread=2 sequence=13947 recid=144 stamp=740660184
output filename=/rman/backup/orcl/archive_2_13947.log recid=150 stamp=740669114
channel ORA_DISK_1: archivelog copy complete, elapsed time: 00:00:04
Finished backup at 17-JAN-11

Starting Control File and SPFILE Autobackup at 17-JAN-11
piece handle=/rman/backup/orcl/c-1264586523-20110117-04 comment=NONE
Finished Control File and SPFILE Autobackup at 17-JAN-11

利用rmanASM中的歸檔日誌複製到目的路徑中,然後ftp到目標伺服器。

首先利用rman恢復SPFILE:

$ env |grep ORACLE
ORACLE_SID=orcl
ORACLE_HOME=/oracle/db
$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Mon Jan 17 11:07:59 2011

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

connected to target database: DUMMY (not mounted)

RMAN> set dbid 1264586523

executing command: SET DBID

RMAN> startup nomount

connected to target database (not started)
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/db/dbs/initorcl.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started

Total System Global Area     159383552 bytes

Fixed Size                     2066400 bytes
Variable Size                 67110944 bytes
Database Buffers              83886080 bytes
Redo Buffers                   6320128 bytes

RMAN> restore spfile to '/home/oracle/spfileorcl.ora' from '/data/backup/orcl/c-1264586523-20110117-02';

Starting restore at 17-JAN-11
using channel ORA_DISK_1

channel ORA_DISK_1: autobackup found: /data/backup/orcl/c-1264586523-20110117-02
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 17-JAN-11

RMAN> exit


Recovery Manager complete.

$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Mon Jan 17 11:11:48 2011

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


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

SQL> create pfile='/home/oracle/initorcl.ora' from spfile='/home/oracle/spfileorcl.ora';

File created.

    修改pfile引數如下:

*.audit_file_dest='/oracle/db/admin/orcl/adump'
*.background_dump_dest='/oracle/db/admin/orcl/bdump'
*.cluster_database_instances=2
*.cluster_database=false
*.compatible='10.2.0.5.0'
*.control_files='/data/oradata/orcl/control01.ctl'
*.core_dump_dest='/oracle/db/admin/orcl/cdump'
*.db_block_size=8192
*.db_create_file_dest=''
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.db_recovery_file_dest=''
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/data/oradata/orcl/archivelog'
*.open_cursors=300
*.pga_aggregate_target=1024m
*.processes=1500
*.remote_listener=''
*.remote_login_passwordfile='exclusive'
*.sessions=1655
*.sga_max_size=4096m
*.sga_target=4096m
*.undo_management='AUTO'
*.undo_retention=10800
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/db/admin/orcl/udump'

SQL> shutdown
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount pfile=/home/oracle/initorcl.ora
ORACLE instance started.

Total System Global Area 4294967296 bytes
Fixed Size                  2073472 bytes
Variable Size             805309568 bytes
Database Buffers         3472883712 bytes
Redo Buffers               14700544 bytes

恢復控制檔案,載入備份集資訊:

$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Mon Jan 17 11:31:40 2011

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

connected to target database: orcl (not mounted)

RMAN> restore controlfile from '/data/backup/orcl/c-1264586523-20110117-02';

Starting restore at 17-JAN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1641 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:06
output filename=/data/oradata/orcl/control01.ctl
Finished restore at 17-JAN-11

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> catalog backuppiece '/data/backup/orcl/5pm2aets_1_1';

cataloged backuppiece
backup piece handle=/data/backup/orcl/5pm2aets_1_1 recid=182 stamp=740662644

RMAN> catalog backuppiece '/data/backup/orcl/5qm2aets_1_1';

cataloged backuppiece
backup piece handle=/data/backup/orcl/5qm2aets_1_1 recid=183 stamp=740662723

RMAN> catalog backuppiece '/data/backup/orcl/5sm2aev4_1_1';

cataloged backuppiece
backup piece handle=/data/backup/orcl/5sm2aev4_1_1 recid=184 stamp=740662726

RMAN> catalog backuppiece '/data/backup/orcl/5rm2aeub_1_1';

cataloged backuppiece
backup piece handle=/data/backup/orcl/5rm2aeub_1_1 recid=185 stamp=740662730

RMAN> catalog backuppiece '/data/backup/orcl/5tm2af71_1_1';

cataloged backuppiece
backup piece handle=/data/backup/orcl/5tm2af71_1_1 recid=186 stamp=740662733

RMAN> catalog backuppiece '/data/backup/orcl/5um2af72_1_1';

cataloged backuppiece
backup piece handle=/data/backup/orcl/5um2af72_1_1 recid=187 stamp=740662736

RMAN> catalog backuppiece '/data/backup/orcl/60m2an40_1_1';

cataloged backuppiece
backup piece handle=/data/backup/orcl/60m2an40_1_1 recid=188 stamp=740662739

RMAN> catalog backuppiece '/data/backup/orcl/61m2an40_1_1';

cataloged backuppiece
backup piece handle=/data/backup/orcl/61m2an40_1_1 recid=189 stamp=740662742

至此資料庫恢復的準備工作完成,下面可以進行資料庫的還原和恢復操作。

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-687978/,如需轉載,請註明出處,否則將追究法律責任。

相關文章