签到成功

知道了

CNDBA社区CNDBA社区

RMAN异机恢复(10.2.0.1--10.2.0.4--11.2.0.4)

2018-04-02 17:42 2848 0 原创 数据库升级
作者: Marvinn

RMAN异机恢复(10.2.0.1—10.2.0.4—11.2.0.4)

测试平台信息

环境 参数
数据库版本 源端10.2.0.1.0 目标端11.2.0.4.0
是否集群 源端单 目标端单
操作系统 源端centos6.6 目标端6.6
DB_NAME 源端 marvin —>>> 目标端 marvin

刚开始升级并不知道10.2.0.1不能直升11g,到后面才发现不能直升,升级路线

并且没在源库执行utlu112i.sql脚本,导致后续执行catupgrd.sql脚本一直报错,执行不了:以下是在recover数据库后的报错

起库报错:ORA-32004
SQL> startup mount;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance

查看告警日志
Deprecated system parameters with specified values:
  background_dump_dest     
  user_dump_dest           
End of deprecated system parameter listing

SQL> alter system reset  background_dump_dest scope=spfile sid='*';

System altered.

SQL> alter system reset  user_dump_dest scope=spfile sid='*';

System altered

重启数据库
SQL> startup force mount;
ORACLE instance started.

Total System Global Area  517763072 bytes
Fixed Size                  2254784 bytes
Variable Size             251660352 bytes
Database Buffers          260046848 bytes
Redo Buffers                3801088 bytes
Database mounted.

SQL>alter databse open upgrade;

运行catupgrd.sql
SQL>@?rdbms/admin/catupgrd.sql
报错如下:无法进行运行,原因你是未在源库运行11g的utlu112i.sql脚本
DOC>  The following error is generated if the pre-upgrade tool has not been
DOC>  run in the old ORACLE_HOME home prior to upgrading a pre-11.2 database:
DOC>
DOC>  SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE')
DOC>                       *
DOC>     ERROR at line 1:
DOC>     ORA-01722: invalid number
DOC>
DOC>    o Action:
DOC>       Shutdown database ("alter systemcheckpoint" and then "shutdown abort").
DOC>       Revert to the original oracle home andstart the database.
DOC>       Run pre-upgrade tool against thedatabase.
DOC>       Review and take appropriate actionsbased on the pre-upgrade
DOC>       output before opening the datatabase inthe new software version.

至此,前期没做好准备,得重新开始弄过了....

说明http://www.cndba.cn/Marvinn/article/2705

(1)RMAN 异机恢复的时候,db_name必须相同。 如果说要想改成其他的实例名,可以在恢复成功后,用nid命令修改。 实例名的信息会记录到控制文件里,所以如果在恢复的时候,如果实例名不一致,恢复的时候会报错。
(2)如果恢复的路径和源库不一致,就需要在restore时用set 命令指定新位置。 并且使用switch datafile all将信息更新的到控制文件。
   在做duplicate的时候,RMAN 会自动根据pfile中的log_file_name_convert和db_file_name_convert来进行set 的转换。 手工restore时,只能只只能使用set 命令。
(3)异机恢复对相同目录和不同目录都做了说明。
(4)最后测试NID 修改DBID 和DBNAME.

一、源库准备

升级源库到10.2.0.4http://www.cndba.cn/Marvinn/article/2705

升级步骤,参考

http://www.cndba.cn/Marvinn/article/2704http://www.cndba.cn/Marvinn/article/2705

在源端备份之前,需要执行一下utlu112i.sql 脚本,否则升级运行catupgrd.sql可能会报如上的错误信息

从目标库11g ORACLE_HOME/rdbms/admin目录下拷贝utlu112i.sql 脚本传送到10g对应的目录下,这个脚本可以检查升级前的一些信息。如果不满足条件,会列出

oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin>scp utlu112i.sql 172.16.10.20:/u01/oracle/10.2.0/rdbms/admin
oracle@172.16.10.20's password: 
utlu112i.sql                                                                                                              100%  220KB 220.3KB/s   00:01 

源库10g执行该脚本:
oracle@single-10g:/home/oracle>sqlplus / as sysdba
SQL> @?rdbms/admin/utlu112i.sql
Oracle Database 11.2 Pre-Upgrade Information Tool 04-02-2018 13:38:41
Script Version: 11.2.0.4.0 Build: 001
.
**********************************************************************
Database:
**********************************************************************
--> name:          MARVIN
--> version:       10.2.0.4.0
--> compatible:    10.2.0.4.0
--> blocksize:     8192
--> platform:      Linux x86 64-bit
--> timezone file: V4
.
**********************************************************************
Tablespaces: [make adjustments in the current environment]
**********************************************************************
--> SYSTEM tablespace is adequate for the upgrade.
.... minimum required size: 1000 MB
--> UNDOTBS1 tablespace is adequate for the upgrade.
.... minimum required size: 400 MB
--> SYSAUX tablespace is adequate for the upgrade.
.... minimum required size: 746 MB
--> TEMP tablespace is adequate for the upgrade.
.... minimum required size: 60 MB
.
**********************************************************************
Flashback: OFF
**********************************************************************
**********************************************************************
Update Parameters: [Update Oracle Database 11.2 init.ora or spfile]
Note: Pre-upgrade tool was run on a lower version 64-bit database.
**********************************************************************
--> If Target Oracle is 32-Bit, refer here for Update Parameters:
-- No update parameter changes are required.
.

