码迷,mamicode.com
首页 > 数据库 > 详细

Oracle RMAN 异机恢复一例

时间:2017-10-25 11:31:00      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:bit   terminal   mode   location   使用   dbi   运行   /tmp   hang   

背景介绍:本例需求是将NBU备份的oracle数据库恢复到另一主机上。

NBU环境配置、异机上的Oracle软件安装配置忽略,下面只介绍OracleDB恢复的过程。

 

----------------------------------------------------------------------------------------------------
----1.  Master Server端添加允许异地恢复文件

touch /usr/openv/netbackup/db/altnames/No.Restrictions
chmod 777 /usr/openv/netbackup/db/altnames/No.Restrictions


----------------------------------------------------------------------------------------------------
----2.  客户端重新启动nbu client服务
d3oeedb1@root[/usr/openv/netbackup/bin/goodies] /usr/openv/netbackup/bin/goodies/netbackup stop
d3oeedb1@root[/usr/openv/netbackup/bin/goodies] /usr/openv/netbackup/bin/goodies/netbackup start


----------------------------------------------------------------------------------------------------
----3.  在恢复客户端列出备份客户端的备份:
d3oeedb1@oracle[/usr/openv/netbackup/bin]/usr/openv/netbackup/bin/bplist -C p3fabdb2 -t 4 -R /

/c-3228927279-20170810-01                      ----第6步会用到这里的命令返回结果dbid。
/ctrl_dP3FABDB_u1bsbh07h_s14379_p1_t951615729  ----第6步会用到这里的命令返回结果。

 


----------------------------------------------------------------------------------------------------
----4.  创建参数文件
d3oeedb1@root[]
su - oracle
cd /oracle/product/11.2.0/dbs
vi $ORACLE_HOME/dbs/initp3fabdb.ora
db_name=p3fabdb
log_archive_dest_1=‘LOCATION=/rmandb2/p3fabdb‘
processes=2000
db_files=3000


d3oeedb1@oracle[/oracle/product/11.2.0/dbs]cat $ORACLE_HOME/dbs/initp3fabdb.ora
db_name=p3fabdb
log_archive_dest_1=‘LOCATION=/rmandb2/p3fabdb‘
processes=2000
db_files=3000


----------------------------------------------------------------------------------------------------
----5. 启动实例到no mount 状态(这个sqlplus 的terminal窗口不要关闭,恢复过程中还会用到)

d3oeedb1@oracle[/oracle/product/11.2.0/dbs]export ORACLE_SID=p3fabdb
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]unset ORACLE_UNQNAME
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]sqlplus / as sysdba

SYS@p3fabdb> startup nomount;

 

----------------------------------------------------------------------------------------------------
----6. 开启第二个terminal窗口,开启rman接口,恢复控制文件

------ 注意: 此方式是基于控制文件的恢复方式;若使用 catalog目录库备份的,那么必须使用 catalog库来恢复,下见6.1步。
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]export ORACLE_SID=p3fabdb
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]unset ORACLE_UNQNAME
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]rman target /
RMAN> set dbid 3228927279


-------说明运行恢复控制文件命令如下:
rman target /
run {
  allocate channel t2 DEVICE TYPE ‘SBT_TAPE‘
  PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
  SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;  [--clientname为备份节点name。]
  restore controlfile from ‘ctrl_dP3FABDB_u1bsbh07h_s14379_p1_t951615729‘; [--此处控制文件备份集选自第三步中bplist命令结果中,最高的ctrl文件备份。]
  release channel t2;
}


-------恢复窗口如下:
RMAN> run {
allocate channel t2 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
restore controlfile from ‘ctrl_dP3FABDB_u1bsbh07h_s14379_p1_t951615729‘;
release channel t2;
}

run {
allocate channel t2 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
restore controlfile from ‘ctrl_dP3FABDB_u1bsbh07h_s14379_p1_t951615729‘;
release channel t2;
}


------------------------------------------------------------------------------------------------------
------6.1  基于 catalog 库的 恢复 方式
------------------------------------------------------------------------------------------------------
------- sqlplus rman/rman@oracat
----  rman target / catalog rman/rman@oracat
----  rman target / catalog rman/rman@CATALOG


----6.1.1 开启第二个terminal窗口,开启rman接口,恢复控制文件

