Networker恢復oracle rac到單機

hellohf123發表於2021-12-07

Networker恢復oracle rac到單機

此處oracle為oracle19c pdb

參考 Networker恢復oracle單節點,這裡主要列出來一些不同之處

http://blog.itpub.net/70004783/viewspace-2845335/


oracle恢復過程

此處oracle204是我用來恢復的單機

在oracle204機器上,建立最簡單的c引數檔案

1
2
3
4
5
[oracle@oracle204 dbs]$  cat  initprod.ora
*.db_name= 'prod'
*.sga_target=1496m
[oracle@oracle204 dbs]$  pwd
/u01/app/oracle/product/19c/db_1/dbs


啟動資料庫到nomount狀態

1
2
3
4
5
6
7
8
[oracle@oracle204 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Dec 6 10:35:18 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> startup nomount


在Networker查詢最新的備份,確定rman恢復指令碼。




首先恢復引數檔案

依據查詢的引數對應修改這一行

send 'NSR_ENV=( NSR_CLIENT= rac1-vip ,NSR_SERVER=  backserver,NSR_DATA_VOLUME_POOL=  bstindex)';

RMAN> set dbid=496022129;
executing command: SET DBID
RMAN> run
{
allocate channel t1 type 'SBT_TAPE';
send 'NSR_ENV=( NSR_CLIENT=rac1-vip,NSR_SERVER=backserver,NSR_DATA_VOLUME_POOL=bstindex)';
restore spfile from autobackup;
release channel t1;
}2> 3> 4> 5> 6> 7>
using target database control file instead of recovery catalog
allocated channel: t1
channel t1: SID=22 device type=SBT_TAPE
channel t1: NMDA Oracle v19.2.1.2
sent command to channel: t1
Starting restore at 2021-12-07 14:02:16
channel t1: looking for AUTOBACKUP on day: 20211207
channel t1: AUTOBACKUP found: c-496022129-20211207-00
channel t1: restoring spfile from AUTOBACKUP c-496022129-20211207-00
channel t1: SPFILE restore from AUTOBACKUP complete
Finished restore at 2021-12-07 14:12:21
released channel: t1
RMAN>



利用恢復的引數檔案轉化為引數檔案initprod.ora,並修改相應的引數。

[oracle@oracle204 dbs]$ strings spfileprod.ora > initprod.ora
恢復回來的引數檔案
[oracle@oracle204 dbs]$ cat initprod.ora
prod2.__data_transfer_cache_size=0
prod1.__data_transfer_cache_size=0
prod2.__db_cache_size=1476395008
prod1.__db_cache_size=1207959552
prod2.__inmemory_ext_roarea=0
prod1.__inmemory_ext_roarea=0
prod2.__inmemory_ext_rwarea=0
prod1.__inmemory_ext_rwarea=0
prod2.__java_pool_size=0
prod1.__java_pool_size=0
prod2.__large_pool_size=16777216
prod1.__large_pool_size=16777216
prod1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
prod2.__oracle_base='/u01/app/oracle'#ORACLE_
BASE set from environment
prod2.__pga_aggregate_target=822083584
prod1.__pga_aggregate_target=822083584
prod2.__sga_target=2466250752
prod1.__sga_target=2466250752
prod2.__shared_io_pool_size=117440512
prod1.__shared_io_pool_size=117440512
prod2.__shared_pool_size=838860800
prod1.__shared_pool_size=1107296256
prod2.__streams_pool_size=0
prod1.__streams_pool_size=0
prod2.__unified_pga_pool_size=0
prod1.__unified_pga_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/prod/adump'
*.au
dit_trail='db'
*.cluster_database=true
*.compatible='19.0.0'
*.control_files='+DATADG/PROD/CONTROLFILE/current.261.1084183793'
*.db_block_size=8192
*.db_create_file_dest='+DATADG'
*.db_file_name_convert='+DATADG/','+DATADG/'
*.db_name='prod'
*.db_unique_name='prod'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=prodXDB)'
*.enable_pluggable_database=true
*.fal_client='tns_primary'
*.fal_server='tns_standby'
family:dw_helper.instance_mode='read-only'
prod1.i
nstance_number=1
prod2.instance_number=2
*.local_listener='-oraagent-dummy-'
*.log_archive_config='DG_CONFIG=(prod,prodstd)'
*.log_archive_dest_1='LOCATION=+FRADG/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=prod'
*.log_archive_dest_2='SERVICE=tns_standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=prodstd'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=8
*.log_file_name_convert='+DATADG/','+DATADG/'
*.nls_language='AMERICAN'
*.nls_territ
ory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=782m
*.processes=1000
*.remote_login_passwordfile='exclusive'
*.sga_target=2346m
*.standby_file_management='AUTO'
prod2.thread=2
prod1.thread=1
prod1.undo_tablespace='UNDOTBS1'
prod2.undo_tablespace='UNDOTBS2'
[oracle@oracle204 dbs]$