--> If Target Oracle is 64-Bit, refer here for Update Parameters:
WARNING: --> "sga_target" needs to be increased to at least 596 MB
.
**********************************************************************
Renamed Parameters: [Update Oracle Database 11.2 init.ora or spfile]
**********************************************************************
-- No renamed parameters found. No changes are required.
.
**********************************************************************
Obsolete/Deprecated Parameters: [Update Oracle Database 11.2 init.ora or spfile]
**********************************************************************
--> background_dump_dest         11.1       DEPRECATED   replaced by  "diagnostic_dest"
--> user_dump_dest               11.1       DEPRECATED   replaced by  "diagnostic_dest"
.

**********************************************************************
Components: [The following database components will be upgraded or installed]
**********************************************************************
--> Oracle Catalog Views         [upgrade]  VALID
--> Oracle Packages and Types    [upgrade]  VALID
--> JServer JAVA Virtual Machine [upgrade]  VALID
--> Oracle XDK for Java          [upgrade]  VALID
--> Oracle Workspace Manager     [upgrade]  VALID
--> OLAP Analytic Workspace      [upgrade]  VALID
--> OLAP Catalog                 [upgrade]  VALID
--> EM Repository                [upgrade]  VALID
--> Oracle Text                  [upgrade]  VALID
--> Oracle XML Database          [upgrade]  VALID
--> Oracle Java Packages         [upgrade]  VALID
--> Oracle interMedia            [upgrade]  VALID
--> Spatial                      [upgrade]  VALID
--> Data Mining                  [upgrade]  VALID
--> Expression Filter            [upgrade]  VALID
--> Rule Manager                 [upgrade]  VALID
--> Oracle OLAP API              [upgrade]  VALID
.
**********************************************************************
Miscellaneous Warnings
**********************************************************************
WARNING: --> Database is using a timezone file older than version 14.
.... After the release migration, it is recommended that DBMS_DST package
.... be used to upgrade the 10.2.0.4.0 database timezone version
.... to the latest version which comes with the new release.
WARNING: --> EM Database Control Repository exists in the database.
.... Direct downgrade of EM Database Control is not supported. Refer to the
.... Upgrade Guide for instructions to save the EM data prior to upgrade.
WARNING: --> Your recycle bin contains 22 object(s).
.... It is REQUIRED that the recycle bin is empty prior to upgrading
.... your database.  The command:
        PURGE DBA_RECYCLEBIN
.... must be executed immediately prior to executing your upgrade.
.
**********************************************************************
Recommendations
**********************************************************************
Oracle recommends gathering dictionary statistics prior to
upgrading the database.
To gather dictionary statistics execute the following command
while connected as SYSDBA:

    EXECUTE dbms_stats.gather_dictionary_stats;

**********************************************************************
Oracle recommends reviewing any defined events prior to upgrading.

To view existing non-default events execute the following commands
while connected AS SYSDBA:
  Events:
    SELECT (translate(value,chr(13)||chr(10),' ')) FROM sys.v$parameter2
      WHERE  UPPER(name) ='EVENT' AND  isdefault='FALSE'

  Trace Events:
    SELECT (translate(value,chr(13)||chr(10),' ')) from sys.v$parameter2
      WHERE UPPER(name) = '_TRACE_EVENTS' AND isdefault='FALSE'

Changes will need to be made in the init.ora or spfile.

**********************************************************************

根绝上述输出信息,查看是否存在Error错误信息,存在则需解决再进行备份升级,若无,可根据解决或者忽略也可

这里我就清理下回收站以及收集数据字典统计信息,其他就不做处理了。
SQL> PURGE DBA_RECYCLEBIN;

DBA Recyclebin purged.

SQL> EXECUTE dbms_stats.gather_dictionary_stats;

PL/SQL procedure successfully completed.

接下来开始着手搞下了.http://www.cndba.cn/Marvinn/article/2705

1、查询DBID

SQL> select name,dbid from v$database;

NAME            DBID
--------- ----------
MARVIN    3091385266

2、源端备份DB(差异增量)

RMAN备份脚本,参考:

http://www.cndba.cn/Marvinn/article/2701

RMAN两周循环脚本,参考:

www.cndba.cn/Marvinn/article/2700

测试..手动执行一下各个0、1、2级脚本

创建测试数据


SQL> conn marvin/marvin;
Connected.
SQL> create table marvin(id number,name varchar2(20))
  2  partition by range(id)
  3  (
  4  partition p1 values less than (250000),
  5  partition p2 values less than (500000),
  6  partition p3 values less than (750000),
  7  partition p4 values less than (maxvalue)
  8  );


Table created.

SQL> SQL> declare
 i number;
  2    3  begin
  4   for i in 1..1000000 loop
  5    insert into marvin values(i,'ss');
  6   end loop;
  7   commit;
  8  end;
  9  /

PL/SQL procedure successfully completed.

SQL> select count(*) from marvin partition (p1);

  COUNT(*)
----------
    249999

0级备

rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Mar 30 14:24:21 2018

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

connected to target database: ORCL (DBID=1492741289)

RMAN> @backup_level0.rcv

插入数据,2级备http://www.cndba.cn/Marvinn/article/2705

SQL> declare
  2   i number;
  3  begin
  4   for i in 10000..100000 loop
  5    insert into marvin values(i,'dd');
  6   end loop;
  7   commit;
  8  end;
  9  /