d3oeedb1@oracle[/oracle/product/11.2.0/dbs]export ORACLE_SID=p3fabdb
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]unset ORACLE_UNQNAME
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]rman target / catalog rman/rman@oracat
RMAN> 


-------说明运行恢复控制文件命令如下:
run {
  allocate channel t2 DEVICE TYPE ‘SBT_TAPE‘
  PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
  SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;  [--clientname为备份节点name。]
  restore controlfile from ‘ctrl_dP3FABDB_u1bsbh07h_s14379_p1_t951615729‘; [--此处控制文件备份集选自第三步中bplist命令结果中,最高的ctrl文件备份。]
  release channel t2;
}


-------恢复窗口如下:

run {
allocate channel t2 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
restore controlfile from ‘ctrl_dP3FABDB_u1bsbh07h_s14379_p1_t951615729‘;
release channel t2;
}

 

----------------------------------------------------------------------------------------------------
----7. 将恢复到默认目录的控制文件复制到恢复目录  /rmandb2/p3fabdb


d3oeedb1@oracle[/rmandb2/p3fabdb] cp /oracle/product/11.2.0/dbs/cntrlp3fabdb.dbf /rmandb2/p3fabdb/control01.dbf
d3oeedb1@oracle[/rmandb2/p3fabdb] cp /oracle/product/11.2.0/dbs/cntrlp3fabdb.dbf /rmandb2/p3fabdb/control02.dbf


----------------------------------------------------------------------------------------------------
----8. 修改参数文件增加控制文件参数,并生成spfile,从spfile启动
d3oeedb1@oracle[/oracle/product/11.2.0/dbs] vi $ORACLE_HOME/dbs/initp3fabdb.ora
增加下列行
control_files=‘/rmandb2/p3fabdb/control01.dbf‘,‘/rmandb2/p3fabdb/control02.dbf‘
compatible=‘11.2.0.4.0‘


-------
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]export ORACLE_SID=p3fabdb
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]unset ORACLE_UNQNAME
d3oeedb1@oracle[/oracle/product/11.2.0/dbs]sqlplus / as sysdba

SYS@p3fabdb>create spfile from pfile;
SYS@p3fabdb> shutdown immediate;
ORA-01507: database not mounted

SYS@p3fabdb> startup nomount
ORACLE instance started.


SYS@p3fabdb> alter database mount;

 

SYS@p3fabdb> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /oracle/product/11.2.0/dbs/spfilep3fabdb.ora


----------------------------------------------------------------------------------------------------
----9. 查询logfile name,rename logfile name
SYS@p3fabdb> col member for a60
SYS@p3fabdb> select * from v$logfile;

 
    ------ 说明: 此时 数据库处于 mount 状态,下面 alter database rename file... 在修改控制文件中的redolog参数
   ------ 手工生成rename logfile脚本并于SQLPLUS窗口运行:
SYS@p3fabdb>
    alter database rename file ‘/fab_redo/p3fabdb/redo01.log‘              to ‘/rmandb2/p3fabdb/redo01.log‘;
    alter database rename file ‘/fab_redo/p3fabdb/redo02.log‘              to ‘/rmandb2/p3fabdb/redo02.log‘;
    alter database rename file ‘/fab_redo/p3fabdb/redo05.log‘              to ‘/rmandb2/p3fabdb/redo03.log‘;
    alter database rename file ‘/fab_data/fab_data01/p3fabdb/redo07_1.log‘ to ‘/rmandb2/p3fabdb/redo04.log‘;
    alter database rename file ‘/fab_data/fab_data01/p3fabdb/redo07_2.log‘ to ‘/rmandb2/p3fabdb/redo05.log‘;
    alter database rename file ‘/fab_redo/p3fabdb/redo03.log‘              to ‘/rmandb2/p3fabdb/redo06.log‘;
    alter database rename file ‘/fab_redo/p3fabdb/redo04.log‘              to ‘/rmandb2/p3fabdb/redo07.log‘;
    alter database rename file ‘/fab_data/fab_data01/p3fabdb/redo01_2.log‘ to ‘/rmandb2/p3fabdb/redo08.log‘;
    alter database rename file ‘/fab_data/fab_data01/p3fabdb/redo02_2.log‘ to ‘/rmandb2/p3fabdb/redo09.log‘;
    alter database rename file ‘/fab_data/fab_data01/p3fabdb/redo03_2.log‘ to ‘/rmandb2/p3fabdb/redo10.log‘;
    alter database rename file ‘/fab_data/fab_data01/p3fabdb/redo04_2.log‘ to ‘/rmandb2/p3fabdb/redo11.log‘;
    alter database rename file ‘/fab_data/fab_data01/p3fabdb/redo05_2.log‘ to ‘/rmandb2/p3fabdb/redo12.log‘;

 

  
  ------再 查询logfile name