修改後的參 數檔案,刪掉恢復回來的spfile

[oracle@oracle204 dbs]$ pwd
/u01/app/oracle/product/19c/db_1/dbs
[oracle@oracle204 dbs]$ cat initprod.ora
*.audit_file_dest='/u01/app/oracle/admin/prod/adump'
*.audit_trail='db'
*.compatible='19.0.0'
*.control_files='/u01/app/oracle/oradata/control01.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/'
*.db_create_online_log_dest_1='/u01/app/oracle/oradata/'
*.db_file_name_convert='+DATADG/','/u01/app/oracle/oradata/'
*.db_name='prod'
*.db_unique_name='prod'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=prodXDB)'
*.enable_pluggable_database=true
*.log_archive_dest_1='LOCATION=/u01/app/oracle/oradata/'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=8
*.log_file_name_convert='+DATADG/','/u01/app/oracle/oradata/'
*.open_cursors=300
*.pga_aggregate_target=782m
*.processes=1000
*.remote_login_passwordfile='exclusive'
*.sga_target=2346m
[oracle@oracle204 dbs]$


透過新的修改的pfile重新啟動資料庫到nomount狀態

SQL> startup nomount;
ORACLE instance started.
Total System Global Area 2466247664 bytes
Fixed Size                  9139184 bytes
Variable Size             536870912 bytes
Database Buffers         1912602624 bytes
Redo Buffers                7634944 bytes
SQL>

透過修改的pfile建立spfile,並重新透過spfile啟動到nomount狀態。

SQL> create spfile from pfile;
File created.
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup nomount;



恢復控制檔案

RMAN> set dbid=496022129;
executing command: SET DBID
RMAN> run
{
allocate channel t1 type 'SBT_TAPE';
send 'NSR_ENV=( NSR_CLIENT=rac1-vip,NSR_SERVER=backserver,NSR_DATA_VOLUME_POOL=bstindex)';
restore controlfile  from autobackup;
release channel t1;
}2> 3> 4> 5> 6> 7>
using target database control file instead of recovery catalog
allocated channel: t1
channel t1: SID=781 device type=SBT_TAPE
channel t1: NMDA Oracle v19.2.1.2
sent command to channel: t1
Starting restore at 2021-12-07 14:32:17
channel t1: looking for AUTOBACKUP on day: 20211207
channel t1: AUTOBACKUP found: c-496022129-20211207-00
channel t1: restoring control file from AUTOBACKUP c-496022129-20211207-00
channel t1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/control01.ctl
Finished restore at 2021-12-07 14:42:33
released channel: t1
RMAN>



啟動資料庫到mount狀態,list backup可以檢視記錄在控制檔案中的備份