PL/SQL procedure successfully completed.

SQL> select count(*) from marvin partition (p1);

  COUNT(*)
----------
    340000

rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Mar 30 14:29:13 2018

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

connected to target database: ORCL (DBID=1492741289)

RMAN> @backup_level2.rcv

再次2级备

http://www.cndba.cn/Marvinn/article/2705
http://www.cndba.cn/Marvinn/article/2705

SQL> declare
  2   i number;
  3  begin
  4   for i in 500000..600000 loop
  5    insert into marvin values(i,'kk');
  6   end loop;
  7   commit;
  8  end;
  9  /

PL/SQL procedure successfully completed.

SQL> select count(*) from marvin partition (p2);

  COUNT(*)
----------
    250000

rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Mar 30 14:32:50 2018

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

connected to target database: ORCL (DBID=1492741289)

RMAN> @backup_level2.rcv

创建个表,1级备份

SQL> conn marvin/marvin;
Connected.
SQL> create table marvinn (id number primary key,name varchar2(20));

Table created.

SQL> declare
  2   i number;
  3  begin
  4   for i in 1..1000000 loop
  5    insert into marvinn values(i,'ss');
  6   end loop;
  7   commit;
  8  end;
  9  /

PL/SQL procedure successfully completed.

SQL> select count(*) from marvinn;

  COUNT(*)
----------
   1000000

rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Mar 30 14:37:57 2018

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

connected to target database: ORCL (DBID=1492741289)

RMAN> @backup_level1.rcv

归档备份

rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Mar 30 14:43:16 2018

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

connected to target database: ORCL (DBID=1492741289)

RMAN> @backup_arch.rcv

查看备份信息

oracle@single-10g:/u01/backup>ls
arch_MARVIN_20180402_36_1  fulldb_level1_MARVIN_20180402_33_1  fulldb_MARVIN_20180402_22_12  fulldb_MARVIN_20180402_23_12
arch_MARVIN_20180402_36_2  fulldb_level1_MARVIN_20180402_34_1  fulldb_MARVIN_20180402_22_13  fulldb_MARVIN_20180402_23_13
arch_MARVIN_20180402_36_3  fulldb_level1_MARVIN_20180402_34_2  fulldb_MARVIN_20180402_22_14  fulldb_MARVIN_20180402_23_14
arch_MARVIN_20180402_37_1  fulldb_level1_MARVIN_20180402_34_3  fulldb_MARVIN_20180402_22_2   fulldb_MARVIN_20180402_23_2
arch_MARVIN_20180402_37_2  fulldb_level1_MARVIN_20180402_34_4  fulldb_MARVIN_20180402_22_3   fulldb_MARVIN_20180402_23_3
arch_MARVIN_20180402_37_3  fulldb_level1_MARVIN_20180402_34_5  fulldb_MARVIN_20180402_22_4   fulldb_MARVIN_20180402_23_4
arch_MARVIN_20180402_38_1  fulldb_level1_MARVIN_20180402_34_6  fulldb_MARVIN_20180402_22_5   fulldb_MARVIN_20180402_23_5
arch_MARVIN_20180402_38_2  fulldb_level2_MARVIN_20180402_27_1  fulldb_MARVIN_20180402_22_6   fulldb_MARVIN_20180402_23_6
arch_MARVIN_20180402_38_3  fulldb_level2_MARVIN_20180402_28_1  fulldb_MARVIN_20180402_22_7   fulldb_MARVIN_20180402_23_7
arch_MARVIN_20180402_39_1  fulldb_level2_MARVIN_20180402_30_1  fulldb_MARVIN_20180402_22_8   fulldb_MARVIN_20180402_23_8
arch_MARVIN_20180402_39_2  fulldb_level2_MARVIN_20180402_31_1  fulldb_MARVIN_20180402_22_9   fulldb_MARVIN_20180402_23_9
arch_MARVIN_20180402_40_1  fulldb_MARVIN_20180402_22_1         fulldb_MARVIN_20180402_23_1   fulldb_MARVIN_20180402_24_1
arch_MARVIN_20180402_40_2  fulldb_MARVIN_20180402_22_10        fulldb_MARVIN_20180402_23_10  fulldbsp_MARVIN_20180402_25_1
controlfile                fulldb_MARVIN_20180402_22_11        fulldb_MARVIN_20180402_23_11

3、目标端

3.1、创建口令文件

oracle@kaifayongji:/u01/backup>orapwd file=?/dbs/orapwmarvin password=oracle
oracle@kaifayongji:/u01/backup>cd $ORACLE_HOME/dbs
oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>ls
hc_orcl.dat  init.ora  initorcl.ora  lkORCL  orapwmarvin  orapworcl  snapcf_orcl.f  spfileorcl.ora

3.2、创建备份存放目录

oracle@kaifayongji:/u01>mkdir oradata
oracle@kaifayongji:/u01>cd oradata/

源端传输备份数据到此目录

oracle@single-10g:/u01/backup>scp * 172.16.10.53:/u01/oradata/
The authenticity of host '172.16.10.53 (172.16.10.53)' can't be established.
RSA key fingerprint is fb:5a:bc:43:a7:4c:c0:d1:0f:6b:be:24:16:4b:2b:fb.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.10.53' (RSA) to the list of known hosts.
oracle@172.16.10.53's password: 


