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

【RAC】将单实例备份集恢复为rac数据库

时间:2015-06-02 16:59:46      阅读:374      评论:0      收藏:0      [点我收藏+]

标签:

RAC】将单实例备份集恢复为rac数据库

一.1  BLOG文档结构图

 

技术分享

 

一.2  前言部分

 

一.2.1  导读

各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~:

单实例环境的备份集如何恢复到rac环境(重点)

rman恢复数据库的一般步骤

rac环境的简单操作

 

注意:本篇BLOG中代码部分需要特别关注的地方我都用黄色背景和红色字体来表示,比如下边的例子中,thread 1的最大归档日志号为33thread 2的最大归档日志号为43是需要特别关注的地方。

  List of Archived Logs in backup set 11

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    32      1621589    2015-05-29 11:09:52 1625242    2015-05-29 11:15:48

  1    33      1625242    2015-05-29 11:15:48 1625293    2015-05-29 11:15:58

  2    42      1613951    2015-05-29 10:41:18 1625245    2015-05-29 11:15:49

  2    43      1625245    2015-05-29 11:15:49 1625253    2015-05-29 11:15:53

 

 

 

 

本文如有错误或不完善的地方请大家多多指正,ITPUB留言或QQ皆可,您的批评指正是我写作的最大动力。

 

一.2.2  实验环境介绍

 

源库:11.2.0.1   RHEL6.5 单实例

目标库:11.2.0.1  RHEL6.5  rac环境

 

 

一.2.3  相关参考文章链接

 

rac安装系列:

【推荐】 一步一步搭建11gR2 rac+dg之结尾篇(十) 

http://blog.itpub.net/26736162/viewspace-1328156/ 

【推荐】 一步一步搭建11gR2 rac+dg之DG SWITCHOVER功能(九) 

http://blog.itpub.net/26736162/viewspace-1328050/ 

一步一步搭建11gR2 rac+dg之配置单实例的DG(八) 

http://blog.itpub.net/26736162/viewspace-1298735/ 

一步一步搭建11gR2 rac+dg之DG 机器配置(七) 

http://blog.itpub.net/26736162/viewspace-1298733/ 

一步一步搭建11gR2 rac+dg之安装rac出现问题解决(六) 

http://blog.itpub.net/26736162/viewspace-1297128/ 

一步一步搭建oracle 11gR2 rac+dg之database安装(五) 

http://blog.itpub.net/26736162/viewspace-1297113/ 

一步一步搭建 oracle 11gR2 rac+dg之grid安装(四) 

http://blog.itpub.net/26736162/viewspace-1297101/ 

【推荐】 一步一步搭建oracle 11gR2 rac+dg之共享磁盘设置(三) 

http://blog.itpub.net/26736162/viewspace-1291144/ 

【推荐】 一步一步搭建oracle 11gR2 rac+dg之环境准备(二) 

http://blog.itpub.net/26736162/viewspace-1290416/ 

【推荐】 一步一步搭建 oracle 11gR2 rac + dg 之前传 (一) 

http://blog.itpub.net/26736162/viewspace-1290405/ 

 

 

一.2.4  本文简介

 

 

本文基于如何将单实例的数据库备份恢复到rac环境下,至于rac环境的备份集如何恢复到单实例及rac环境的备份集恢复到rac环境的实验请参考相关文章链接部分。

 

实验的一些数据库环境参考如下表格:

项目

source db

target  db

db 类型

单实例

rac环境

db version

11.2.0.1

11.2.0.1

ORACLE_SID

orastrac

orastrac1 orastrac2

db_name

orastrac

orastrac

主机IP地址:

 

192.168.59.129

192.168.1.31

192.168.1.32

 

 

 

先描述下大致步骤:

? 源端创建备份集;