SYS@p3fabdb> select * from v$logfile;

    ------查看当前控制文件scn
SYS@p3fabdb> select to_char(checkpoint_change#),current_scn from v$database;    ---- (当前恢复用控制文件scn)
13406695558607    ---- 此 SCN 会在 第12步 用到 : recover database until scn 13406695558607;

 


----------------------------------------------------------------------------------------------------
----10. 编写restore脚本,并在rman窗口的shell提示符下运行脚本
d3oeedb1@oracle[/rmandb2/p3fabdb] vi /tmp/nbutest/cmdfile_fab

run {
allocate channel t2 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t3 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t4 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t5 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t6 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t7 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
set newname for database to ‘/rmandb2/p3fabdb/%b‘;   ---- 此处用于恢复所有文件,到与备份主机数据文件所在的单个不同目录;如果恢复到多个目录,并且与原主机不同需要分别为每个datafile set newname;如果恢复至相同目录或相同名称的ASM磁盘组,不需要指定,下面的switch datafile all也不需要;如果是恢复至不同的ASM磁盘组,直接指定磁盘组名称即可。
restore database;
switch datafile all;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
release channel t6;
release channel t7;
}

 


------ 执行 cmdfile
d3oeedb1@oracle[/rmandb2/p3fabdb]export ORACLE_SID=p3fabdb
d3oeedb1@oracle[/rmandb2/p3fabdb]unset ORACLE_UNQNAME
d3oeedb1@oracle[/rmandb2/p3fabdb] nohup rman target / catalog rman/rman@oracat cmdfile=/tmp/nbutest/cmdfile_fab &

 

----------------------------------------------------------------------------------------------------
----11.  观察nohup.out直到出现“Recovery Manager complete.”字样

d3oeedb1@oracle[/rmandb2/p3fabdb]cat nohup.out

......
released channel: t7

Recovery Manager complete.

 

 

-----------------------------------------------------------------------------------------------
------ 11.1   处理p3fabdb数据库restore过程中ORA-19563的错误 ----- 数据文件名一样导致的错误
查询:
select substr(file_name,30) AS f ,count(1) from dba_data_files  group by substr(file_name,30) having count(1) > 1

 FEM_PRDHIST_DAT18.dbf 2
 FEM_PRDHIST_DAT17.dbf 2

查询:
select file_name,file_ID,tablespace_name from dba_data_files where substr(file_name,30) IN (‘FEM_PRDHIST_DAT18.dbf‘,‘FEM_PRDHIST_DAT17.dbf‘);

FILE_NAME FILE_ID TABLESPACE_NAME
/fab_data/fab_data05/p3fabdb/FEM_PRDHIST_DAT17.dbf 125 FEM_PRDHIST_DAT
/fab_data/fab_data05/p3fabdb/FEM_PRDHIST_DAT18.dbf 126 FEM_PRDHIST_DAT
/fab_data/fab_data06/p3fabdb/FEM_PRDHIST_DAT17.dbf 151 FEM_PRDHIST_DAT
/fab_data/fab_data06/p3fabdb/FEM_PRDHIST_DAT18.dbf 153 FEM_PRDHIST_DAT
 

-----  11.2 编写 处理数据文件名一样 的 restore脚本,并在rman窗口的shell提示符下运行脚本
-----       select ‘set newname for datafile ‘ || file_ID || ‘ to ‘ ||
-----       ‘"/rmandb2/p3fabdb/‘ || trim(substr(file_name, 30)) || ‘";‘
-----       from dba_data_files
-----       order by file_id;
-----     

d3oeedb1@oracle[/rmandb2/p3fabdb] vi /tmp/nbutest/cmdfile_fab_re

run {
allocate channel t2 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t3 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t4 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t5 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t6 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t7 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;

set newname for datafile 1 to "/rmandb2/p3fabdb/system01.dbf";
set newname for datafile 2 to "/rmandb2/p3fabdb/sysaux01.dbf";
set newname for datafile 3 to "/rmandb2/p3fabdb/undotbs01.dbf";
set newname for datafile 4 to "/rmandb2/p3fabdb/undotbs02.dbf";
set newname for datafile 5 to "/rmandb2/p3fabdb/users01.dbf";
set newname for datafile 6 to "/rmandb2/p3fabdb/undotbs01_01.dbf";
set newname for datafile 7 to "/rmandb2/p3fabdb/undotbs02_01.dbf";
set newname for datafile 8 to "/rmandb2/p3fabdb/FEM_CUSTOMS_DAT01.dbf";
set newname for datafile 9 to "/rmandb2/p3fabdb/FEM_CUSTOMS_IDX01.dbf";
set newname for datafile 10 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT01.dbf";
set newname for datafile 11 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX01.dbf";
set newname for datafile 12 to "/rmandb2/p3fabdb/FEM_LOTHIST_DAT01.dbf";
set newname for datafile 13 to "/rmandb2/p3fabdb/FEM_LOTHIST_IDX01.dbf";
set newname for datafile 14 to "/rmandb2/p3fabdb/FEM_MACHIST_DAT01.dbf";
set newname for datafile 15 to "/rmandb2/p3fabdb/FEM_MACHIST_IDX01.dbf";
set newname for datafile 16 to "/rmandb2/p3fabdb/FEM_PARAL01_DAT01.dbf";
set newname for datafile 17 to "/rmandb2/p3fabdb/FEM_PARAL01_IDX01.dbf";
set newname for datafile 18 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT01.dbf";
set newname for datafile 19 to "/rmandb2/p3fabdb/FEM_PLOHIST_IDX01.dbf";
set newname for datafile 20 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT01.dbf";
set newname for datafile 21 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX01.dbf";
set newname for datafile 22 to "/rmandb2/p3fabdb/FEM_PRODRUN_DAT01.dbf";
set newname for datafile 23 to "/rmandb2/p3fabdb/FEM_PRODRUN_IDX01.dbf";
set newname for datafile 24 to "/rmandb2/p3fabdb/FEM_RUNTIME_DAT01.dbf";
set newname for datafile 25 to "/rmandb2/p3fabdb/FEM_RUNTIME_IDX01.dbf";
set newname for datafile 26 to "/rmandb2/p3fabdb/FEM_SPECTIM_DAT01.dbf";
set newname for datafile 27 to "/rmandb2/p3fabdb/FEM_SPECTIM_IDX01.dbf";
set newname for datafile 28 to "/rmandb2/p3fabdb/FEM_TRXHIST_DAT01.dbf";
set newname for datafile 29 to "/rmandb2/p3fabdb/FEM_TRXHIST_IDX01.dbf";
set newname for datafile 30 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT02.dbf";
set newname for datafile 31 to "/rmandb2/p3fabdb/FEM_PLOHIST_IDX02.dbf";
set newname for datafile 32 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT03.dbf";
set newname for datafile 33 to "/rmandb2/p3fabdb/FEM_PLOHIST_IDX03.dbf";
set newname for datafile 34 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT04.dbf";
set newname for datafile 35 to "/rmandb2/p3fabdb/FEM_PLOHIST_IDX04.dbf";
set newname for datafile 36 to "/rmandb2/p3fabdb/undotbs01_02.dbf";
set newname for datafile 37 to "/rmandb2/p3fabdb/undotbs01_03.dbf";
set newname for datafile 38 to "/rmandb2/p3fabdb/undotbs01_04.dbf";
set newname for datafile 39 to "/rmandb2/p3fabdb/undotbs01_05.dbf";
set newname for datafile 40 to "/rmandb2/p3fabdb/undotbs01_06.dbf";
set newname for datafile 41 to "/rmandb2/p3fabdb/undotbs01_07.dbf";
set newname for datafile 42 to "/rmandb2/p3fabdb/undotbs01_08.dbf";
set newname for datafile 43 to "/rmandb2/p3fabdb/undotbs01_09.dbf";
set newname for datafile 44 to "/rmandb2/p3fabdb/undotbs01_10.dbf";
set newname for datafile 45 to "/rmandb2/p3fabdb/undotbs01_11.dbf";
set newname for datafile 46 to "/rmandb2/p3fabdb/undotbs01_12.dbf";
set newname for datafile 47 to "/rmandb2/p3fabdb/undotbs01_13.dbf";
set newname for datafile 48 to "/rmandb2/p3fabdb/undotbs01_14.dbf";
set newname for datafile 49 to "/rmandb2/p3fabdb/undotbs01_15.dbf";
set newname for datafile 50 to "/rmandb2/p3fabdb/undotbs01_16.dbf";
set newname for datafile 51 to "/rmandb2/p3fabdb/undotbs01_17.dbf";
set newname for datafile 52 to "/rmandb2/p3fabdb/undotbs01_18.dbf";
set newname for datafile 53 to "/rmandb2/p3fabdb/undotbs01_19.dbf";
set newname for datafile 54 to "/rmandb2/p3fabdb/undotbs01_20.dbf";
set newname for datafile 55 to "/rmandb2/p3fabdb/undotbs02_02.dbf";
set newname for datafile 56 to "/rmandb2/p3fabdb/undotbs02_03.dbf";
set newname for datafile 57 to "/rmandb2/p3fabdb/undotbs02_04.dbf";
set newname for datafile 58 to "/rmandb2/p3fabdb/undotbs02_05.dbf";
set newname for datafile 59 to "/rmandb2/p3fabdb/undotbs02_06.dbf";
set newname for datafile 60 to "/rmandb2/p3fabdb/undotbs02_07.dbf";
set newname for datafile 61 to "/rmandb2/p3fabdb/undotbs02_08.dbf";
set newname for datafile 62 to "/rmandb2/p3fabdb/undotbs02_09.dbf";
set newname for datafile 63 to "/rmandb2/p3fabdb/undotbs02_10.dbf";
set newname for datafile 64 to "/rmandb2/p3fabdb/undotbs02_11.dbf";
set newname for datafile 65 to "/rmandb2/p3fabdb/undotbs02_12.dbf";
set newname for datafile 66 to "/rmandb2/p3fabdb/undotbs02_13.dbf";
set newname for datafile 67 to "/rmandb2/p3fabdb/undotbs02_14.dbf";
set newname for datafile 68 to "/rmandb2/p3fabdb/undotbs02_15.dbf";
set newname for datafile 69 to "/rmandb2/p3fabdb/undotbs02_16.dbf";
set newname for datafile 70 to "/rmandb2/p3fabdb/undotbs02_17.dbf";
set newname for datafile 71 to "/rmandb2/p3fabdb/undotbs02_18.dbf";
set newname for datafile 72 to "/rmandb2/p3fabdb/undotbs02_19.dbf";
set newname for datafile 73 to "/rmandb2/p3fabdb/undotbs02_20.dbf";
set newname for datafile 74 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT05.dbf";
set newname for datafile 75 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT06.dbf";
set newname for datafile 76 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT07.dbf";
set newname for datafile 77 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT08.dbf";
set newname for datafile 78 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT09.dbf";
set newname for datafile 79 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT10.dbf";
set newname for datafile 80 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT11.dbf";
set newname for datafile 81 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT12.dbf";
set newname for datafile 82 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT13.dbf";
set newname for datafile 83 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT14.dbf";
set newname for datafile 84 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT15.dbf";
set newname for datafile 85 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT16.dbf";
set newname for datafile 86 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT02.dbf";
set newname for datafile 87 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT03.dbf";
set newname for datafile 88 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT04.dbf";
set newname for datafile 89 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT05.dbf";
set newname for datafile 90 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT06.dbf";
set newname for datafile 91 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT07.dbf";
set newname for datafile 92 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT08.dbf";
set newname for datafile 93 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT09.dbf";
set newname for datafile 94 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT10.dbf";
set newname for datafile 95 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT02.dbf";
set newname for datafile 96 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX02.dbf";
set newname for datafile 97 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX02.dbf";
set newname for datafile 98 to "/rmandb2/p3fabdb/FEM_LOTHIST_DAT02.dbf";
set newname for datafile 99 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT03.dbf";
set newname for datafile 100 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT04.dbf";
set newname for datafile 101 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT05.dbf";
set newname for datafile 102 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX03.dbf";
set newname for datafile 103 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX04.dbf";
set newname for datafile 104 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX05.dbf";
set newname for datafile 105 to "/rmandb2/p3fabdb/FEM_CUSTOMS_DAT02.dbf";
set newname for datafile 106 to "/rmandb2/p3fabdb/FEM_CUSTOMS_DAT03.dbf";
set newname for datafile 107 to "/rmandb2/p3fabdb/FEM_CUSTOMS_DAT04.dbf";
set newname for datafile 108 to "/rmandb2/p3fabdb/FEM_CUSTOMS_DAT05.dbf";
set newname for datafile 109 to "/rmandb2/p3fabdb/FEM_CUSTOMS_IDX02.dbf";
set newname for datafile 110 to "/rmandb2/p3fabdb/FEM_CUSTOMS_IDX03.dbf";
set newname for datafile 111 to "/rmandb2/p3fabdb/FEM_CUSTOMS_IDX04.dbf";
set newname for datafile 112 to "/rmandb2/p3fabdb/FEM_CUSTOMS_IDX05.dbf";
set newname for datafile 113 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT11.dbf";
set newname for datafile 114 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT12.dbf";
set newname for datafile 115 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT13.dbf";
set newname for datafile 116 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT14.dbf";
set newname for datafile 117 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT15.dbf";
set newname for datafile 118 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX03.dbf";
set newname for datafile 119 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX04.dbf";
set newname for datafile 120 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX05.dbf";
set newname for datafile 121 to "/rmandb2/p3fabdb/FEM_LOTHIST_DAT03.dbf";
set newname for datafile 122 to "/rmandb2/p3fabdb/FEM_LOTHIST_DAT04.dbf";
set newname for datafile 123 to "/rmandb2/p3fabdb/FEM_LOTHIST_DAT05.dbf";
set newname for datafile 124 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT16.dbf";
set newname for datafile 125 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT17.dbf";
set newname for datafile 126 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT18.dbf";
set newname for datafile 127 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT19.dbf";
set newname for datafile 128 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT20.dbf";
set newname for datafile 129 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT17.dbf";
set newname for datafile 130 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT18.dbf";
set newname for datafile 131 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT19.dbf";
set newname for datafile 132 to "/rmandb2/p3fabdb/FEM_PLOHIST_DAT20.dbf";
set newname for datafile 133 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT21.dbf";
set newname for datafile 134 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT22.dbf";
set newname for datafile 135 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT23.dbf";
set newname for datafile 136 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT24.dbf";
set newname for datafile 137 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT25.dbf";
set newname for datafile 138 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT26.dbf";
set newname for datafile 139 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT27.dbf";
set newname for datafile 140 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT28.dbf";
set newname for datafile 141 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT29.dbf";
set newname for datafile 142 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT30.dbf";
set newname for datafile 143 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT31.dbf";
set newname for datafile 144 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT32.dbf";
set newname for datafile 145 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX06.dbf";
set newname for datafile 146 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX07.dbf";
set newname for datafile 147 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX08.dbf";
set newname for datafile 148 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX09.dbf";
set newname for datafile 149 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX10.dbf";
set newname for datafile 150 to "/rmandb2/p3fabdb/SYS_AUD_01.dbf";
set newname for datafile 151 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT17_02.dbf";
set newname for datafile 152 to "/rmandb2/p3fabdb/FEM_PRODRUN_DAT02.dbf";
set newname for datafile 153 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT18_02.dbf";
set newname for datafile 154 to "/rmandb2/p3fabdb/FEM_SPECTIM_DAT02.dbf";
set newname for datafile 155 to "/rmandb2/p3fabdb/FEM_TRXHIST_DAT02.dbf";
set newname for datafile 156 to "/rmandb2/p3fabdb/FEM_MACHIST_DAT02.dbf";
set newname for datafile 157 to "/rmandb2/p3fabdb/whstable.dbf";
set newname for datafile 158 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT35.dbf";
set newname for datafile 159 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT36.dbf";
set newname for datafile 160 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT37.dbf";
set newname for datafile 161 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT38.dbf";
set newname for datafile 162 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT39.dbf";
set newname for datafile 163 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT40.dbf";
set newname for datafile 164 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX06.dbf";
set newname for datafile 165 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX07.dbf";
set newname for datafile 166 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX08.dbf";
set newname for datafile 167 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX09.dbf";
set newname for datafile 168 to "/rmandb2/p3fabdb/FEM_PRDHIST_IDX10.dbf";
set newname for datafile 169 to "/rmandb2/p3fabdb/FEM_PARAL01_DAT02.dbf";
set newname for datafile 170 to "/rmandb2/p3fabdb/FEM_PARAL01_DAT03.dbf";
set newname for datafile 171 to "/rmandb2/p3fabdb/FEM_PARAL01_IDX02.dbf";
set newname for datafile 172 to "/rmandb2/p3fabdb/FEM_PARAL01_IDX03.dbf";
set newname for datafile 173 to "/rmandb2/p3fabdb/FEM_LOTHIST_IDX02.dbf";
set newname for datafile 174 to "/rmandb2/p3fabdb/FEM_PRODRUN_IDX02.dbf";
set newname for datafile 175 to "/rmandb2/p3fabdb/FEM_SPECTIM_IDX02.dbf";
set newname for datafile 176 to "/rmandb2/p3fabdb/FEM_MACHIST_IDX02.dbf";
set newname for datafile 177 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT06.dbf";
set newname for datafile 178 to "/rmandb2/p3fabdb/FEM_TRXHIST_IDX02.dbf";
set newname for datafile 179 to "/rmandb2/p3fabdb/FEM_LOTHIST_DAT06.dbf";
set newname for datafile 180 to "/rmandb2/p3fabdb/FEM_SPECTIM_DAT03.dbf";
set newname for datafile 181 to "/rmandb2/p3fabdb/FEM_SPECTIM_DAT04.dbf";
set newname for datafile 182 to "/rmandb2/p3fabdb/FEM_SPECTIM_DAT05.dbf";
set newname for datafile 183 to "/rmandb2/p3fabdb/FEM_SPECTIM_IDX03.dbf";
set newname for datafile 184 to "/rmandb2/p3fabdb/FEM_SPECTIM_IDX04.dbf";
set newname for datafile 185 to "/rmandb2/p3fabdb/FEM_SPECTIM_IDX05.dbf";
set newname for datafile 186 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT41.dbf";
set newname for datafile 187 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT42.dbf";
set newname for datafile 188 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT43.dbf";
set newname for datafile 189 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT44.dbf";
set newname for datafile 190 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT45.dbf";
set newname for datafile 191 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT46.dbf";
set newname for datafile 192 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT47.dbf";
set newname for datafile 193 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT48.dbf";
set newname for datafile 194 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT49.dbf";
set newname for datafile 195 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT50.dbf";
set newname for datafile 196 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT51.dbf";
set newname for datafile 197 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT52.dbf";
set newname for datafile 198 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT53.dbf";
set newname for datafile 199 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT54.dbf";
set newname for datafile 200 to "/rmandb2/p3fabdb/FEM_PRDHIST_DAT55.dbf";
set newname for datafile 201 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT07.dbf";
set newname for datafile 202 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT08.dbf";
set newname for datafile 203 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT09.dbf";
set newname for datafile 204 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT11.dbf";
set newname for datafile 205 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT12.dbf";
set newname for datafile 206 to "/rmandb2/p3fabdb/FEM_DCOLRES_DAT13.dbf";
set newname for datafile 207 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX11.dbf";
set newname for datafile 208 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX12.dbf";
set newname for datafile 209 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX13.dbf";
set newname for datafile 210 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX14.dbf";
set newname for datafile 211 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX15.dbf";
set newname for datafile 212 to "/rmandb2/p3fabdb/FEM_DCOLRES_IDX16.dbf";

restore database;
switch datafile all;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
release channel t6;
release channel t7;
}

------ 执行 cmdfile
d3oeedb1@oracle[/rmandb2/p3fabdb]export ORACLE_SID=p3fabdb
d3oeedb1@oracle[/rmandb2/p3fabdb]unset ORACLE_UNQNAME
d3oeedb1@oracle[/rmandb2/p3fabdb] nohup rman target / catalog rman/rman@oracat cmdfile=/tmp/nbutest/cmdfile_fab_re &


 ---- 观察nohup.out直到出现“Recovery Manager complete.”字样


----------------------------------------------------------------------------------------------------
----12.  编写recover 数据库脚本,并后台运行recover脚本

d3oeedb1@oracle[/rmandb2/p3fabdb]vi /tmp/nbutest/cmdfile2_fab

run {
allocate channel t2 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t3 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t4 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
allocate channel t5 DEVICE TYPE ‘SBT_TAPE‘ PARMS "SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so";
SEND ‘NB_ORA_SERV=p3bkmast, NB_ORA_CLIENT=p3fabdb2‘;
recover database until scn 13406695558607;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
}

d3oeedb1@oracle[/rmandb2/p3fabdb]export ORACLE_SID=p3fabdb
d3oeedb1@oracle[/rmandb2/p3fabdb]unset ORACLE_UNQNAME
d3oeedb1@oracle[/rmandb2/p3fabdb] nohup rman target / catalog rman/rman@oracat cmdfile=/tmp/nbutest/cmdfile2_fab &


---- nohup rman target / catalog rman/rman@oracat cmdfile=/tmp/nbutest/cmdfile3_fab &

 


----------------------------------------------------------------------------------------------------
----13.  观察nohup.out文件,直至再次出现” Recovery Manager complete.”字样

d3oeedb1@oracle[/rmandb2/p3fabdb]cat nohup.out

......
RMAN-03002: failure of recover command at 08/02/2017 15:51:39
RMAN-06053: unable to perform media recovery because of missing log
......
RMAN-06025: no backup of archived log for thread 1 with sequence 10247 and starting SCN of 13357444294718 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 10246 and starting SCN of 13357443421686 found to restore

Recovery Manager complete.

 

 

----------------------------------------------------------------------------------------------------------------------------------
----14.  基于SCN的恢复,可以直接以 open 方式打开数据库

d3oeedb1@oracle[/home/oracle] export ORACLE_SID=p3fabdb
d3oeedb1@oracle[/home/oracle] unset ORACLE_UNQNAME


d3oeedb1@oracle[/home/oracle]sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 2 16:11:40 2017

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


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

SYS@p3fabdb> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED


 -------注意:若源数据库 备份开启 块改变跟踪方式( BLOCK CHANGE TRACKING ) 备份,
 -------      恢复时遇到 错误,可以 在异机目标数据库mount状态下 关闭块改变跟踪属性,然后open数据库。
 -------      SQL> SELECT * FROM v$block_change_tracking;
 -------      SQL> alter database open resetlogs;
 -------          (说明: 以open resetlogs方式打开数据库(以openresetlogs方式打开库依照redo logfile的大小决定打开的时长;
 -------                  如果redo 过大,resetlogs时间可能会比较长,请耐心等待。)

SYS@p3fabdb> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;   ---- disable BLOCK CHANGE TRACKING  , then open database

SYS@p3fabdb> alter database open RESETLOGS;

Database altered.

  ------查看数据库打开状态
SYS@p3fabdb> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE


----------------------------------------------------------------------------------------------------------------------------------
----14.1  重启数据库确认数据库可以正常重启,观察到”database opend”表示数据库正常开启。 然后处理 临时表空间。
----      因为rman不备份临时表空间,打开数据库后,需要重建临时表空间
SYS@p3fabdb> col FILE_NAME for a50

SYS@p3fabdb> select tablespace_name from dba_tablespaces where tablespace_name like ‘%TEMP%‘;
             select tablespace_name , FILE_NAME from dba_temp_files;

SYS@p3fabdb>
    CREATE TEMPORARY TABLESPACE temp001 TEMPFILE ‘/rmandb2/p3fabdb/temp001.dbf‘ SIZE 200m autoextend on next 16M; ---- 创建新的 临时表空间
    ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp001;  ---- 设置新的 默认临时表空间
    DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES; ---- drop 掉旧的临时表空间

  ---- 验证数据库临时表空间
SYS@p3fabdb> col TABLESPACE_NAME for a30
             col FILE_NAME for a50
             select TABLESPACE_NAME, FILE_NAME from dba_temp_files;


----------------------------------------------------------------------------------------------------------------------------------
----15.  重启数据库确认数据库可以正常重启,观察到”database opend”表示数据库正常开启。
----   (此处如果是RAC库,需要在第二个节点alter database open即可)

SYS@p3fabdb> shutdown immediate;

SYS@p3fabdb> startup;

SYS@p3fabdb> col db_name for a30
             col host for a30
    SELECT SYS_CONTEXT(‘USERENV‘,‘DB_NAME‘) db_name,SYS_CONTEXT(‘USERENV‘,‘HOST‘) host FROM DUAL;
    select count(1) from dba_tables where owner=‘P3MESFAB‘;
    select sum(bytes)/1024/1024/1024 DBSIZE_GB from dba_segments;


----------------------------------------------------------------------------------------------------------------------------------
----16.  联系业务校验数据完整性
----------------------------------------------------------------------------------------------------------------------------------

 

Oracle RMAN 异机恢复一例

标签:bit   terminal   mode   location   使用   dbi   运行   /tmp   hang   

原文地址:http://www.cnblogs.com/lipeng20004/p/7727049.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!