验证目标端是否存在
oracle@kaifayongji:/u01/oradata>ls
arch_MARVIN_20180402_36_1  fulldb_level1_MARVIN_20180402_33_1  fulldb_MARVIN_20180402_22_12  fulldb_MARVIN_20180402_23_12
arch_MARVIN_20180402_36_2  fulldb_level1_MARVIN_20180402_34_1  fulldb_MARVIN_20180402_22_13  fulldb_MARVIN_20180402_23_13
arch_MARVIN_20180402_36_3  fulldb_level1_MARVIN_20180402_34_2  fulldb_MARVIN_20180402_22_14  fulldb_MARVIN_20180402_23_14
arch_MARVIN_20180402_37_1  fulldb_level1_MARVIN_20180402_34_3  fulldb_MARVIN_20180402_22_2   fulldb_MARVIN_20180402_23_2
arch_MARVIN_20180402_37_2  fulldb_level1_MARVIN_20180402_34_4  fulldb_MARVIN_20180402_22_3   fulldb_MARVIN_20180402_23_3
arch_MARVIN_20180402_37_3  fulldb_level1_MARVIN_20180402_34_5  fulldb_MARVIN_20180402_22_4   fulldb_MARVIN_20180402_23_4
arch_MARVIN_20180402_38_1  fulldb_level1_MARVIN_20180402_34_6  fulldb_MARVIN_20180402_22_5   fulldb_MARVIN_20180402_23_5
arch_MARVIN_20180402_38_2  fulldb_level2_MARVIN_20180402_27_1  fulldb_MARVIN_20180402_22_6   fulldb_MARVIN_20180402_23_6
arch_MARVIN_20180402_38_3  fulldb_level2_MARVIN_20180402_28_1  fulldb_MARVIN_20180402_22_7   fulldb_MARVIN_20180402_23_7
arch_MARVIN_20180402_39_1  fulldb_level2_MARVIN_20180402_30_1  fulldb_MARVIN_20180402_22_8   fulldb_MARVIN_20180402_23_8
arch_MARVIN_20180402_39_2  fulldb_level2_MARVIN_20180402_31_1  fulldb_MARVIN_20180402_22_9   fulldb_MARVIN_20180402_23_9
arch_MARVIN_20180402_40_1  fulldb_MARVIN_20180402_22_1         fulldb_MARVIN_20180402_23_1   fulldb_MARVIN_20180402_24_1
arch_MARVIN_20180402_40_2  fulldb_MARVIN_20180402_22_10        fulldb_MARVIN_20180402_23_10  fulldbsp_MARVIN_20180402_25_1
controlfile                fulldb_MARVIN_20180402_22_11        fulldb_MARVIN_20180402_23_11

3.3、创建初始化参数

考虑到当前环境下已经存在一个数据库,所以

oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>cp ~/.bash_profile ~/.bash_marvin
修改ORACLE_SID=marvin
oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>source ~/.bash_marvin

有两种方式:http://www.cndba.cn/Marvinn/article/2705

​ 1、使用默认init.ora起库到nomount状态,再尝试restore spfile to pfile,再用pfile起库

​ 2、手工源库建pfile,传送过来再起库到Nomount

1、使用默认init.ora起库到nomount状态,再尝试restore spfile to pfile,再用pfile起库
oracle@kaifayongji:/u01/oradata>rman target / nocatalog

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Mar 30 18:54:26 2018

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

connected to target database (not started)

RMAN> set DBID=3091385266                 #设置源库的DBID

executing command: SET DBID

RMAN> startup nomount;

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initmarvin.ora'

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

Total System Global Area    1068937216 bytes

Fixed Size                     2260088 bytes
Variable Size                281019272 bytes
Database Buffers             780140544 bytes
Redo Buffers                   5517312 bytes

从备份中恢复参数文件为pfile
RMAN>  run
2> {
3> restore spfile to pfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initmarvin.ora' from '/u01/oradata/fulldbsp_MARVIN_20180402_25_1';
4> shutdown abort;
5> }

Starting restore at 2018-04-02 14:38:24
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/oradata/fulldbsp_MARVIN_20180402_25_1
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 2018-04-02 14:38:25

Oracle instance shut down

两种方式任选其中一个即可。上为使用默认init.ora起库,下为手动创建pfile并传送

2、手工源库创建pfile,然后将pfile文件copy到目标端
源端执行:
SQL> create pfile='/u01/backup/initmarvin.ora' from spfile;

File created

目标端执行:

传送到指定目录oradata下,再以该参数文件起库
oracle@kaifayongji:/u01/oradata>source ~/.bash_marvin
oracle@kaifayongji:/u01/oradata>rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Mar 30 17:07:00 2018

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

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database: 
ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9925


oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 30 17:32:27 2018

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

ERROR:
ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9925
ORA-01075: you are currently logged on


Enter user-name: 
ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name: 
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus


估计是之前默认init.ora的影响,当前ORACLE_SID被占用,但又启动不了,导致现在报错
查看到告警日志这边,已经生成了对应trace
oracle@kaifayongji:/u01/app/oracle/diag/rdbms/orcl/marvin/trace>tail -200 alert_marvin.log  
ORACLE_BASE from environment = /u01/app/oracle
Fri Mar 30 16:51:36 2018
OS Audit file could not be created; failing after 6 retries
Fri Mar 30 16:52:47 2018
OS Audit file could not be created; failing after 6 retries
OS Audit file could not be created; failing after 6 retries
Fri Mar 30 16:55:45 2018
OS Audit file could not be created; failing after 6 retries
OS Audit file could not be created; failing after 6 retries
Fri Mar 30 17:02:41 2018
OS Audit file could not be created; failing after 6 retries
Fri Mar 30 17:04:13 2018
OS Audit file could not be created; failing after 6 retries
OS Audit file could not be created; failing after 6 retries
Fri Mar 30 17:05:20 2018
OS Audit file could not be created; failing after 6 retries
Fri Mar 30 17:07:05 2018
OS Audit file could not be created; failing after 6 retries