? 目标端安装数据库软件和集群件,并配置好共享存储(安装rac的时候一般已经配置好了

? 复制源端备份集到目标端;

? 目录端任意节点执行正常恢复,恢复时注意要将 spfile,controlfile,datafile,redofile 等路径改到共享存储上,恢复完后这会儿仍然是个单实例数据库;

? 修改初始化参数、增加 UNDO 表空间、增加 REDOLOG 线程组,重建密钥文件,目标端任意节点执行;

? 目标端各个节点配置监听及网络服务名;

? 将新建的数据库配置到 crs,目标端任意节点执行即可。

 

一.3  实验部分

 

一.3.1  实验目标

 

将单实例的备份集成功的恢复到rac环境下,并添加数据库到crs环境。

一.3.2  源库操作

 

source库上需要做的操作主要是备份和创建测试用户。

 

一.3.2.1  静默创建一个单实例的测试库

 

首先修改归档模式,这样创建的数据库默认为归档模式,然后我们在源库上静默创建一个单实例的库,sidorastrac,为oracle single instance to rac,关于静默安装数据库参考:

静默安装系列 

 

【推荐】 【DBCA -SILENT】静默方式安装11gR2 oracle数据库软件 

http://blog.itpub.net/26736162/viewspace-1589769/ 

【推荐】 【DBCA -SILENT】静默安装之rac数据库安装 

http://blog.itpub.net/26736162/viewspace-1586352/ 

【推荐】 【DBCA -SILENT】静默安装如何启用归档模式 

http://blog.itpub.net/26736162/viewspace-1585925/ 

【推荐】  DBCA静默方式建库 

http://blog.itpub.net/26736162/viewspace-1448220/ 

 

[oracle@orcltest ~]$ echo $ORACLE_HOME

/u01/app/oracle/product/11.2.0/dbhome_1

[oracle@orcltest ~]$ sqlplus -v

 

SQL*Plus: Release 11.2.0.1.0 Production

 

[oracle@orcltest ~]$ strings $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc | grep -i arch

         <archiveLogMode>false</archiveLogMode>

[oracle@orcltest ~]$ vi $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc

<?xml version = ‘1.0‘?>

<DatabaseTemplate name="General_Purpose" description="" version="11.1.0.0.0">

   <CommonAttributes>

      <option name="OMS" value="false"/>

      <option name="JSERVER" value="true"/>

      <option name="SPATIAL" value="true"/>

      <option name="IMEDIA" value="true"/>

      <option name="XDB_PROTOCOLS" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="ORACLE_TEXT" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="SAMPLE_SCHEMA" value="false"/>

      <option name="CWMLITE" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="EM_REPOSITORY" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="APEX" value="true"/>

      <option name="OWB" value="true"/>

      <option name="DV" value="false"/>

   </CommonAttributes>

   <Variables/>

   <CustomScripts Execute="false"/>

   <InitParamAttributes>

      <InitParams>

         <initParam name="db_name" value=""/>

         <initParam name="dispatchers" value="(PROTOCOL=TCP) (SERVICE={SID}XDB)"/>

         <initParam name="audit_file_dest" value="{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump"/>

         <initParam name="compatible" value="11.2.0.0.0"/>

         <initParam name="remote_login_passwordfile" value="EXCLUSIVE"/>

         <initParam name="processes" value="150"/>

         <initParam name="undo_tablespace" value="UNDOTBS1"/>

         <initParam name="control_files" value="("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl", "{ORACLE_BASE}/flash_recovery_area/{DB_UNIQUE_NAME}/control02.ctl")"/>

         <initParam name="diagnostic_dest" value="{ORACLE_BASE}"/>

         <initParam name="db_recovery_file_dest" value="{ORACLE_BASE}/flash_recovery_area"/>

         <initParam name="audit_trail" value="db"/>

         <initParam name="memory_target" value="250" unit="MB"/>

         <initParam name="db_block_size" value="8" unit="KB"/>

         <initParam name="open_cursors" value="300"/>

         <initParam name="db_recovery_file_dest_size" value="" unit="MB"/>

      </InitParams>

      <MiscParams>

         <databaseType>MULTIPURPOSE</databaseType>

         <maxUserConn>20</maxUserConn>

         <percentageMemTOSGA>40</percentageMemTOSGA>

         <customSGA>false</customSGA>

         <archiveLogMode>true</archiveLogMode>

         <initParamFileName>{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/pfile/init.ora</initParamFileName>

      </MiscParams>

      <SPfile useSPFile="true">{ORACLE_HOME}/dbs/spfile{SID}.ora</SPfile>

   </InitParamAttributes>

   <StorageAttributes>

      <DataFiles>

"/u01/app/oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc" 95L, 4985C written                                                                                     

[oracle@orcltest ~]$ strings $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc | grep -i arch

         <archiveLogMode>true</archiveLogMode>

[oracle@orcltest ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orastrac -sid orastrac -sysPassword lhr -systemPassword lhr -responseFile NO_VALUE -datafileDestination /u01/app/oracle/oradata -redoLogFileSize 50 -recoveryAreaDestination /u01/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -totalMemory 200 -databaseType OLTP -emConfiguration NONE  -automaticMemoryManagement true

Copying database files

1% complete

3% complete

10% complete

17% complete

24% complete

35% complete

Creating and starting Oracle instance

37% complete

42% complete

47% complete

52% complete

53% complete

56% complete

58% complete

Registering database with Oracle Restart

64% complete

Completing Database Creation

68% complete

71% complete

75% complete

85% complete

86% complete

96% complete

100% complete

Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orastrac/orastrac.log" for further details.

[oracle@orcltest ~]$

[oracle@orcltest ~]$ ORACLE_SID=orastrac

[oracle@orcltest ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 11:09:02 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> show parameter name

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_file_name_convert                 string

db_name                              string      orastrac

db_unique_name                       string      orastrac

global_names                         boolean     FALSE

instance_name                        string      orastrac

lock_name_space                      string

log_file_name_convert                string

service_names                        string      orastrac

SQL> create user lhr identified by lhr;

 

User created.

 

SQL> grant dba to lhr;

 

Grant succeeded.

 

SQL> create table lhr.test_rac as select * from dba_objects;

 

Table created.

 

SQL> select count(1) FROM LHR.TEST_RAC;

 

  COUNT(1)

----------

     72468

 

SQL>

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     3

Next log sequence to archive   5

Current log sequence           5

SQL>

 

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      /u01/app/oracle/product/11.2.0

                                                 /dbhome_1/dbs/spfileorastrac.o

                                                 ra

SQL>

 

 

一.3.2.2  source库执行备份操作

 

 

备份脚本如下,注意控制文件需要最后备份:

run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup database format  ‘/home/oracle/rman_back/full_%n_%T_%t_%s_%p.bak‘;

sql ‘alter system archive log current‘;

backup archivelog all format ‘/home/oracle/rman_back/arch_%d_%T_%s_%p.bak‘ delete input;

backup current controlfile format ‘/home/oracle/rman_back/ctl_%d_%T_%s_%p.bak‘;

release channel c1;

release channel c2;

}

 

 

执行过程如下:

[oracle@orcltest ~]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 1 11:12:15 2015

 

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

 

connected to target database: ORASTRAC (DBID=1317814272)

 

RMAN> run

2> {

3>  allocate channel c1 type disk;

4>  allocate channel c2 type disk;

5>  backup database format  ‘/home/oracle/rman_back/full_%n_%T_%t_%s_%p.bak‘;

6>  sql ‘alter system archive log current‘;

7>  backup archivelog all format ‘/home/oracle/rman_back/arch_%d_%T_%s_%p.bak‘ delete input;

8>  backup current controlfile format ‘/home/oracle/rman_back/ctl_%d_%T_%s_%p.bak‘;

9>  release channel c1;

10>  release channel c2;

11> }

 

using target database control file instead of recovery catalog

allocated channel: c1

channel c1: SID=142 device type=DISK

 

allocated channel: c2

channel c2: SID=20 device type=DISK

 

Starting backup at 2015-06-01 11:12:28

channel c1: starting full datafile backup set

channel c1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/orastrac/system01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/orastrac/users01.dbf

channel c1: starting piece 1 at 2015-06-01 11:12:29

channel c2: starting full datafile backup set

channel c2: specifying datafile(s) in backup set

input datafile file number=00002 name=/u01/app/oracle/oradata/orastrac/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/orastrac/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/orastrac/undotbs01.dbf

channel c2: starting piece 1 at 2015-06-01 11:12:29

channel c2: finished piece 1 at 2015-06-01 11:15:26

piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak tag=TAG20150601T111228 comment=NONE

channel c2: backup set complete, elapsed time: 00:02:59

channel c2: starting full datafile backup set

channel c2: specifying datafile(s) in backup set

including current control file in backup set

channel c2: starting piece 1 at 2015-06-01 11:15:48

channel c2: finished piece 1 at 2015-06-01 11:15:49

piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881234138_3_1.bak tag=TAG20150601T111228 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:01

channel c2: starting full datafile backup set

channel c2: specifying datafile(s) in backup set

including current SPFILE in backup set

channel c2: starting piece 1 at 2015-06-01 11:15:50

channel c2: finished piece 1 at 2015-06-01 11:15:51

piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak tag=TAG20150601T111228 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:01

channel c1: finished piece 1 at 2015-06-01 11:15:53

piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak tag=TAG20150601T111228 comment=NONE

channel c1: backup set complete, elapsed time: 00:03:24

Finished backup at 2015-06-01 11:15:53

 

sql statement: alter system archive log current

 

Starting backup at 2015-06-01 11:16:05

current log archived

channel c1: starting archived log backup set

channel c1: specifying archived log(s) in backup set

input archived log thread=1 sequence=5 RECID=1 STAMP=881234164

channel c1: starting piece 1 at 2015-06-01 11:16:05

channel c2: starting archived log backup set

channel c2: specifying archived log(s) in backup set

input archived log thread=1 sequence=6 RECID=2 STAMP=881234165

channel c2: starting piece 1 at 2015-06-01 11:16:06

channel c1: finished piece 1 at 2015-06-01 11:16:09

piece handle=/home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak tag=TAG20150601T111605 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:04

channel c1: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORASTRAC/archivelog/2015_06_01/o1_mf_1_5_bpqmmhbp_.arc RECID=1 STAMP=881234164

channel c2: finished piece 1 at 2015-06-01 11:16:10

piece handle=/home/oracle/rman_back/arch_ORASTRAC_20150601_6_1.bak tag=TAG20150601T111605 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:04

channel c2: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORASTRAC/archivelog/2015_06_01/o1_mf_1_6_bpqmmo4t_.arc RECID=2 STAMP=881234165

Finished backup at 2015-06-01 11:16:10

 

Starting backup at 2015-06-01 11:16:10

channel c1: starting full datafile backup set

channel c1: specifying datafile(s) in backup set

including current control file in backup set

channel c1: starting piece 1 at 2015-06-01 11:16:11

channel c1: finished piece 1 at 2015-06-01 11:16:12

piece handle=/home/oracle/rman_back/ctl_ORASTRAC_20150601_7_1.bak tag=TAG20150601T111610 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:01

Finished backup at 2015-06-01 11:16:12

 

released channel: c1

 

released channel: c2

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

1       Full    501.84M    DISK        00:02:42     2015-06-01 11:15:11

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak

  List of Datafiles in backup set 1

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  2       Full 1027268    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/sysaux01.dbf

  3       Full 1027268    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/undotbs01.dbf

  5       Full 1027268    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

2       Full    9.33M      DISK        00:00:10     2015-06-01 11:15:48

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881234138_3_1.bak

  Control File Included: Ckp SCN: 1027334      Ckp time: 2015-06-01 11:15:38

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

3       Full    80.00K     DISK        00:00:00     2015-06-01 11:15:50

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak

  SPFILE Included: Modification time: 2015-06-01 11:12:28

  SPFILE db_unique_name: ORASTRAC

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

4       Full    599.97M    DISK        00:03:24     2015-06-01 11:15:52

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak

  List of Datafiles in backup set 4

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  1       Full 1027267    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/system01.dbf

  4       Full 1027267    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/users01.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

5       41.16M     DISK        00:00:02     2015-06-01 11:16:07

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111605

        Piece Name: /home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak

 

  List of Archived Logs in backup set 5

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    5       1012317    2015-06-01 11:04:50 1027356    2015-06-01 11:15:59

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

6       2.00K      DISK        00:00:02     2015-06-01 11:16:07

        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111605

        Piece Name: /home/oracle/rman_back/arch_ORASTRAC_20150601_6_1.bak

 

  List of Archived Logs in backup set 6

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    6       1027356    2015-06-01 11:15:59 1027365    2015-06-01 11:16:05

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

7       Full    9.33M      DISK        00:00:02     2015-06-01 11:16:12

        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111610

        Piece Name: /home/oracle/rman_back/ctl_ORASTRAC_20150601_7_1.bak

  Control File Included: Ckp SCN: 1027386      Ckp time: 2015-06-01 11:16:10

 

RMAN> list backupset summary;

 

 

List of Backups

===============

Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag

------- -- -- - ----------- ------------------- ------- ------- ---------- ---

1       B  F  A DISK        2015-06-01 11:15:11 1       1       NO         TAG20150601T111228

2       B  F  A DISK        2015-06-01 11:15:48 1       1       NO         TAG20150601T111228

3       B  F  A DISK        2015-06-01 11:15:50 1       1       NO         TAG20150601T111228

4       B  F  A DISK        2015-06-01 11:15:52 1       1       NO         TAG20150601T111228

5       B  A  A DISK        2015-06-01 11:16:07 1       1       NO         TAG20150601T111605

6       B  A  A DISK        2015-06-01 11:16:07 1       1       NO         TAG20150601T111605

7       B  F  A DISK        2015-06-01 11:16:12 1       1       NO         TAG20150601T111610

 

RMAN>

 

 

 

一.3.2.3  将备份传递到target

这个方法就多了,可以采用ftp上传下载,也可以采用NFS网络文件系统,或者scp命令都可以,这里我们采用scp直接传递到rac环境的第一个节点。

 

源库scp操作:

[oracle@orcltest ~]$ cd rman_back/

[oracle@orcltest rman_back]$ ll

total 1189660

-rw-r----- 1 oracle asmadmin  43154944 Jun  1 11:16 arch_ORASTRAC_20150601_5_1.bak

-rw-r----- 1 oracle asmadmin      2560 Jun  1 11:16 arch_ORASTRAC_20150601_6_1.bak

-rw-r----- 1 oracle asmadmin   9797632 Jun  1 11:16 ctl_ORASTRAC_20150601_7_1.bak

-rw-r----- 1 oracle asmadmin 629121024 Jun  1 11:15 full_ORASTRAC_20150601_881233948_1_1.bak

-rw-r----- 1 oracle asmadmin 526229504 Jun  1 11:14 full_ORASTRAC_20150601_881233949_2_1.bak

-rw-r----- 1 oracle asmadmin   9797632 Jun  1 11:15 full_ORASTRAC_20150601_881234138_3_1.bak

-rw-r----- 1 oracle asmadmin     98304 Jun  1 11:15 full_ORASTRAC_20150601_881234150_4_1.bak

[oracle@orcltest rman_back]$ ll -h

total 1.2G

-rw-r----- 1 oracle asmadmin  42M Jun  1 11:16 arch_ORASTRAC_20150601_5_1.bak

-rw-r----- 1 oracle asmadmin 2.5K Jun  1 11:16 arch_ORASTRAC_20150601_6_1.bak

-rw-r----- 1 oracle asmadmin 9.4M Jun  1 11:16 ctl_ORASTRAC_20150601_7_1.bak

-rw-r----- 1 oracle asmadmin 600M Jun  1 11:15 full_ORASTRAC_20150601_881233948_1_1.bak

-rw-r----- 1 oracle asmadmin 502M Jun  1 11:14 full_ORASTRAC_20150601_881233949_2_1.bak

-rw-r----- 1 oracle asmadmin 9.4M Jun  1 11:15 full_ORASTRAC_20150601_881234138_3_1.bak

-rw-r----- 1 oracle asmadmin  96K Jun  1 11:15 full_ORASTRAC_20150601_881234150_4_1.bak

[oracle@orcltest rman_back]$

[oracle@orcltest rman_back]$ scp -r /home/oracle/rman_back  oracle@192.168.1.31:/home/oracle

oracle@192.168.1.31‘s password:

ctl_ORASTRAC_20150601_7_1.bak                                                                                                                                                  100%  9.4MB  17.7MB/s   00:01   

arch_ORASTRAC_20150601_5_1.bak                                                                                                                                                 100%   42MB  27.0MB/s   00:03   

arch_ORASTRAC_20150601_6_1.bak                                                                                                                                                 100%  2.5KB  16.5MB/s   00:02   

full_ORASTRAC_20150601_881233948_1_1.bak                                                                                                                                       100%   18MB  17.7MB/s   00:01   

full_ORASTRAC_20150601_881233949_2_1.bak                                                                                                                                       100%  618MB  12.4MB/s   00:50   

full_ORASTRAC_20150601_881234138_3_1.bak                                                                                                                                       100%  500MB  15.2MB/s   00:33   

full_ORASTRAC_20150601_881234150_4_1.bak                                                                                                                                       100%   96KB  96.0KB/s   00:00   

[oracle@node2 rman_back]$

 

 

 

 

 

target库查看备份文件:

[oracle@node1 rman_back]$ ll -h

total 1.2G

-rw-r----- 1 oracle oinstall  42M Jun  1 11:19 arch_ORASTRAC_20150601_5_1.bak

-rw-r----- 1 oracle oinstall 2.5K Jun  1 11:23 arch_ORASTRAC_20150601_6_1.bak

-rw-r----- 1 oracle oinstall 9.4M Jun  1 11:21 ctl_ORASTRAC_20150601_7_1.bak

-rw-r----- 1 oracle oinstall 600M Jun  1 11:23 full_ORASTRAC_20150601_881233948_1_1.bak

-rw-r----- 1 oracle oinstall 502M Jun  1 11:21 full_ORASTRAC_20150601_881233949_2_1.bak

-rw-r----- 1 oracle oinstall 9.4M Jun  1 11:21 full_ORASTRAC_20150601_881234138_3_1.bak

-rw-r----- 1 oracle oinstall  96K Jun  1 11:23 full_ORASTRAC_20150601_881234150_4_1.bak

[oracle@node1 rman_back]$

 

 

一.3.3  target库操作

 

以下操作若无特殊说明均在节点一操作。

 

一.3.3.1  查看rac环境

 

target库已经有3个库,都处于close状态。

[root@node2 ~]# crsstat

Name                           Type                       Target     State      Host      

------------------------------ -------------------------- ---------- ---------  -------  

ora.ARCH.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.DATA.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.LISTENER.lsnr              ora.listener.type          ONLINE     ONLINE     node1    

ora.LISTENER_SCAN1.lsnr        ora.scan_listener.type     ONLINE     ONLINE     node1    

ora.OVDISK.dg                  ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.TEST.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.asm                        ora.asm.type               ONLINE     ONLINE     node1    

ora.db.db                      ora.database.type          OFFLINE    OFFLINE             

ora.eons                       ora.eons.type              ONLINE     ONLINE     node1    

ora.gsd                        ora.gsd.type               OFFLINE    OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     ONLINE     node1    

ora.jmrac.haha.svc             ora.service.type           ONLINE     ONLINE     node1    

ora.net1.network               ora.network.type           ONLINE     ONLINE     node1    

ora.node1.ASM1.asm             application                ONLINE     ONLINE     node1    

ora.node1.LISTENER_NODE1.lsnr  application                ONLINE     ONLINE     node1    

ora.node1.gsd                  application                OFFLINE    OFFLINE             

ora.node1.ons                  application                ONLINE     ONLINE     node1    

ora.node1.vip                  ora.cluster_vip_net1.type  ONLINE     ONLINE     node1    

ora.node2.ASM2.asm             application                ONLINE     ONLINE     node2    

ora.node2.LISTENER_NODE2.lsnr  application                ONLINE     ONLINE     node2    

ora.node2.gsd                  application                OFFLINE    OFFLINE             

ora.node2.ons                  application                ONLINE     ONLINE     node2    

ora.node2.vip                  ora.cluster_vip_net1.type  ONLINE     ONLINE     node2    

ora.oc4j                       ora.oc4j.type              OFFLINE    OFFLINE             

ora.ons                        ora.ons.type               ONLINE     ONLINE     node1    

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

ora.registry.acfs              ora.registry.acfs.type     ONLINE     ONLINE     node1    

ora.scan1.vip                  ora.scan_vip.type          ONLINE     ONLINE     node1

[root@node2 ~]# crsstat | grep ora.database.type

ora.db.db                      ora.database.type          OFFLINE    OFFLINE             

ora.jmrac.db                   ora.database.type          OFFLINE    OFFLINE             

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

[root@node2 ~]#

 

 

查看磁盘组的情况,确保有足够的空间来还原数据库:

[root@node2 ~]# su - grid

[grid@node2 ~]$ asmcmd

ASMCMD>

ASMCMD> lsdg

State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name

MOUNTED  EXTERN  N         512   4096  1048576      9999     8905                0            8905              0             N  ARCH/

MOUNTED  EXTERN  N         512   4096  1048576     19999    11604                0           11604              0             N  DATA/

MOUNTED  EXTERN  N         512   4096  1048576      3099     2703                0            2703              0             N  OVDISK/

MOUNTED  EXTERN  N         512   4096  1048576      1024      929                0             929              0             N  TEST/

ASMCMD>

 

[root@node2 ~]# cat /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1       localhost.localdomain localhost

::1             localhost6.localdomain6 localhost6

 

#public

192.168.1.31     node1

192.168.1.32     node2

#vip

192.168.1.131   node1-vip

192.168.1.132   node2-vip

#priv

9.9.9.31    node1-priv

9.9.9.32    node2-priv

 

#scan

192.168.1.35     cluster-scan

 

 

 

[root@node2 ~]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:79:BA:86 

          inet addr:192.168.1.32 Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:150190 errors:0 dropped:0 overruns:0 frame:0

          TX packets:109804 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:205303912 (195.7 MiB)  TX bytes:20182601 (19.2 MiB)

 

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:79:BA:86 

          inet addr:192.168.1.132  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

 

eth1      Link encap:Ethernet  HWaddr 00:0C:29:79:BA:90 

          inet addr:9.9.9.32  Bcast:9.9.9.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:49075 errors:0 dropped:0 overruns:0 frame:0

          TX packets:49811 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:23642469 (22.5 MiB)  TX bytes:31528595 (30.0 MiB)

 

lo        Link encap:Local Loopback 

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:16496 errors:0 dropped:0 overruns:0 frame:0

          TX packets:16496 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:15118447 (14.4 MiB)  TX bytes:15118447 (14.4 MiB)

 

[root@node2 ~]#

 

 

一.3.3.2  恢复spfilepfile,修改pfile,创建相关路径:

 

 

首先利用rman恢复spfile

[oracle@node1 rman_back]$ ORACLE_SID=orastrac

[oracle@node1 rman_back]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 1 13:25:33 2015

 

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

 

connected to target database (not started)

 

RMAN> set dbid 1317814272

 

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/initorastrac.ora‘

 

starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started

 

Total System Global Area     158662656 bytes

 

Fixed Size                     2211448 bytes

Variable Size                 96469384 bytes

Database Buffers              54525952 bytes

Redo Buffers                   5455872 bytes

 

RMAN> restore spfile to pfile ‘?/dbs/initorastrac.ora‘ from ‘/home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak‘;

 

Starting restore at 01-JUN-2015 13:25:59

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=25 device type=DISK

 

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 01-JUN-2015 13:26:00

 

RMAN>

RMAN> exit

 

 

Recovery Manager complete.

[oracle@node1 rman_back]$ ll /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorastrac.ora

-rw-r--r-- 1 oracle asmadmin 997 Jun  1 13:25 /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorastrac.ora

[oracle@node1 rman_back]$

[oracle@node1 rman_back]$ more /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorastrac.ora

orastrac.__db_cache_size=121634816

orastrac.__java_pool_size=4194304

orastrac.__large_pool_size=4194304

orastrac.__oracle_base=‘/u01/app/oracle‘#ORACLE_BASE set from environment

orastrac.__pga_aggregate_target=167772160

orastrac.__sga_target=243269632

orastrac.__shared_io_pool_size=0

orastrac.__shared_pool_size=100663296

orastrac.__streams_pool_size=0

*.audit_file_dest=‘/u01/app/oracle/admin/orastrac/adump‘

*.audit_trail=‘db‘

*.compatible=‘11.2.0.0.0‘

*.control_files=‘/u01/app/oracle/oradata/orastrac/control01.ctl‘,‘/u01/app/oracle/flash_recovery_area/orastrac/control02.ctl‘

*.db_block_size=8192

*.db_domain=‘‘

*.db_name=‘orastrac‘

*.db_recovery_file_dest=‘/u01/app/oracle/flash_recovery_area‘

*.db_recovery_file_dest_size=4070572032

*.diagnostic_dest=‘/u01/app/oracle‘

*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=orastracXDB)‘

*.log_archive_format=‘%t_%s_%r.dbf‘

*.memory_target=408944640

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile=‘EXCLUSIVE‘

*.undo_tablespace=‘UNDOTBS1‘

[oracle@node1 rman_back]$

 

 

修改与路径相关的参数,修改后如下:

[oracle@node1 dbs]$ more initorastrac.ora

*.audit_file_dest=‘/u01/app/oracle/admin/orastrac/adump‘

*.audit_trail=‘db‘

*.compatible=‘11.2.0.0.0‘

*.control_files=‘+DATA/orastrac/controlfile/control01.ctl‘

*.db_block_size=8192

*.db_domain=‘‘

*.db_name=‘orastrac‘

*.db_recovery_file_dest=‘+ARCH‘

*.db_recovery_file_dest_size=4070572032

*.diagnostic_dest=‘/u01/app/oracle‘

*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=orastracXDB)‘

*.log_archive_format=‘%t_%s_%r.dbf‘

*.memory_target=408944640

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile=‘EXCLUSIVE‘

*.undo_tablespace=‘UNDOTBS1‘

 

 

插曲:注意,这里如果想让控制文件的格式为ASM格式,可以这样设置控制文件的路径:

 

pfile文件中的control_files这样写: *.control_files=‘+DATA‘,‘+ARCH‘,然后还原的时候就可以直接还原为asm格式的文件了,我这里由于是后边补上的,所以就不采用如下的形式了,如下:

 

 

RMAN> restore controlfile   from ‘/home/oracle/rman_back/ctl_ORASTRAC_20150601_7_1.bak‘;

 

Starting restore at 01-JUN-2015 17:59:39

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output file name=+DATA/orastrac/controlfile/current.357.881258379

output file name=+ARCH/orastrac/controlfile/current.369.881258379

Finished restore at 01-JUN-2015 17:59:40

 

RMAN>

 

 

创建os文件路径,注意在节点一和节点二都执行:

[oracle@node1 ~]$ mkdir -p /u01/app/oracle/admin/orastrac/adump

[oracle@node1 ~]$

 

 

注意哟,创建的 spfile 可是要放到共享存储上去的: 

 

[oracle@node1 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 15:49:22 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL>  create spfile=‘+DATA‘ from pfile;

 

File created.

 

SQL>

File created.

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string

SQL>

 

 

查看新创建的spfile的文件名:

ASMCMD> pwd

+DATA/orastrac/PARAMETERFILE

ASMCMD> ls

spfile.335.881250575

ASMCMD>

 

 

[oracle@node1 dbs]$ cp initorastrac.ora initorastrac.ora_bk2

[oracle@node1 dbs]$ echo "SPFILE=‘+DATA/ORASTRAC/PARAMETERFILE/spfile.335.881250575‘" > $ORACLE_HOME/dbs/initorastrac.ora

[oracle@node1 dbs]$

[oracle@node1 dbs]$ more initorastrac.ora

SPFILE=‘+DATA/ORASTRAC/PARAMETERFILE/spfile.335.881250575‘

[oracle@node1 dbs]$

 

一.3.3.3  恢复控制文件

 

[oracle@node1 dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 1 15:46:55 2015

 

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

 

connected to target database (not started)

 

RMAN> startup nomount force;

 

Oracle instance started

 

Total System Global Area     409194496 bytes

 

Fixed Size                     2213856 bytes

Variable Size                272631840 bytes

Database Buffers             130023424 bytes

Redo Buffers                   4325376 bytes

 

RMAN> restore controlfile   from ‘/home/oracle/rman_back/ctl_ORASTRAC_20150601_7_1.bak‘;

 

Starting restore at 01-JUN-2015 15:47:14

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=29 device type=DISK

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:07

output file name=+DATA/orastrac/controlfile/control01.ctl

Finished restore at 01-JUN-2015 15:47:21

 

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

 

RMAN>

 

 

 

 

 

一.3.3.4  还原及恢复数据文件

 

首先得到运行的脚本:

[oracle@node1 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 15:58:47 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a60

SQL> select ‘datafile‘ file_type, file#,name FILE_NAME,status,enabled from v$datafile

  2  union all

  3  select ‘tempfile‘,file#,name FILE_NAME,status,enabled from v$tempfile

  4  union all

  5  select ‘logfile‘,group# file#,member FILE_NAME,status,‘‘ from v$logfile

  6  union all

  7  select ‘controlfile‘, to_number(‘‘) ,name FILE_NAME,status,‘‘ from v$controlfile

  8  ;

 

FILE_TYPE        FILE# FILE_NAME                                                    STATUS  ENABLED

----------- ---------- ------------------------------------------------------------ ------- ----------

datafile             1 /u01/app/oracle/oradata/orastrac/system01.dbf                SYSTEM  READ WRITE

datafile             2 /u01/app/oracle/oradata/orastrac/sysaux01.dbf                ONLINE  READ WRITE

datafile             3 /u01/app/oracle/oradata/orastrac/undotbs01.dbf               ONLINE  READ WRITE

datafile             4 /u01/app/oracle/oradata/orastrac/users01.dbf                 ONLINE  READ WRITE

datafile             5 /u01/app/oracle/oradata/orastrac/example01.dbf               ONLINE  READ WRITE

tempfile             1 /u01/app/oracle/oradata/orastrac/temp01.dbf                  ONLINE  READ WRITE

logfile              3 /u01/app/oracle/oradata/orastrac/redo03.log

logfile              2 /u01/app/oracle/oradata/orastrac/redo02.log

logfile              1 /u01/app/oracle/oradata/orastrac/redo01.log

controlfile            +DATA/orastrac/controlfile/control01.ctl

 

10 rows selected.

 

SQL> set pagesize  200 linesize 200

SQL> select ‘set newname for datafile ‘ || a.FILE# || ‘ to "‘ || a.NAME || ‘";‘

  2    from v$datafile a

  3  union all

  4  select ‘set newname for tempfile ‘ || a.FILE# || ‘ to "‘ || a.NAME || ‘";‘

  5    from v$tempfile a

  6  union all

  7  SELECT ‘SQL "ALTER DATABASE RENAME FILE ‘‘‘‘‘ || a.MEMBER || ‘‘‘‘‘  to  ‘‘‘‘‘ ||

  8         a.MEMBER || ‘‘‘‘‘ ";‘

  9    FROM v$logfile a;

 

‘SETNEWNAMEFORDATAFILE‘||A.FILE#||‘TO"‘||A.NAME||‘";‘

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

set newname for datafile 1 to "/u01/app/oracle/oradata/orastrac/system01.dbf";

set newname for datafile 2 to "/u01/app/oracle/oradata/orastrac/sysaux01.dbf";

set newname for datafile 3 to "/u01/app/oracle/oradata/orastrac/undotbs01.dbf";

set newname for datafile 4 to "/u01/app/oracle/oradata/orastrac/users01.dbf";

set newname for datafile 5 to "/u01/app/oracle/oradata/orastrac/example01.dbf";

set newname for tempfile 1 to "/u01/app/oracle/oradata/orastrac/temp01.dbf";

SQL "ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo03.log‘‘  to  ‘‘/u01/app/oracle/oradata/orastrac/redo03.log‘‘ ";

SQL "ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo02.log‘‘  to  ‘‘/u01/app/oracle/oradata/orastrac/redo02.log‘‘ ";

SQL "ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo01.log‘‘  to  ‘‘/u01/app/oracle/oradata/orastrac/redo01.log‘‘ ";

 

9 rows selected.

 

SQL>

 

 

 

 

查看备份集及还原数据库:

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    

------- ---- -- ---------- ----------- ------------ --------------------

1       Full    501.84M    DISK        00:02:42     01-JUN-2015 11:15:11

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak

  List of Datafiles in backup set 1

  File LV Type Ckp SCN    Ckp Time             Name

  ---- -- ---- ---------- -------------------- ----

  2       Full 1027268    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/sysaux01.dbf

  3       Full 1027268    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/undotbs01.dbf

  5       Full 1027268    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    

------- ---- -- ---------- ----------- ------------ --------------------

2       Full    9.33M      DISK        00:00:10     01-JUN-2015 11:15:48

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881234138_3_1.bak

  Control File Included: Ckp SCN: 1027334      Ckp time: 01-JUN-2015 11:15:38

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    

------- ---- -- ---------- ----------- ------------ --------------------

3       Full    80.00K     DISK        00:00:00     01-JUN-2015 11:15:50

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak

  SPFILE Included: Modification time: 01-JUN-2015 11:12:28

  SPFILE db_unique_name: ORASTRAC

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    

------- ---- -- ---------- ----------- ------------ --------------------

4       Full    599.97M    DISK        00:03:24     01-JUN-2015 11:15:52

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak

  List of Datafiles in backup set 4

  File LV Type Ckp SCN    Ckp Time             Name

  ---- -- ---- ---------- -------------------- ----

  1       Full 1027267    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/system01.dbf

  4       Full 1027267    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/users01.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time    

------- ---------- ----------- ------------ --------------------

5       41.16M     DISK        00:00:02     01-JUN-2015 11:16:07

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111605

        Piece Name: /home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak

 

  List of Archived Logs in backup set 5

  Thrd Seq     Low SCN    Low Time             Next SCN   Next Time

  ---- ------- ---------- -------------------- ---------- ---------

  1    5       1012317    01-JUN-2015 11:04:50 1027356    01-JUN-2015 11:15:59

 

BS Key  Size       Device Type Elapsed Time Completion Time    

------- ---------- ----------- ------------ --------------------

6       2.00K      DISK        00:00:02     01-JUN-2015 11:16:07

        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111605

        Piece Name: /home/oracle/rman_back/arch_ORASTRAC_20150601_6_1.bak

 

  List of Archived Logs in backup set 6

  Thrd Seq     Low SCN    Low Time             Next SCN   Next Time

  ---- ------- ---------- -------------------- ---------- ---------

  1   6       1027356    01-JUN-2015 11:15:59 1027365    01-JUN-2015 11:16:05

 

RMAN>

RMAN> run {

2> ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

3> set newname for datafile 1 to "+DATA";

4> set newname for datafile 2 to "+DATA";

5> set newname for datafile 3 to "+DATA";

6> set newname for datafile 4 to "+DATA";

7> set newname for datafile 5 to "+DATA";

8> set newname for tempfile 1 to "+DATA";

9> SQL "ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo03.log‘‘  to  ‘‘+DATA‘‘ ";

10> SQL "ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo02.log‘‘  to  ‘‘+DATA‘‘ ";

11> SQL "ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo01.log‘‘  to  ‘‘+DATA‘‘ ";

12> restore database;

13> SWITCH DATAFILE ALL;

14> SWITCH TEMPFILE ALL;

15> release channel c1;

16> }

 

allocated channel: c1

channel c1: SID=27 device type=DISK

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

sql statement: ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo03.log‘‘  to  ‘‘+DATA‘‘

 

sql statement: ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo02.log‘‘  to  ‘‘+DATA‘‘

 

sql statement: ALTER DATABASE RENAME FILE ‘‘/u01/app/oracle/oradata/orastrac/redo01.log‘‘  to  ‘‘+DATA‘‘

 

Starting restore at 01-JUN-2015 16:04:19

Starting implicit crosscheck backup at 01-JUN-2015 16:04:19

Crosschecked 6 objects

Finished implicit crosscheck backup at 01-JUN-2015 16:04:19

 

Starting implicit crosscheck copy at 01-JUN-2015 16:04:19

Finished implicit crosscheck copy at 01-JUN-2015 16:04:19

 

searching for all files in the recovery area

cataloging files...

no files cataloged

 

 

channel c1: starting datafile backup set restore

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00002 to +DATA

channel c1: restoring datafile 00003 to +DATA

channel c1: restoring datafile 00005 to +DATA

channel c1: reading from backup piece /home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak

channel c1: piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak tag=TAG20150601T111228

channel c1: restored backup piece 1

channel c1: restore complete, elapsed time: 00:00:48

channel c1: starting datafile backup set restore

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00001 to +DATA

channel c1: restoring datafile 00004 to +DATA

channel c1: reading from backup piece /home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak

channel c1: piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak tag=TAG20150601T111228

channel c1: restored backup piece 1

channel c1: restore complete, elapsed time: 00:00:49

Finished restore at 01-JUN-2015 16:05:58

 

datafile 1 switched to datafile copy

input datafile copy RECID=7 STAMP=881251559 file name=+DATA/orastrac/datafile/system.330.881251509

datafile 2 switched to datafile copy

input datafile copy RECID=8 STAMP=881251559 file name=+DATA/orastrac/datafile/sysaux.331.881251461

datafile 3 switched to datafile copy

input datafile copy RECID=9 STAMP=881251559 file name=+DATA/orastrac/datafile/undotbs1.329.881251463

datafile 4 switched to datafile copy

input datafile copy RECID=10 STAMP=881251559 file name=+DATA/orastrac/datafile/users.327.881251511

datafile 5 switched to datafile copy

input datafile copy RECID=11 STAMP=881251559 file name=+DATA/orastrac/datafile/example.332.881251463

 

renamed tempfile 1 to +DATA in control file

 

released channel: c1

 

RMAN>

 

RMAN> RUN

2> {

3> set until sequence 6; 

4> recover database;

5> }

 

executing command: SET until clause

 

Starting recover at 01-JUN-2015 16:08:53

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=27 device type=DISK

 

starting media recovery

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=5

channel ORA_DISK_1: reading from backup piece /home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak

channel ORA_DISK_1: piece handle=/home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak tag=TAG20150601T111605

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

archived log file name=+ARCH/orastrac/archivelog/2015_06_01/thread_1_seq_5.350.881251737 thread=1 sequence=5

channel default: deleting archived log(s)

archived log file name=+ARCH/orastrac/archivelog/2015_06_01/thread_1_seq_5.350.881251737 RECID=3 STAMP=881251739

media recovery complete, elapsed time: 00:00:02

Finished recover at 01-JUN-2015 16:09:01

 

RMAN>

 

 

 

 

 

 

告警日志:

 

ALTER DATABASE RENAME FILE ‘/u01/app/oracle/oradata/orastrac/redo03.log‘  to  ‘+DATA‘

Completed: ALTER DATABASE RENAME FILE ‘/u01/app/oracle/oradata/orastrac/redo03.log‘  to  ‘+DATA‘

ALTER DATABASE RENAME FILE ‘/u01/app/oracle/oradata/orastrac/redo02.log‘  to  ‘+DATA‘

Completed: ALTER DATABASE RENAME FILE ‘/u01/app/oracle/oradata/orastrac/redo02.log‘  to  ‘+DATA‘

ALTER DATABASE RENAME FILE ‘/u01/app/oracle/oradata/orastrac/redo01.log‘  to  ‘+DATA‘

Completed: ALTER DATABASE RENAME FILE ‘/u01/app/oracle/oradata/orastrac/redo01.log‘  to  ‘+DATA‘

SUCCESS: diskgroup ARCH was mounted

Mon Jun 01 16:04:40 2015

Full restore complete of datafile 5 to datafile copy +DATA/orastrac/datafile/example.332.881251463.  Elapsed time: 0:00:14

  checkpoint is 1027268

  last deallocation scn is 965277

Full restore complete of datafile 3 to datafile copy +DATA/orastrac/datafile/undotbs1.329.881251463.  Elapsed time: 0:00:18

  checkpoint is 1027268

  last deallocation scn is 983226

Mon Jun 01 16:05:05 2015

Full restore complete of datafile 2 to datafile copy +DATA/orastrac/datafile/sysaux.331.881251461.  Elapsed time: 0:00:43

  checkpoint is 1027268

  last deallocation scn is 1026156

Full restore complete of datafile 4 to datafile copy +DATA/orastrac/datafile/users.327.881251511.  Elapsed time: 0:00:03

  checkpoint is 1027267

Mon Jun 01 16:05:49 2015

Full restore complete of datafile 1 to datafile copy +DATA/orastrac/datafile/system.330.881251509.  Elapsed time: 0:00:39

  checkpoint is 1027267

  last deallocation scn is 1025383

Mon Jun 01 16:05:59 2015

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/system01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 1 complete to datafile copy

  checkpoint is 1027267

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/sysaux01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 2 complete to datafile copy

  checkpoint is 1027268

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/undotbs01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 3 complete to datafile copy

  checkpoint is 1027268

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/users01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 4 complete to datafile copy

  checkpoint is 1027267

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/example01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 5 complete to datafile copy

  checkpoint is 1027268

Mon Jun 01 16:06:02 2015

Signalling error 1152 for datafile 1!

Signalling error 1152 for datafile 2!

Signalling error 1152 for datafile 3!

Signalling error 1152 for datafile 4!

Signalling error 1152 for datafile 5!

Checker run found 5 new persistent data failures

 

 

一.3.3.5  RESETLOGS打开数据库并验证数据

 

RMAN>  alter database open resetlogs;

 

database opened

 

RMAN>

 

 

告警日志:

Mon Jun 01 16:09:51 2015

alter database open resetlogs

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

RESETLOGS after incomplete recovery UNTIL CHANGE 1027356

Resetting resetlogs activation ID 1317842432 (0x4e8cae00)

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: ‘+DATA‘

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name ‘+DATA‘ is not in reference form

Mon Jun 01 16:09:54 2015

Setting recovery target incarnation to 3

Mon Jun 01 16:09:54 2015

Assigning activation ID 1317780902 (0x4e8bbda6)

LGWR: STARTING ARCH PROCESSES

Mon Jun 01 16:09:54 2015

ARC0 started with pid=33, OS id=20083

ARC0: Archival started

LGWR: STARTING ARCH PROCESSES COMPLETE

ARC0: STARTING ARCH PROCESSES

Thread 1 opened at log sequence 1

  Current log# 1 seq# 1 mem# 0: +ARCH/orastrac/onlinelog/group_1.350.881251793

Successful open of redo thread 1

MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set

Mon Jun 01 16:09:57 2015

ARC1 started with pid=34, OS id=20087

Mon Jun 01 16:09:57 2015

SMON: enabling cache recovery

Mon Jun 01 16:09:57 2015

ARC2 started with pid=35, OS id=20091

Mon Jun 01 16:09:57 2015

ARC3 started with pid=36, OS id=20095

ARC1: Archival started

ARC2: Archival started

ARC2: Becoming the ‘no FAL‘ ARCH

ARC2: Becoming the ‘no SRL‘ ARCH

ARC1: Becoming the heartbeat ARCH

ARC3: Archival started

ARC0: STARTING ARCH PROCESSES COMPLETE

Mon Jun 01 16:10:03 2015

Successfully onlined Undo Tablespace 2.

Dictionary check beginning

Mon Jun 01 16:10:03 2015

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_dbw0_19220.trc:

ORA-01186: file 201 failed verification tests

ORA-01157: cannot identify/lock data file 201 - see DBWR trace file

ORA-01110: data file 201: ‘+DATA‘

File 201 not verified due to error ORA-01157

Dictionary check complete

Verifying file header compatibility for 11g tablespace encryption..

Verifying 11g file header compatibility for tablespace encryption completed

SMON: enabling tx recovery

Re-creating tempfile +DATA as +DATA/orastrac/tempfile/temp.333.881251803

Database Characterset is ZHS16GBK

No Resource Manager plan active

replication_dependency_tracking turned off (no async multimaster replication found)

Starting background process QMNC

Mon Jun 01 16:10:12 2015

QMNC started with pid=37, OS id=20118

Mon Jun 01 16:10:13 2015

LOGSTDBY: Validating controlfile with logical metadata

LOGSTDBY: Validation complete

Mon Jun 01 16:10:25 2015

Completed: alter database open resetlogs

Mon Jun 01 16:10:26 2015

db_recovery_file_dest_size of 3882 MB is 3.94% used. This is a

user-specified limit on the amount of space that will be used by this

database for recovery-related files, and does not reflect the amount of

space available in the underlying filesystem or ASM diskgroup.

Mon Jun 01 16:10:28 2015

Starting background process CJQ0

Mon Jun 01 16:10:28 2015

CJQ0 started with pid=41, OS id=20162

 

 

此时的数据库还是单实例的,需要启用集群特性来转换为rac数据库。

一.3.3.6  启用集群特性用于转换为RAC环境的数据库

需要修改如下几类参数:

一、 指定实例参数

 

 

[oracle@node1 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 16:12:03 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL> col parameter format a50

SQL> set line 9999

SQL>  select * from v$option where parameter = ‘Real Application Clusters‘;

 

PARAMETER                                          VALUE

-------------------------------------------------- ----------------------------------------------------------------

Real Application Clusters                          TRUE

 

SQL> show parameter cluster

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cluster_database                     boolean     FALSE

cluster_database_instances           integer     1

cluster_interconnects                string

SQL>

 

由上述返回结果可知,RAC 特性是支持的,不过尚未启用集群数据库,因此接下来首先要改的,就是 enable CLUSTER DATABASE,操作如下:

 

 

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      +DATA/orastrac/parameterfile/s

                                                 pfile.335.881250575

SQL>  alter system set cluster_database=true scope=spfile;

 

System altered.

 

SQL>

 

SQL> alter system set cluster_database_instances=2 scope=spfile;

 

System altered.

 

SQL>  alter system set instance_number=1 scope=spfile sid=‘orastrac1‘;

 

System altered.

 

SQL>  alter system set instance_number=2 scope=spfile sid=‘orastrac2‘;

 

System altered.

 

SQL> alter system set thread=1 scope=spfile sid=‘orastrac1‘;

 

System altered.

 

SQL> alter system set thread=2 scope=spfile sid=‘orastrac2‘;

 

System altered.

 

SQL>

 

 

二、 增加undo

新建一组 UNDO 表空间和线程 2 使用的两组 REDO 文件:

 

SQL> select * from v$tablespace;

 

       TS# NAME                           INC BIG FLA ENC

---------- ------------------------------ --- --- --- ---

         0 SYSTEM                         YES NO  YES

         1 SYSAUX                         YES NO  YES

         2 UNDOTBS1                       YES NO  YES

         4 USERS                          YES NO  YES

         3 TEMP                           NO  NO  YES

         6 EXAMPLE                        YES NO  YES

 

6 rows selected.

 

SQL>  create undo tablespace undotbs2 datafile ‘+DATA‘ SIZE 50m;

 

Tablespace created.

 

SQL> alter system set undo_tablespace=‘undotbs1‘ scope=spfile sid=‘orastrac1‘;

 

System altered.

 

SQL> alter system set undo_tablespace=‘undotbs2‘ scope=spfile sid=‘orastrac2‘;

 

System altered.

 

 

 

三、 增加redo

SQL> select * from v$log;

 

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------

         1          1          1   52428800        512          1 NO  CURRENT                1027357 01-JUN-15   2.8147E+14

         2          1          0   52428800        512          1 YES UNUSED                       0                      0

         3          1          0   52428800        512          1 YES UNUSED                       0                      0

 

SQL>  alter database add logfile thread 2 group 4 ‘+arch‘ size 50M;

 

Database altered.

 

SQL> alter database add logfile thread 2 group 5 ‘+arch‘ size 50M;

 

Database altered.

 

SQL> alter database add logfile thread 2 group 6 ‘+arch‘ size 50M;

 

Database altered.

 

SQL> select * from v$log;

 

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------

         1          1          1   52428800        512          1 NO  CURRENT                1027357 01-JUN-15   2.8147E+14

         2          1          0   52428800        512          1 YES UNUSED                       0                      0

         3          1          0   52428800        512          1 YES UNUSED                       0                      0

         4          2          0   52428800        512          1 YES UNUSED                       0                      0

         5          2          0   52428800        512          1 YES UNUSED                       0                      0

         6          2          0   52428800        512          1 YES UNUSED                       0                      0

 

6 rows selected.

 

SQL> col instance format a8

SQL> select thread#,instance,status,enabled from v$thread;

 

   THREAD# INSTANCE STATUS ENABLED

---------- -------- ------ --------

         1 orastrac OPEN   PUBLIC

         2 UNNAMED_ CLOSED DISABLED

           INSTANCE

           _2

 

 

SQL> alter database enable thread 2 ;

 

Database altered.

 

SQL> select thread#,instance,status,enabled from v$thread;

 

   THREAD# INSTANCE STATUS ENABLED

---------- -------- ------ --------

         1 orastrac OPEN   PUBLIC

         2 UNNAMED_ CLOSED PRIVATE

           INSTANCE

           _2

 

 

SQL>

 

 

 

一.3.3.7  重启数据库

重启数据库,在每个节点上修改pfile文件:

一、 节点一

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

[oracle@node1 dbs]$ ORACLE_SID=orastrac1

[oracle@node1 dbs]$ echo "SPFILE=‘+DATA/ORASTRAC/PARAMETERFILE/spfile.335.881250575‘" > $ORACLE_HOME/dbs/initorastrac1.ora

[oracle@node1 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 16:32:38 2015

 

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

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2213856 bytes

Variable Size             314574880 bytes

Database Buffers           88080384 bytes

Redo Buffers                4325376 bytes

Database mounted.

Database opened.

SQL>

SQL> show parameter cluster

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cluster_database                     boolean     TRUE

cluster_database_instances           integer     2

cluster_interconnects                string

SQL> set line 9999

col HOST_NAME format a10

select INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,ACTIVE_STATE,INSTANCE_ROLE,DATABASE_STATUS from gv$INSTANCE;

 

INSTANCE_NAME    HOST_NAME  VERSION           STARTUP_T STATUS       ACTIVE_ST INSTANCE_ROLE      DATABASE_STATUS

---------------- ---------- ----------------- --------- ------------ --------- ------------------ -----------------

orastrac1        node1      11.2.0.1.0        01-JUN-15 OPEN         NORMAL    PRIMARY_INSTANCE   ACTIVE

 

SQL> select INST_ID,name , open_mode, log_mode,force_logging from gv$database;

 

   INST_ID NAME      OPEN_MODE            LOG_MODE     FOR

---------- --------- -------------------- ------------ ---

         1 ORASTRAC  READ WRITE           ARCHIVELOG   NO

 

SQL>

SQL>  select count(1) FROM LHR.TEST_RAC;

 

  COUNT(1)

----------

     72468

 

SQL>

 

 

 

二、 节点二

[oracle@node1 dbs]$ ORACLE_SID=orastrac2

[oracle@node1 dbs]$ echo "SPFILE=‘+DATA/ORASTRAC/PARAMETERFILE/spfile.335.881250575‘" > $ORACLE_HOME/dbs/initorastrac2.ora

[oracle@node1 dbs]$ sqlplus / as sysdba

[oracle@node2 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 17:14:00 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2213856 bytes

Variable Size             314574880 bytes

Database Buffers           88080384 bytes

Redo Buffers                4325376 bytes

Database mounted.

Database opened.

 

 

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      +DATA/orastrac/parameterfile/s

                                                 pfile.335.881250575

SQL>

 

SQL> show parameter cluster

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cluster_database                     boolean     TRUE

cluster_database_instances           integer     2

cluster_interconnects                string

SQL> set line 9999

SQL> col HOST_NAME format a10

SQL> select INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,ACTIVE_STATE,INSTANCE_ROLE,DATABASE_STATUS from gv$INSTANCE;

 

INSTANCE_NAME    HOST_NAME  VERSION           STARTUP_T STATUS       ACTIVE_ST INSTANCE_ROLE      DATABASE_STATUS

---------------- ---------- ----------------- --------- ------------ --------- ------------------ -----------------

orastrac1        node1      11.2.0.1.0        01-JUN-15 OPEN         NORMAL    PRIMARY_INSTANCE   ACTIVE

orastrac2        node2      11.2.0.1.0        01-JUN-15 OPEN         NORMAL    PRIMARY_INSTANCE   ACTIVE

 

SQL> select INST_ID,name , open_mode, log_mode,force_logging from gv$database;

 

   INST_ID NAME      OPEN_MODE            LOG_MODE     FOR

---------- --------- -------------------- ------------ ---

         1 ORASTRAC  READ WRITE           ARCHIVELOG   NO

         2 ORASTRAC  READ WRITE           ARCHIVELOG   NO

 

SQL>

SQL>  select count(1) FROM LHR.TEST_RAC;

 

  COUNT(1)

----------

     72468

 

SQL>

 

 

 

 

 

数据已经恢复,下边把新恢复的数据库注册到crs

 

 

 

一.3.3.8  注册到crs服务

 

[oracle@node2 ~]$ crsstat

Name                           Type                       Target     State      Host      

------------------------------ -------------------------- ---------- ---------  -------  

ora.ARCH.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.DATA.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.LISTENER.lsnr              ora.listener.type          ONLINE     ONLINE     node1    

ora.LISTENER_SCAN1.lsnr        ora.scan_listener.type     ONLINE     ONLINE     node1    

ora.OVDISK.dg                  ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.TEST.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.asm                        ora.asm.type               ONLINE     ONLINE     node1    

ora.db.db                      ora.database.type          ONLINE     OFFLINE             

ora.eons                       ora.eons.type              ONLINE     ONLINE     node1    

ora.gsd                        ora.gsd.type               OFFLINE    OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     OFFLINE             

ora.jmrac.haha.svc             ora.service.type           ONLINE     OFFLINE             

ora.net1.network               ora.network.type           ONLINE     ONLINE     node1    

ora.node1.ASM1.asm             application                ONLINE     ONLINE     node1    

ora.node1.LISTENER_NODE1.lsnr  application                ONLINE     ONLINE     node1    

ora.node1.gsd                  application                OFFLINE    OFFLINE             

ora.node1.ons                  application                ONLINE     ONLINE     node1    

ora.node1.vip                  ora.cluster_vip_net1.type  ONLINE     ONLINE     node1    

ora.node2.ASM2.asm             application                ONLINE     ONLINE     node2    

ora.node2.LISTENER_NODE2.lsnr  application                ONLINE     ONLINE     node2    

ora.node2.gsd                  application                OFFLINE    OFFLINE             

ora.node2.ons                  application                ONLINE     ONLINE     node2    

ora.node2.vip                  ora.cluster_vip_net1.type  ONLINE     ONLINE     node2    

ora.oc4j                       ora.oc4j.type              OFFLINE    OFFLINE             

ora.ons                        ora.ons.type               ONLINE     ONLINE     node1    

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

ora.registry.acfs              ora.registry.acfs.type     ONLINE     ONLINE     node1    

ora.scan1.vip                  ora.scan_vip.type          ONLINE     ONLINE     node1    

[oracle@node2 ~]$ crsstat | grep ora.database.type

ora.db.db                      ora.database.type          ONLINE     OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     OFFLINE             

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

[oracle@node2 ~]$

[oracle@node2 ~]$ srvctl add database -d orastrac -h

 

Adds a database configuration to the Oracle Clusterware.

 

Usage: srvctl add database -d <db_unique_name> -o <oracle_home> [-m <domain_name>] [-p <spfile>] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY}] [-s <start_options>] [-t <stop_options>] [-n <db_name>] [-y {AUTOMATIC | MANUAL}] [-g "<serverpool_list>"] [-x <node_name>] [-a "<diskgroup_list>"]

    -d <db_unique_name>      Unique name for the database

    -o <oracle_home>         ORACLE_HOME path

    -x <node_name>           Node name. -x option is specified for single-instance databases

    -m <domain>              Domain for database. Must be set if database has DB_DOMAIN set.

    -p <spfile>              Server parameter file path

    -r <role>                Role of the database (primary, physical_standby, logical_standby, snapshot_standby)

    -s <start_options>       Startup options for the database. Examples of startup options are open, mount, or nomount.

    -t <stop_options>        Stop options for the database. Examples of shutdown options are normal, transactional, immediate, or abort.

    -n <db_name>        Database name (DB_NAME), if different from the unique name given by the -d option

    -y <dbpolicy>            Management policy for the database (AUTOMATIC or MANUAL)

    -g "<serverpool_list>"    Comma separated list of database server pool names

    -a "<diskgroup_list>"      Comma separated list of disk groups

    -h                       Print usage

[oracle@node2 ~]$ srvctl add database -d orastrac -o $ORACLE_HOME -p +DATA/orastrac/parameterfile/spfile.335.881250575

[oracle@node2 ~]$ srvctl config database -d orastrac

Database unique name: orastrac

Database name:

Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/orastrac/parameterfile/spfile.335.881250575

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools: orastrac

Database instances:

Disk Groups:

Services:

Database is administrator managed

[oracle@node2 ~]$ srvctl add instance -d orastrac -i orastrac1 -n node1

[oracle@node2 ~]$ srvctl add instance -d orastrac -i orastrac2 -n node2

[oracle@node2 ~]$ srvctl config database -d orastrac

Database unique name: orastrac

Database name:

Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/orastrac/parameterfile/spfile.335.881250575

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools: orastrac

Database instances: orastrac1,orastrac2

Disk Groups:

Services:

Database is administrator managed

[oracle@node2 ~]$

[oracle@node2 ~]$ crsstat | grep ora.database.type

ora.db.db                      ora.database.type          ONLINE     OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     OFFLINE             

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

ora.orastrac.db                ora.database.type          OFFLINE    OFFLINE             

[oracle@node2 ~]$

[oracle@node2 ~]$ srvctl status database -d orastrac

Instance orastrac1 is not running on node node1

Instance orastrac2 is not running on node node2

[oracle@node2 ~]$ srvctl start database -d orastrac

[oracle@node2 ~]$ srvctl status database -d orastrac

Instance orastrac1 is running on node node1

Instance orastrac2 is running on node node2

[oracle@node2 ~]$

[oracle@node2 ~]$ crsstat | grep ora.database.type

ora.db.db                      ora.database.type          ONLINE     OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     OFFLINE             

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

ora.orastrac.db                ora.database.type          ONLINE     ONLINE     node1    

[oracle@node2 ~]$

 

 

 

上述 3 条命令分别配置了数据库和两个实例,此时 3 项服务刚刚配置完成,crs 中尚未同步其状态,因此需要执行一下 srvctl start database,然后再通过 crs_stat 即可查看正确的状态了

 

 

 

OK,现在已经是集群的数据库了,整个恢复工作基本完成。剩下的比如修改监听、配置网络服务名,创建密钥文件等操作相信大家已经熟悉的不能再熟悉,这里不再演示相关操作了(注意密钥文件也是建议创建到共享存储端,否则的话就得在各个节点分别创建一份)

 

一.3.4  实验总结

 

单实例的数据库备份集恢复到rac环境下其实很简单,和一般的恢复步骤都一样的,不过在恢复spfilecontrol filedatafile的时候需要放在共享存储里边,另外恢复完成后需要修改一些集群相关的参数才可以转换为集群数据库。

 

 

一.4  总结

 

到此所有的处理算是基本完毕,过程很简单,但是不同的场景处理方式有很多种,我们应该学会灵活变通。

 

 

 

一.5  About Me

 

...........................................................................................................................................................................................

本文作者:小麦苗,只专注于数据库的技术,更注重技术的运用

ITPUB BLOG:http://blog.itpub.net/26736162

本文地址:http://blog.itpub.net/26736162/viewspace-1682250/

本文pdf版:http://yunpan.cn/QCwUAI9bn7g7w  提取码:af2d

QQ:642808185 若加QQ请注明你所正在读的文章标题

创作时间地点:2015-06-01 10:00~ 2015-06-02 12:00 于外汇交易中心

<版权所有,文章允许转载,但须以链接方式注明源地址,否则追究法律责任!>

...........................................................................................................................................................................................

 

 

【RAC】将单实例备份集恢复为rac数据库

标签:

原文地址:http://www.cnblogs.com/lhrbest/p/4546653.html

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