RMAN> alter database mount;
Statement processed
RMAN> list backup;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
34      Full    1.47G      SBT_TAPE    00:00:46     2021-12-06 16:41:12
        BP Key: 34   Status: AVAILABLE  Compressed: NO  Tag: TAG20211206T164026
        Handle: 230g2frq_1_1   Media: bstindex.001
  List of Datafiles in backup set 34
  File LV Type Ckp SCN    Ckp Time            Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- ------------------- ----------- ------ ----
  3       Full 12810654   2021-12-06 16:40:27              NO    +DATADG/PROD/DATAFILE/sysaux.258.1084183683
  7       Full 12810654   2021-12-06 16:40:27              NO    +DATADG/PROD/DATAFILE/users.260.1084183711
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
35      Full    1.22G      SBT_TAPE    00:00:45     2021-12-06 16:41:12
        BP Key: 35   Status: AVAILABLE  Compressed: NO  Tag: TAG20211206T164026
        Handle: 240g2frr_1_1   Media: bstindex.001
  List of Datafiles in backup set 35
  File LV Type Ckp SCN    Ckp Time            Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- ------------------- ----------- ------ ----
  1       Full 12810661   2021-12-06 16:40:27              NO    +DATADG/PROD/DATAFILE/system.257.1084183629
  4       Full 12810661   2021-12-06 16:40:27              NO    +DATADG/PROD/DATAFILE/undotbs1.259.1084183709
  9       Full 12810661   2021-12-06 16:40:27              NO    +DATADG/PROD/DATAFILE/undotbs2.269.1084184569


restore database

因為我spfile裡面已經設定了,如果沒有設定,需要在rman恢復指令碼里自己指定檔案轉換

db_file_name_convert  和  db_file_name_convert引數會自動轉換asm路徑檔案到本地路徑

所以直接restore database