查看下对应的SID进程,全部杀掉(ORA-01075: you are currently logged on 解决方案)

oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs> ps -ef |grep $ORACLE_SID
oracle   14379     1  0 16:51 ?        00:00:00 ora_pmon_marvin
oracle   14381     1  0 16:51 ?        00:00:00 ora_psp0_marvin
oracle   14383     1  0 16:51 ?        00:00:15 ora_vktm_marvin
oracle   14387     1  0 16:51 ?        00:00:00 ora_gen0_marvin
oracle   14389     1  0 16:51 ?        00:00:00 ora_diag_marvin
oracle   14391     1  0 16:51 ?        00:00:00 ora_dbrm_marvin
oracle   14393     1  0 16:51 ?        00:00:00 ora_dia0_marvin
oracle   14395     1  0 16:51 ?        00:00:00 ora_mman_marvin
oracle   14397     1  0 16:51 ?        00:00:00 ora_dbw0_marvin
oracle   14399     1  0 16:51 ?        00:00:00 ora_lgwr_marvin
oracle   14401     1  0 16:51 ?        00:00:00 ora_ckpt_marvin
oracle   14403     1  0 16:51 ?        00:00:00 ora_smon_marvin
oracle   14405     1  0 16:51 ?        00:00:00 ora_reco_marvin
oracle   14407     1  0 16:51 ?        00:00:00 ora_mmon_marvin
oracle   14409     1  0 16:51 ?        00:00:00 ora_mmnl_marvin
oracle   14411     1  0 16:51 ?        00:00:00 ora_d000_marvin
oracle   14413     1  0 16:51 ?        00:00:00 ora_s000_marvin
oracle   15046 14654  0 17:34 pts/0    00:00:00 grep marvin

杀掉方式:
    1.使用Linux的kill命令杀死所有与oracle有关的进程
    $ ps -ef |grep $ORACLE_SID|grep -v grep|awk '{print $2}' | xargs kill -9
    2.使用Linux的ipcs和ipcsrm命令释放oracle占用的共享内存
    $ ipcs -m | grep oracle | awk '{print $2}' | xargs ipcrm shm

验证,已恢复正常.
oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 30 17:36:21 2018

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

Connected to an idle instance.

SQL>

3.4、根据参数文件,创建指定目录

当然,这些目录还可以自动指定创建,然后修改对应参数文件的参数路径即可,这里我选择默认

*.audit_file_dest='/u01/oracle/admin/marvin/adump'
*.background_dump_dest='/u01/oracle/admin/marvin/bdump'
*.control_files='/u01/oracle/oradata/MARVIN/controlfile/o1_mf_fcvrflof_.ctl'
*.core_dump_dest='/u01/oracle/admin/marvin/cdump'
*.user_dump_dest='/u01/oracle/admin/marvin/udump'
*.db_create_file_dest='/u01/oracle/oradata'

目标端创建目录:
oracle@kaifayongji:/u01/oradata>source ~/.bash_marvin
oracle@kaifayongji:/u01/oradata>mkdir -p /u01/oracle/admin/marvin/adump
oracle@kaifayongji:/u01/oradata>mkdir -p /u01/oracle/admin/marvin/bdump 
oracle@kaifayongji:/u01/oradata>mkdir -p /u01/oracle/admin/marvin/cdump
oracle@kaifayongji:/u01/oradata>mkdir -p /u01/oracle/admin/marvin/udump

如果修改数据文件保存的位置,那么要修改控制文件的相关的参数:
*.control_files='/u01/oracle/oradata/MARVIN/controlfile/o1_mf_fcvrflof_.ctl'
此处修改为(多路复用)
*.control_files='/u01/oracle/admin/marvin/control01.ctl','/u01/app/oracle/product/11.2.0/dbhome_1/dbs/crontrolmarvin.ctl'

如果要修改数据库文件(即数据文件、重做日志等)的位置,则需创建指定,并修改对应的参数到创建指定的目录位置【即restore database 是指定其他目录恢复还是恢复原目录(当然指定其他目录恢复还需要SET命令操作)】

*.db_create_file_dest='/u01/oracle/oradata'
此处不更改
oracle@kaifayongji:/u01/oradata>mkdir -p /u01/oracle/marvin/oradata
*.db_create_file_dest='/u01/oracle/oradata'

............................................................
目录不存在报错:
RMAN> startup nomount pfile='/u01/oradata/marvin.ora';

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 03/30/2018 18:00:40
RMAN-04014: startup failed: ORA-01261: Parameter db_create_file_dest destination string cannot be translated
ORA-01262: Stat failed on a file destination directory
Linux-x86_64 Error: 2: No such file or directory
RMAN-04017: startup error description: ORA-32006: BACKGROUND_DUMP_DEST initialization parameter has been deprecated
ORA-32006: USER_DUMP_DEST initialization parameter has been deprecated
.............................................................................................................................................................

如果要修改归档路经名称,则需指定创建,否则需创建同等目录
*.log_archive_dest_1='LOCATION=/u01/marvin/arch'
此处不变更

.............................................................................................................................
目录不存在报错
RMAN> startup nomount pfile='/u01/oradata/marvin.ora';

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 03/30/2018 18:07:08
RMAN-04014: startup failed: ORA-16032: parameter LOG_ARCHIVE_DEST_1 destination string cannot be translated
ORA-07286: sksagdi: cannot obtain device information.
Linux-x86_64 Error: 2: No such file or directory
RMAN-04017: startup error description: ORA-32006: BACKGROUND_DUMP_DEST initialization parameter has been deprecated
ORA-32006: USER_DUMP_DEST initialization parameter has been deprecate

最后再次nomount启动数据库成功

oracle@kaifayongji:/u01/oradata>rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Apr 2 14:46:25 2018

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

connected to target database (not started)

使用编辑后的pfile参数文件来启动实例到nomount状态
RMAN> startup force nomount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initmarvin.ora'

Oracle instance started

Total System Global Area     517763072 bytes

Fixed Size                     2254784 bytes
Variable Size                251660352 bytes
Database Buffers             260046848 bytes
Redo Buffers                   3801088 bytes

注意:因为源数据库启用了控制文件自动备份,从控制文件自动备份文件中还原控制文件并将目标数据库启动到mount状态,为了还原非缺省格式的自动备份,需要执行set controlfile autobackup format命令来指定格式(需要将源库自动备份控制文件的文件也传输到目标端某个指定位置,当前目标端指定位置为/u01/oradata/controlfile/%F)
RMAN> run
2> {
3> set controlfile autobackup format for device type disk to '/u01/oradata/controlfile/%F';
4> restore controlfile from autobackup;
5> alter database mount;
6> }

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

Starting restore at 2018-04-02 14:50:40
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

AUTOBACKUP search with format "/u01/oradata/controlfile/%F" not attempted because DBID was not set
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/02/2018 14:50:40
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece

RMAN> set DBID=3091385266           #设置源库的DBID

executing command: SET DBID

RMAN> run
2> {
3> set controlfile autobackup format for device type disk to '/u01/oradata/controlfile/%F';
4> restore controlfile from autobackup;
5> alter database mount;
}
6> 
executing command: SET CONTROLFILE AUTOBACKUP FORMAT

Starting restore at 2018-04-02 14:52:39
using channel ORA_DISK_1

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180402
channel ORA_DISK_1: AUTOBACKUP found: /u01/oradata/controlfile/c-3091385266-20180402-04
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/oradata/controlfile/c-3091385266-20180402-04
channel ORA_DISK_1: control file restore from AUTOBACKUP complete

output file name=/u01/oracle/admin/marvin/control01.ctl
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/crontrolmarvin.ctl

Finished restore at 2018-04-02 14:52:40

database mounted
released channel: ORA_DISK_1

注意:restore 控制文件的时候,控制文件恢复的位置,是我们在pfile中的control_files参数控制的

.......................................................................................................................
或者如果有特定的备份控制文件,可直接指定备份片恢复(操作如下)
RMAN> restore controlfile from '/u01/oradata/fulldbct_MARVIN_20180330_21_1';

Starting restore at 2018-03-30 18:36:09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 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/oracle/admin/marvin/control01.ctl
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/crontrolmarvin.ctl

Finished restore at 2018-03-30 18:36:10

注意:restore 控制文件的时候,控制文件恢复的位置,是我们在pfile中的control_files参数控制的

将DB启动到MOUNT状态
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> 
......................................................................................................

恢复不同目录

注意:即使恢复不同目录,参数文件中db_create_file_dest路径也需要更改到指定的目录,否则可能恢复失败