RMAN> run
{
allocate channel t1 type 'SBT_TAPE';
2> 3> 4> allocate channel t2 type 'SBT_TAPE';
allocate channel t3 type 'SBT_TAPE';
allocate channel t4 type 'SB5> T_TAPE';
send 'NSR_ENV=( NSR_CLIENT=rac1-vip,NSR_SERVER=backserver,NSR_DATA_VOLUME_POOL=bstindex)';
6> 7> 8> restore database ;
9> release channel t1;
release channel t2;
10> 11> release channel t3;
release channel t4;
12> 13> }
allocated channel: t1
channel t1: SID=18 device type=SBT_TAPE
channel t1: NMDA Oracle v19.2.1.2
allocated channel: t2
channel t2: SID=19 device type=SBT_TAPE
channel t2: NMDA Oracle v19.2.1.2
allocated channel: t3
channel t3: SID=786 device type=SBT_TAPE
channel t3: NMDA Oracle v19.2.1.2
allocated channel: t4
channel t4: SID=26 device type=SBT_TAPE
channel t4: NMDA Oracle v19.2.1.2
sent command to channel: t1
sent command to channel: t2
sent command to channel: t3
sent command to channel: t4
Starting restore at 2021-12-07 14:47:17
channel t1: starting datafile backup set restore
channel t1: specifying datafile(s) to restore from backup set
channel t1: restoring datafile 00001 to +DATADG/PROD/DATAFILE/system.257.1084183629
channel t1: restoring datafile 00004 to +DATADG/PROD/DATAFILE/undotbs1.259.1084183709
channel t1: restoring datafile 00009 to +DATADG/PROD/DATAFILE/undotbs2.269.1084184569
channel t1: reading from backup piece 300g4cqf_1_1
channel t2: starting datafile backup set restore
channel t2: specifying datafile(s) to restore from backup set
channel t2: restoring datafile 00003 to +DATADG/PROD/DATAFILE/sysaux.258.1084183683
channel t2: restoring datafile 00007 to +DATADG/PROD/DATAFILE/users.260.1084183711
channel t2: reading from backup piece 2v0g4cqf_1_1
channel t3: starting datafile backup set restore
channel t3: specifying datafile(s) to restore from backup set
channel t3: restoring datafile 00011 to +DATADG/PROD/CCC9B4B0A1183CDAE0536862080A56C6/DATAFILE/sysaux.275.1084185285
channel t3: restoring datafile 00013 to +DATADG/PROD/CCC9B4B0A1183CDAE0536862080A56C6/DATAFILE/undo_2.277.1084185339
channel t3: restoring datafile 00014 to +DATADG/PROD/CCC9B4B0A1183CDAE0536862080A56C6/DATAFILE/users.278.1084185359
channel t3: restoring datafile 00016 to +DATADG/PROD/CCC9B4B0A1183CDAE0536862080A56C6/DATAFILE/haifeng.284.1088964183
channel t3: reading from backup piece 310g4crl_1_1
channel t4: starting datafile backup set restore
channel t4: specifying datafile(s) to restore from backup set
channel t4: restoring datafile 00005 to +DATADG/PROD/86B637B62FE07A65E053F706E80A27CA/DATAFILE/system.265.1084184215
channel t4: restoring datafile 00008 to +DATADG/PROD/86B637B62FE07A65E053F706E80A27CA/DATAFILE/undotbs1.267.1084184215
channel t4: reading from backup piece 330g4cs6_1_1
channel t3: piece handle=310g4crl_1_1 tag=TAG20211207T100046
channel t3: restored backup piece 1
channel t3: restore complete, elapsed time: 00:10:15
channel t3: starting datafile backup set restore
channel t3: specifying datafile(s) to restore from backup set
channel t3: restoring datafile 00010 to +DATADG/PROD/CCC9B4B0A1183CDAE0536862080A56C6/DATAFILE/system.274.1084185285
channel t3: restoring datafile 00012 to +DATADG/PROD/CCC9B4B0A1183CDAE0536862080A56C6/DATAFILE/undotbs1.273.1084185285
channel t3: restoring datafile 00015 to +DATADG/PROD/CCC9B4B0A1183CDAE0536862080A56C6/DATAFILE/gdd.283.1088962699
channel t3: reading from backup piece 320g4cs6_1_1
channel t4: piece handle=330g4cs6_1_1 tag=TAG20211207T100046
channel t4: restored backup piece 1
channel t4: restore complete, elapsed time: 00:10:15
channel t4: starting datafile backup set restore
channel t4: specifying datafile(s) to restore from backup set
channel t4: restoring datafile 00006 to +DATADG/PROD/86B637B62FE07A65E053F706E80A27CA/DATAFILE/sysaux.266.1084184215
channel t4: reading from backup piece 340g4csm_1_1
channel t1: piece handle=300g4cqf_1_1 tag=TAG20211207T100046
channel t1: restored backup piece 1
channel t1: restore complete, elapsed time: 00:10:22
channel t2: piece handle=2v0g4cqf_1_1 tag=TAG20211207T100046
channel t2: restored backup piece 1
channel t2: restore complete, elapsed time: 00:10:22
channel t3: piece handle=320g4cs6_1_1 tag=TAG20211207T100046
channel t3: restored backup piece 1
channel t3: restore complete, elapsed time: 00:10:15
channel t4: piece handle=340g4csm_1_1 tag=TAG20211207T100046
channel t4: restored backup piece 1
channel t4: restore complete, elapsed time: 00:10:15
Finished restore at 2021-12-07 15:07:48
released channel: t1
released channel: t2
released channel: t3
released channel: t4
RMAN>


recover database