如:之前是/opt/marvin,现在则是/u01/marvin,以下恢复路径则需在该目录下创建对应目录进行存放恢复即可


    1、如果数据文件要被还原到目标主机上的目录与源数据库所在的目录不相同,那么必须使用set newname命令来对还原的数据文件指定新的目录路径。
    2、如果联机重做日志将创建在与源数据库不相同的目录中,那么必须使用alter database rename file命令来为每个联机重做日志指定新的目录路径,新的联机重做日志文件使用alter database rename file命令来指定
    3、在这里使用set newname for database命令来为所有被还原的数据文件指定新目录,
    也可以一个个指定,将所有数据文件依次罗列出来并指定(类似于
    set newname for datafile 1 to  '/u01/marvin/datafile/system01.dbf';
    或者
set newname for /opt/marvin/datafile/o1_mf_system_f58knm9b_.dbf' to  '/u01/marvin/datafile/system01.dbf';)

恢复脚本:
RMAN> run
{
set newname for database to '/u01/marvin/datafile/%U';
alter database rename file /opt/marvin/onlinelog/group_1.264.930413221' to '/u01//marvin/onlinelog/redo1.log';
 alter database rename file '/opt/marvin/onlinelog/group_2.265.930413225' to '/u01//marvin/onlinelog/redo2.log';
 alter database rename file '/opt/marvin/onlinelog/group_3.266.930413227' to '/u01/marvin/onlinelog/redo3.log';
alter database rename file '/opt/marvin/onlinelog/group_4.267.930413231' to '/u01//marvin/onlinelog/redo4.log';
restore database;
switch datafile all;
recover database;
}

恢复完后,后续命令操作相同....
此处省略操作步骤...

恢复相同目录,即参数文件中db_create_file_dest路径未更改

此情况恢复比较简单,Catalog一下恢复目录,直接restore database

RMAN> catalog start with '/u01/oradata/';

这里可能报错注册参数文件错误,可以忽略,因为我把参数文件一起放到Catalog恢复目录下了
List of Files Which Where Not Cataloged
=======================================
File Name: /u01/oradata/marvin.ora
  RMAN-07517: Reason: The file header is corrupted


RMAN> restore database;

Starting restore at 2018-03-30 18:48:28
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 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 00002 to /u01/oracle/oradata/MARVIN/datafile/o1_mf_undotbs1_fcvrdm2p_.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oracle/oradata/MARVIN/datafile/o1_mf_sysaux_fcvrdm01_.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_2_1
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_2_1
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_2_1 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_2_2
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_2_2
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_2_2 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 2
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_2_3
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_2_3
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_2_3 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 3
channel ORA_DISK_1: restore complete, elapsed time: 00:00:13
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/oracle/oradata/MARVIN/datafile/o1_mf_system_fcvrdlws_.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oracle/oradata/MARVIN/datafile/o1_mf_users_fcvrdm5j_.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_1
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_1
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_1 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_2
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_2
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_2 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 2
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_3
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_3
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_3 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 3
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_4
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_4
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_4 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 4
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_5
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_5
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_5 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 5
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_6
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_6
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_6 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 6
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_7
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_7
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_7 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 7
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_8
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_8
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_8 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 8
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_9
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_9
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_9 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 9
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_10
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_10
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_10 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 10
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_11
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_11
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_11 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 11
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_MARVIN_20180330_1_12
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_MARVIN_20180330_1_12
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_MARVIN_20180330_1_12 tag=LEVEL_0
channel ORA_DISK_1: restored backup piece 12
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
Finished restore at 2018-03-30 18:48:58


RMAN> recover database;

Starting recover at 2018-03-30 19:22:39
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/oracle/oradata/MARVIN/datafile/o1_mf_system_fcw5jb3x_.dbf
destination for restore of datafile 00004: /u01/oracle/oradata/MARVIN/datafile/o1_mf_users_fcw5jb5p_.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_level1_MARVIN_20180330_14_1
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_level1_MARVIN_20180330_14_1
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_level1_MARVIN_20180330_14_1 tag=LEVEL_1DIFF
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00002: /u01/oracle/oradata/MARVIN/datafile/o1_mf_undotbs1_fcw5hwyj_.dbf
destination for restore of datafile 00003: /u01/oracle/oradata/MARVIN/datafile/o1_mf_sysaux_fcw5hwwz_.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_level1_MARVIN_20180330_15_1
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_level1_MARVIN_20180330_15_1
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_level1_MARVIN_20180330_15_1 tag=LEVEL_1DIFF
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_level1_MARVIN_20180330_15_2
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_level1_MARVIN_20180330_15_2
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_level1_MARVIN_20180330_15_2 tag=LEVEL_1DIFF
channel ORA_DISK_1: restored backup piece 2
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_level1_MARVIN_20180330_15_3
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_level1_MARVIN_20180330_15_3
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_level1_MARVIN_20180330_15_3 tag=LEVEL_1DIFF
channel ORA_DISK_1: restored backup piece 3
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_level1_MARVIN_20180330_15_4
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_level1_MARVIN_20180330_15_4
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_level1_MARVIN_20180330_15_4 tag=LEVEL_1DIFF
channel ORA_DISK_1: restored backup piece 4
channel ORA_DISK_1: reading from backup piece /u01/backup/fulldb_level1_MARVIN_20180330_15_5
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/fulldb_level1_MARVIN_20180330_15_5
channel ORA_DISK_1: failover to piece handle=/u01/oradata/fulldb_level1_MARVIN_20180330_15_5 tag=LEVEL_1DIFF
channel ORA_DISK_1: restored backup piece 5
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45

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=22
channel ORA_DISK_1: reading from backup piece /u01/backup/arch_MARVIN_20180330_20_1
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/arch_MARVIN_20180330_20_1
channel ORA_DISK_1: failover to piece handle=/u01/oradata/arch_MARVIN_20180330_20_1 tag=TAG20180330T162529
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/marvin/arch/1_22_972140723.dbf thread=1 sequence=22
unable to find archived log
archived log thread=1 sequence=23
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/30/2018 19:23:42
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 23 and starting SCN of 567388

之后会报一个错误:
    RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 23 and starting SCN of 567388
       这里是提醒恢复到一个未知的scn号。在alter database mount之后,通过set until scn 或者set until time 命令设置恢复到的scn号或时间。就可以避免这个错误

启动数据库(若没有出现以下报错,可忽略)直接以升级模式打开,运行catupgrd.sql

http://www.cndba.cn/Marvinn/article/2705
http://www.cndba.cn/Marvinn/article/2705

oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>source ~/.bash_marvin 
oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 30 19:26:53 2018

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

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
Process ID: 17092
Session ID: 21 Serial number: 5

这里报错是因为源库版本10g,目标端11g,所以需要使用UPGRADE命令进行库升级。

SQL> alter database open resetlogs upgrade;
ERROR:
ORA-03114: not connected to ORACLE


SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


oracle@kaifayongji:/u01/app/oracle/product/11.2.0/dbhome_1/dbs>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 30 19:27:29 2018

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

Connected to an idle instance.

SQL> startup mount;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area  517763072 bytes
Fixed Size                  2254784 bytes
Variable Size             251660352 bytes
Database Buffers          260046848 bytes
Redo Buffers                3801088 bytes
Database mounted.
SQL> alter database open resetlogs upgrade;
alter database open resetlogs upgrade
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery

处理ORA-32004:

创建Spfile,从spfile启库
SQL> create spfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilemarvin.ora' from pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initmarvin.ora';

File created.

SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area  517763072 bytes
Fixed Size                  2254784 bytes
Variable Size             251660352 bytes
Database Buffers          260046848 bytes
Redo Buffers                3801088 bytes
Database mounted.

查看告警日志
Deprecated system parameters with specified values:
  background_dump_dest     
  user_dump_dest           
End of deprecated system parameter listing

SQL> alter system reset  background_dump_dest scope=spfile sid='*';

System altered.

SQL> alter system reset  user_dump_dest scope=spfile sid='*';

System altered

重启数据库
SQL> startup force mount;
ORACLE instance started.

Total System Global Area  517763072 bytes
Fixed Size                  2254784 bytes
Variable Size             251660352 bytes
Database Buffers          260046848 bytes
Redo Buffers                3801088 bytes
Database mounted.

执行升级脚本类似MOUNT下执行catupgrd.sql
SQL> alter database open upgrade;

Database altered.

SQL>@?rdbms/admin/catupgrd.sql     #时间比较长,需要等待
                结束标记
SQL> Rem Set errorlogging off
SQL> SET ERRORLOGGING OFF;
SQL> 
SQL> REM END OF CATUPGRD.SQL
SQL> 
SQL> REM bug 12337546 - Exit current sqlplus session at end of catupgrd.sql.
SQL> REM                This forces user to start a new sqlplus session in order
SQL> REM                to connect to the upgraded db.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
终于完成了.....花都谢了

重新起库
oracle@kaifayongji>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Apr 2 16:28:42 2018

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  517763072 bytes
Fixed Size                  2254784 bytes
Variable Size             494929984 bytes
Database Buffers           16777216 bytes
Redo Buffers                3801088 bytes
Database mounted.
Database opened.

执行catuppst.sql脚本,不需要在upgrade 模式下执行
--这个脚本用来迁移一些Baseline 数据到当前数据库中
SQL> @?/rdbms/admin/catuppst.sql

编译无效对象
SQL>@?rdbms/admin/utlrp.sql

检查组件状态
SQL> select  *  from  UTL_RECOMP_ERRORS;

no rows selected

SQL> col  comp_name format  a30;
SQL> col version format a20;
SQL> col status  format  a20;
SQL> set line 200;
SQL> select comp_name,version,status from  sys.dba_registry;

COMP_NAME                      VERSION              STATUS
------------------------------ -------------------- --------------------
Oracle Enterprise Manager      11.2.0.4.0           VALID
OLAP Catalog                   11.2.0.4.0           VALID
Spatial                        11.2.0.4.0           VALID
Oracle Multimedia              11.2.0.4.0           VALID
Oracle XML Database            11.2.0.4.0           VALID
Oracle Text                    11.2.0.4.0           VALID
Oracle Data Mining             11.2.0.4.0           VALID
Oracle Expression Filter       11.2.0.4.0           VALID
Oracle Rule Manager            11.2.0.4.0           VALID
Oracle Workspace Manager       11.2.0.4.0           VALID
Oracle Database Catalog Views  11.2.0.4.0           VALID

COMP_NAME                      VERSION              STATUS
------------------------------ -------------------- --------------------
Oracle Database Packages and T 11.2.0.4.0           VALID
ypes

JServer JAVA Virtual Machine   11.2.0.4.0           VALID
Oracle XDK                     11.2.0.4.0           VALID
Oracle Database Java Packages  11.2.0.4.0           VALID
OLAP Analytic Workspace        11.2.0.4.0           VALID
Oracle OLAP API                11.2.0.4.0           VALID

17 rows selected.

#检查是否有无效对象
SQL> select count(*) from dba_objects where status='INVALID';

  COUNT(*)
----------
         0
#检查是否有无效的对象
SQL> select object_name,status from dba_objects where object_Name in ('SYS','SYSTEM') and status = 'INVALID';

no rows selected

如果值大于0则说明有错误,就要重新执行sql>@d:/oracle/product/10.2.0/db_1/rdbms/admin/catupgrd.sql,知道没有错误

#查看版本
SQL> select * from  v$version;

BANNER
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

验证数据:对比之前源库创建的测试数据,一样
SQL> select count(*) from marvin;

  COUNT(*)
----------
   1190002

SQL> select count(*) from marvinn;

  COUNT(*)
----------
   1000000

SQL> select count(*) from marvin partition (p2);

  COUNT(*)
----------
    250000

SQL>  select count(*) from marvin partition (p1);

  COUNT(*)
----------
    340000

至此,RMAN异机恢复完成.....(10.2.0.1--11.2.0.4)

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Marvinn

Marvinn

关注

路漫漫其修远兮、吾将上下而求索

  • 99
    原创
  • 0
    翻译
  • 2
    转载
  • 36
    评论
  • 访问:458455次
  • 积分:449
  • 等级:中级会员
  • 排名:第12名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