RMAN> run
{
allocate channel t1 type 'SBT_TAPE';
send 'NSR_ENV=( NSR_CLIENT=rac1-vip,NSR_SERVER=backserver,NSR_DATA_VOLUME_POOL=bstindex)';
recover database  ;
release channel t1;
}2> 3> 4> 5> 6> 7>
allocated channel: t1
channel t1: SID=18 device type=SBT_TAPE
channel t1: NMDA Oracle v19.2.1.2
sent command to channel: t1
Starting recover at 2021-12-07 15:10:37
starting media recovery
channel t1: starting archived log restore to default destination
channel t1: restoring archived log
archived log thread=2 sequence=82
channel t1: reading from backup piece 350g4ct1_1_1
channel t1: piece handle=350g4ct1_1_1 tag=TAG20211207T100209
channel t1: restored backup piece 1
channel t1: restore complete, elapsed time: 00:10:15
channel t1: starting archived log restore to default destination
channel t1: restoring archived log
archived log thread=1 sequence=104
channel t1: reading from backup piece 360g4ct1_1_1
channel t1: piece handle=360g4ct1_1_1 tag=TAG20211207T100209
channel t1: restored backup piece 1
channel t1: restore complete, elapsed time: 00:10:05
archived log file name=/u01/app/oracle/oradata/1_104_1084183797.arc thread=1 sequence=104
archived log file name=/u01/app/oracle/oradata/2_82_1084183797.arc thread=2 sequence=82
unable to find archived log
archived log thread=2 sequence=83
released channel: t1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/07/2021 15:30:58
RMAN-06054: media recovery requesting unknown archived log for thread 2 with sequence 83 and starting SCN of 13050409
RMAN>


根據最後一句報錯,調整恢復rman語句

RMAN> run
{
allocate channel t1 type 'SBT_TAPE';
send 'NSR_ENV=( NSR_CLIENT=rac1-vip,NSR_SERVER=backserver,NSR_DATA_VOLUME_POOL=bstindex)';
recover database until scn  13050409 ;
release channel t1;
}2> 3> 4> 5> 6> 7>
allocated channel: t1
channel t1: SID=18 device type=SBT_TAPE
channel t1: NMDA Oracle v19.2.1.2
sent command to channel: t1
Starting recover at 2021-12-07 15:33:13
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 2021-12-07 15:33:14
released channel: t1
RMAN>


resetlogs 模式開啟資料庫

RMAN> alter database open resetlogs;
Statement processed
RMAN>



查詢rac備份恢復到單機的資料庫檔案。

SQL> select name from v$datafile;
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD/datafile/o1_mf_system_jty1gp48_.dbf
/u01/app/oracle/oradata/PROD/datafile/o1_mf_sysaux_jty1gowk_.dbf
/u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs1_jty1gpb9_.dbf
/u01/app/oracle/oradata/PROD/CCC9746D268F19F9E0536762080AE444/datafile/o1_mf_system_jty1gpbs_.dbf
/u01/app/oracle/oradata/PROD/CCC9746D268F19F9E0536762080AE444/datafile/o1_mf_sysaux_jty21r2j_.dbf
/u01/app/oracle/oradata/PROD/datafile/o1_mf_users_jty1gp4t_.dbf
/u01/app/oracle/oradata/PROD/CCC9746D268F19F9E0536762080AE444/datafile/o1_mf_undotbs1_jty1gpfz_.dbf
/u01/app/oracle/oradata/PROD/datafile/o1_mf_undotbs2_jty1gpg0_.dbf
/u01/app/oracle/oradata/PROD/CCC9B4B0A1183CDAE0536862080A56C6/datafile/o1_mf_system_jty21qtc_.dbf
/u01/app/oracle/oradata/PROD/CCC9B4B0A1183CDAE0536862080A56C6/datafile/o1_mf_sysaux_jty1goor_.dbf
/u01/app/oracle/oradata/PROD/CCC9B4B0A1183CDAE0536862080A56C6/datafile/o1_mf_undotbs1_jty21r5r_.dbf
/u01/app/oracle/oradata/PROD/CCC9B4B0A1183CDAE0536862080A56C6/datafile/o1_mf_undo_2_jty1gowg_.dbf
/u01/app/oracle/oradata/PROD/CCC9B4B0A1183CDAE0536862080A56C6/datafile/o1_mf_users_jty1gp08_.dbf
/u01/app/oracle/oradata/PROD/CCC9B4B0A1183CDAE0536862080A56C6/datafile/o1_mf_gdd_jty21r95_.dbf
/u01/app/oracle/oradata/PROD/CCC9B4B0A1183CDAE0536862080A56C6/datafile/o1_mf_haifeng_jty1gowx_.dbf
15 rows selected.
SQL>


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

相關文章