Oracle 11g单实例RMAN恢复到Oracle 11g RAC

一、环境说明

操作系统版本: RHEL 6.5 x64

1. 源数据库服务器

Oracle版本: Oracle 11g 11.2.0.4 64位(单机)
Oracle_SID: orcl 
db_name   : orcl

背景:一台生产oracle10g(10.2.0.5)数据库计划迁移到Oracle 11.2.0.4.0 RAC.
1) 先oracle10g(10.2.0.5)升级到Oracle 11.2.0.4(过程略)
2)再Oracle 11.2.0.4单实例迁移到Oracle 11.2.0.4 RAC集群


2. 目标数据库服务器

操作系统:RHEL 6.8 x64 安装注意点:
Oracle版本: Oracle 11g 11.2.0.4 RAC 64位
Oracle_SID: orcl1 / orcl2 
db_name  : orcl

说明:
1)RAC与单实例的数据库名一致,不需要重新创建一个实例或恢复一个实例,这也是需要提前考虑的内容。
2)可以直接在RAC原实例上做恢复处理,可以减少一些操作步骤,例如参数文件、口令文件等可以利用原RAC配置即可,无需要修改。


二、源DB服务器

1. 源服务器环境说明

源服务器通过执行 RMAN备份,需要执行异机RAC恢复操作。

2. 备份源数据库

备份脚本内容

#!/bin/bash
# ScriptName:rmanbakup.sh
# Usage: backup all files in oracle user environment.
# Author: koumm
# Creation: 2017-09-16
# Version: 1.0.0

#Define variable <You may need to change the value of basedir.>
basedir=/u01/orabak
date=`date +%Y%m%d`

#Create pfile
sqlplus / as sysdba <<EOF
create pfile='$basedir/pfile$date.ora' from spfile;
EOF

#RMAN BACKUP
rman target / log=$basedir/backup_all_$date.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup database filesperset 4 format '$basedir/full_%d_%T_%s_%p';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup archivelog all format '$basedir/arch_%d_%T_%s_%p' delete input;
backup current controlfile format '$basedir/ctl_%d_%T_%s_%p';
release channel c1;
release channel c2;
}
EOF

3. 备份集目录内容

[oracle@ora11g orabak]$ ll -h
total 1.4G
-rw-r----- 1 oracle oinstall  16M Sep 16 08:29 arch_ORCL_20170916_5_1
-rw-r----- 1 oracle oinstall 3.5K Sep 16 08:29 arch_ORCL_20170916_6_1
-rw-r----- 1 oracle oinstall 2.5K Sep 16 08:29 arch_ORCL_20170916_7_1
-rw-r--r-- 1 oracle oinstall 4.8K Sep 16 08:29 backup_all_20170916.log
-rw-r----- 1 oracle oinstall 9.4M Sep 16 08:29 ctl_ORCL_20170916_8_1
-rw-r----- 1 oracle oinstall 707M Sep 16 08:29 full_ORCL_20170916_1_1
-rw-r----- 1 oracle oinstall 642M Sep 16 08:28 full_ORCL_20170916_2_1
-rw-r----- 1 oracle oinstall 9.4M Sep 16 08:28 full_ORCL_20170916_3_1
-rw-r----- 1 oracle oinstall  96K Sep 16 08:28 full_ORCL_20170916_4_1
-rw-r--r-- 1 oracle oinstall 1.1K Sep 16 08:28 pfile20170916.ora
[oracle@ora11g orabak]$

4. 把备份集传到目标数据库rac db1上

[root@ora11g u01]# scp -r /u01/orabak 192.168.0.135:/u01/
root@192.168.0.135's password: 
full_ORCL_20170916_2_1                                                                                        100%  641MB 106.9MB/s   00:06    
full_ORCL_20170916_1_1                                                                                        100%  707MB  88.3MB/s   00:08    
ctl_ORCL_20170916_8_1                                                                                         100% 9568KB   9.3MB/s   00:00    
arch_ORCL_20170916_7_1                                                                                        100% 2560     2.5KB/s   00:00    
pfile20170916.ora                                                                                             100% 1053     1.0KB/s   00:00    
full_ORCL_20170916_3_1                                                                                        100% 9568KB   9.3MB/s   00:00    
full_ORCL_20170916_4_1                                                                                        100%   96KB  96.0KB/s   00:00    
arch_ORCL_20170916_5_1                                                                                        100%   16MB  15.7MB/s   00:00    
arch_ORCL_20170916_6_1                                                                                        100% 3584     3.5KB/s   00:00    
backup_all_20170916.log                                                                                       100% 4851     4.7KB/s   00:00


三、目的服务器上做RMAN恢复准备

1. 查看RAC磁盘挂载情况以及名称

[root@db1 ~]# su - grid
[root@db1 ~]$ sqlplus / as sysasm

col name for a10
col state for a10
select group_number , name , state, type, total_mb, free_mb  from v$asm_diskgroup ;

SQL> select group_number , name , state, type, total_mb, free_mb  from v$asm_diskgroup ;

GROUP_NUMBER NAME    STATE       TYPE       TOTAL_MB    FREE_MB
------------ ---------- ---------- ------------ ---------- ----------
       1 CRS    MOUNTED    NORMAL         30720    29794
       2 DATA    MOUNTED    EXTERN         40960    39032
       3 RECOVERY    MOUNTED    EXTERN         25952    24758

 

2. 检查备份集目录以及文件权限

[root@db1 u01]# chown -R oracle:oinstall /u01/orabak
[root@db1 u01]# ll -h /u01/orabak/
total 1.4G
-rw-r----- 1 oracle oinstall  16M Sep 16 14:48 arch_ORCL_20170916_5_1
-rw-r----- 1 oracle oinstall 3.5K Sep 16 14:48 arch_ORCL_20170916_6_1
-rw-r----- 1 oracle oinstall 2.5K Sep 16 14:48 arch_ORCL_20170916_7_1
-rw-r--r-- 1 oracle oinstall 4.8K Sep 16 14:48 backup_all_20170916.log
-rw-r----- 1 oracle oinstall 9.4M Sep 16 14:48 ctl_ORCL_20170916_8_1
-rw-r----- 1 oracle oinstall 707M Sep 16 14:48 full_ORCL_20170916_1_1
-rw-r----- 1 oracle oinstall 642M Sep 16 14:48 full_ORCL_20170916_2_1
-rw-r----- 1 oracle oinstall 9.4M Sep 16 14:48 full_ORCL_20170916_3_1
-rw-r----- 1 oracle oinstall  96K Sep 16 14:48 full_ORCL_20170916_4_1
-rw-r--r-- 1 oracle oinstall 1.1K Sep 16 14:48 pfile20170916.ora


3. 查看集群状态

[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.CRS.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.LISTENER.lsnr
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.RECOVERY.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.asm
               ONLINE  ONLINE       db1                      Started             
               ONLINE  ONLINE       db2                      Started             
ora.gsd
               OFFLINE OFFLINE      db1                                          
               OFFLINE OFFLINE      db2                                          
ora.net1.network
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.ons
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.registry.acfs
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db1                                          
ora.cvu
      1        ONLINE  ONLINE       db2                                          
ora.db1.vip
      1        ONLINE  ONLINE       db1                                          
ora.db2.vip
      1        ONLINE  ONLINE       db2                                          
ora.oc4j
      1        ONLINE  ONLINE       db2                                          
ora.orcl.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.scan1.vip
      1        ONLINE  ONLINE       db1            


4. 关闭集群参数并关闭数据库实例准备恢复

$ sqlplus / as sysdba;

SQL> alter system set cluster_database=true scope=spfile sid='*';

$ srvctl stop database -d orcl

 

四、目标服务器上恢复数据

1. 启动到nomount状态

[oracle@db1 ~]$ su - oracle
[oracle@db1 ~]$ sqlplus / as sysdba

SQL> startup nomount;


2. 因实例名称一致,spfile文件不需要恢复,保留原参数文件以及相关配置。

3. 口令文件也保留

4. 恢复控制文件

(1) 通过指定备份集恢复控制文件

[oracle@db1 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Sep 16 09:11:45 2017

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

connected to target database: ORCL (not mounted)

RMAN> restore controlfile from '/u01/orabak/ctl_ORCL_20170916_8_1';

Starting restore at 2017/09/16 09:12:58
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 instance=orcl1 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=+DATA/orcl/controlfile/current.260.937131879
output file name=+RECOVERY/orcl/controlfile/current.256.937131879
Finished restore at 2017/09/16 09:13:00

 

5. 通过备份的控制文件启动到mount状态


注:具体哪个文件还原控制文件,可参数源端运行 list backup of controlfile 可知。

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1


6. 将备份集注册进控制文件里

RMAN> crosscheck backupset;
RMAN> catalog start with '/u01/orabak'; 
RMAN> list backup summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
1       B  F  A DISK        2017/09/16 08:28:46 1       1       NO         TAG20170916T082835
2       B  F  A DISK        2017/09/16 08:28:52 1       1       NO         TAG20170916T082835
3       B  F  A DISK        2017/09/16 08:28:53 1       1       NO         TAG20170916T082835
4       B  F  A DISK        2017/09/16 08:29:14 1       1       NO         TAG20170916T082835
5       B  A  A DISK        2017/09/16 08:29:23 1       1       NO         TAG20170916T082923
6       B  A  A DISK        2017/09/16 08:29:23 1       1       NO         TAG20170916T082923
7       B  A  A DISK        2017/09/16 08:29:24 1       1       NO         TAG20170916T082923
8       B  F  A DISK        2017/09/16 08:29:24 1       1       NO         TAG20170916T082924

 

7. 查看与记录数据库信息

由于控制文件记录的是原oracle10g rac数据库文件的信息,需要记录下来在恢复时进行修改。

(1) 查看源端数据文件及编号

$ sqlplus / as sysdba;

SQL> set pagesize 999;
SQL> set linesize 200;
SQL> col NAME for a65
SQL> select file#,name from v$datafile;

     FILE# NAME
---------- -----------------------------------------------------------------
     1 /u01/app/oracle/oradata/orcl/system01.dbf
     2 /u01/app/oracle/oradata/orcl/sysaux01.dbf
     3 /u01/app/oracle/oradata/orcl/undotbs01.dbf
     4 /u01/app/oracle/oradata/orcl/users01.dbf
     5 /u01/app/oracle/oradata/orcl/tjoa.dbf


(2) 查看联机日志文件

SQL> col MEMBER for a65
SQL> select member from v$logfile;
SQL> select member from v$logfile;

MEMBER
-----------------------------------------------------------------
/u01/app/oracle/oradata/orcl/redo03.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo01.log


(3) 查看临时文件

SQL> select name from v$tempfile;

NAME
-----------------------------------------------------------------
/u01/app/oracle/oradata/orcl/temp01.dbf


(4) 查看源端数据文件构造RMAN RUN脚本。

SQL> set line 80
SQL> set pagesize 9999
SQL> col file_name for a60
SQL> select 'set newname for datafile '||file_id||' to '''||'+DATA'||''';' cmd from dba_data_files order by file_id;

CMD
-----------------------------------------------------------------------------
set newname for datafile 1 to '+DATA';
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
set newname for datafile 5 to '+DATA';

SQL> select 'set newname for tempfile '||file_id||' to '''||'+DATA'||''';' cmd from dba_temp_files;

CMD
-----------------------------------------------------------------------------
set newname for tempfile 1 to '+DATA';


8. 恢复数据文件

#通过RMAN重命名数据文件进行恢复到本地的文件系统上。

rman target /

run {
set newname for datafile 1 to '+DATA';
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
set newname for datafile 5 to '+DATA';
set newname for tempfile 1 to '+DATA';
restore database;
switch datafile all;
switch tempfile all;
}


executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 2017/09/16 10:11:14
using channel ORA_DISK_1
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 +DATA
channel ORA_DISK_1: restoring datafile 00003 to +DATA
channel ORA_DISK_1: restoring datafile 00005 to +DATA
channel ORA_DISK_1: reading from backup piece /u01/orabak/full_ORCL_20170916_2_1
channel ORA_DISK_1: piece handle=/u01/orabak/full_ORCL_20170916_2_1 tag=TAG20170916T082835
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
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 +DATA
channel ORA_DISK_1: restoring datafile 00004 to +DATA
channel ORA_DISK_1: reading from backup piece /u01/orabak/full_ORCL_20170916_1_1
channel ORA_DISK_1: piece handle=/u01/orabak/full_ORCL_20170916_1_1 tag=TAG20170916T082835
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 2017/09/16 10:12:05
datafile 1 switched to datafile copy
input datafile copy RECID=6 STAMP=954843125 file name=+DATA/orcl/datafile/system.268.954843075
datafile 2 switched to datafile copy
input datafile copy RECID=7 STAMP=954843125 file name=+DATA/orcl/datafile/sysaux.271.954843101
datafile 3 switched to datafile copy
input datafile copy RECID=8 STAMP=954843125 file name=+DATA/orcl/datafile/undotbs1.269.954843075
datafile 4 switched to datafile copy
input datafile copy RECID=9 STAMP=954843126 file name=+DATA/orcl/datafile/users.272.954843101
datafile 5 switched to datafile copy
input datafile copy RECID=10 STAMP=954843126 file name=+DATA/orcl/datafile/tjoa.270.954843075
renamed tempfile 1 to +DATA in control file

9. 恢复数据库

RMAN> list backup of archivelog all;

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


BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
5       3.00K      DISK        00:00:00     2017/09/16 08:29:23
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20170916T082923
        Piece Name: /u01/orabak/arch_ORCL_20170916_6_1

  List of Archived Logs in backup set 5
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    120     2896890    2017/09/16 08:29:19 2896899    2017/09/16 08:29:19
  1    121     2896899    2017/09/16 08:29:19 2896908    2017/09/16 08:29:23
  1    122     2896908    2017/09/16 08:29:23 2896917    2017/09/16 08:29:23

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
6       15.68M     DISK        00:00:00     2017/09/16 08:29:23
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20170916T082923
        Piece Name: /u01/orabak/arch_ORCL_20170916_5_1

  List of Archived Logs in backup set 6
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    119     2888996    2017/09/16 06:00:12 2896890    2017/09/16 08:29:19

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
7       2.00K      DISK        00:00:00     2017/09/16 08:29:24
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20170916T082923
        Piece Name: /u01/orabak/arch_ORCL_20170916_7_1

  List of Archived Logs in backup set 7
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    123     2896917    2017/09/16 08:29:23 2896925    2017/09/16 08:29:23


注:根据备份集可以先恢复到SCN为 2896925 ,如果直接 recover database 会因丢失部分日志报错,但可以忽略。

RMAN> recover database until scn 2896925;

Starting recover at 2017/09/16 10:14:25
using channel ORA_DISK_1
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=119
channel ORA_DISK_1: reading from backup piece /u01/orabak/arch_ORCL_20170916_5_1
channel ORA_DISK_1: piece handle=/u01/orabak/arch_ORCL_20170916_5_1 tag=TAG20170916T082923
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_119.302.954843267 thread=1 sequence=119
channel default: deleting archived log(s)
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_119.302.954843267 RECID=6 STAMP=954843266
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=120
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=121
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=122
channel ORA_DISK_1: reading from backup piece /u01/orabak/arch_ORCL_20170916_6_1
channel ORA_DISK_1: piece handle=/u01/orabak/arch_ORCL_20170916_6_1 tag=TAG20170916T082923
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_120.302.954843269 thread=1 sequence=120
channel default: deleting archived log(s)
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_120.302.954843269 RECID=7 STAMP=954843268
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_121.303.954843269 thread=1 sequence=121
channel default: deleting archived log(s)
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_121.303.954843269 RECID=8 STAMP=954843268
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_122.304.954843269 thread=1 sequence=122
channel default: deleting archived log(s)
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_122.304.954843269 RECID=9 STAMP=954843268
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=123
channel ORA_DISK_1: reading from backup piece /u01/orabak/arch_ORCL_20170916_7_1
channel ORA_DISK_1: piece handle=/u01/orabak/arch_ORCL_20170916_7_1 tag=TAG20170916T082923
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_123.304.954843271 thread=1 sequence=123
channel default: deleting archived log(s)
archived log file name=+RECOVERY/orcl/archivelog/2017_09_16/thread_1_seq_123.304.954843271 RECID=10 STAMP=954843269
media recovery complete, elapsed time: 00:00:00
Finished recover at 2017/09/16 10:14:30

 

10. 修改联机日志文件的路径

[oracle@db1 ~]$ sqlplus / as sysdba
set line 150
col member for a50
select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                          IS_
---------- ------- ------- -------------------------------------------------- ---
     3       ONLINE  /u01/app/oracle/oradata/orcl/redo03.log          NO
     2       ONLINE  /u01/app/oracle/oradata/orcl/redo02.log          NO
     1       ONLINE  /u01/app/oracle/oradata/orcl/redo01.log          NO


alter database rename file '/u01/app/oracle/oradata/orcl/redo01.log' to '+DATA';
alter database rename file '/u01/app/oracle/oradata/orcl/redo02.log' to '+DATA';
alter database rename file '/u01/app/oracle/oradata/orcl/redo03.log' to '+DATA';

# 查看redolog文件

SQL> col member for a50;
SQL> select group#,member from v$logfile;

    GROUP# STATUS  TYPE    MEMBER           IS_
---------- ------- ------- -------------------------------------------------- ---
  3    ONLINE  +DATA           NO
  2    ONLINE  +DATA           NO
  1    ONLINE  +DATA           NO

 

11. 打开数据库

采用resetlogs打开数据库

说明:采用rman备份没有redolog文件,以及采用恢复的控制文件进行恢复,恢复时采用不完全恢复。
需要使用resetlogs方式打开数据库。

SQL> alter database open resetlogs;


 

12. 查看并修改参数

SQL> col value for a10
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     2
cluster_interconnects             string


SQL> show parameter thread

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
parallel_threads_per_cpu         integer     2
thread                     integer     1


SQL> show parameter instance_number
NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
instance_number                      integer     1


SQL> alter system set cluster_database=true scope=spfile sid='*';
SQL> alter system set cluster_database_instances=2 scope=spfile sid='*';
SQL> alter system set instance_number=1 scope=spfile sid='orcl1';
SQL> alter system set instance_number=2 scope=spfile sid='orcl2';
SQL> alter system set thread=1 scope=spfile sid='orcl1';
SQL> alter system set thread=2 scope=spfile sid='orcl2';


 

13. 创建节点2的UNDO表空间(节点1上操作即可)

SQL> show parameter undo_tablespace

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace              string     UNDOTBS1


SQL> create undo tablespace UNDOTBS2 datafile '+DATA/orcl/datafile/undotbs02.dbf' size 100M;
SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile sid='orcl2';

 

14. 增加节点2的REDO文件(节点1上操作即可)

alter database add logfile thread 2 group 4 ('+DATA','+RECOVERY') size 50M;
alter database add logfile thread 2 group 5 ('+DATA','+RECOVERY') size 50M;
alter database add logfile thread 2 group 6 ('+DATA','+RECOVERY') size 50M;
alter database enable thread 2;

 

15. 重建temp表空间

因为在 recover 的时候不会对temp 表空间进行recover。所以recover 后,我们要手工重建temp表空间。

[root@db1 ~]# su - grid
[grid@db1 ~]$ asmcmd lsof |grep temp
orcl     orcl1          +data/orcl/tempfile/temp.276.954903205  


或 切换到oracle用户
[root@db1 ~]# su - oracle
[oracle@db1 ~]$ sqlplus / as sysdba

SQL> alter tablespace temp add tempfile '+DATA' size 100M;
Tablespace altered.

SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA/orcl/tempfile/temp.276.954903205
+DATA/orcl/tempfile/temp.281.954903453


SQL> alter database tempfile '+DATA/orcl/tempfile/temp.276.954903205' offline ;
Database altered.

SQL> alter database tempfile '+DATA/orcl/tempfile/temp.276.954903205' drop including datafiles;
alter database tempfile '+DATA/orcl/tempfile/temp.276.954903205' drop including datafiles
*
ERROR at line 1:
ORA-25152: TEMPFILE cannot be dropped at this time

SQL> shutdown immediate;
SQL> startup

SQL>  alter database tempfile '+DATA/orcl/tempfile/temp.276.954903205' drop including datafiles;

Database altered.

 

16. 确认实例情况

[oracle@db1 oracle]$ srvctl stop database -d orcl -o immediate
[oracle@db1 oracle]$ srvctl start database -d orcl -o open


[oracle@db1 ~]$ sqlplus / as sysdba

SQL> col instance_name for a20
SQL> col host_name for a10
SQL> select instance_number,instance_name ,host_name from gv$instance;

INSTANCE_NUMBER INSTANCE_NAME         HOST_NAME
--------------- -------------------- ----------
          1 orcl1             db1
          2 orcl2             db2

 

17. 执行catclust.sql脚本创建相关视图

SQL> @$ORACLE_HOME/rdbms/admin/catclust.sql

Package created.
Package body created.
PL/SQL procedure successfully completed.
View created.
Synonym created.
Grant succeeded.
View created.
Grant succeeded.
Synonym created.
View created.
Grant succeeded.
Synonym created.
View created.
Grant succeeded.
Synonym created.
View created.
Grant succeeded.
Synonym created.
View created.
Grant succeeded.
Synonym created.
View created.
Grant succeeded.
Synonym created.
View created.
Grant succeeded.
Synonym created.
View created.
Grant succeeded.
View created.
Grant succeeded.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
Synonym created.
View created.
Grant succeeded.
Synonym created.
View created.
Grant succeeded.
Synonym created.
PL/SQL procedure successfully completed.

 

18. 查看在线日志情况

SQL> set pagesize 9999
SQL> col member for a50
SQL> select group#,member from v$logfile order by group#;

    GROUP# MEMBER
---------- --------------------------------------------------
     1 +DATA/orcl/onlinelog/group_1.273.954903193
     1 +RECOVERY/orcl/onlinelog/group_1.301.954903195
     2 +RECOVERY/orcl/onlinelog/group_2.300.954903195
     2 +DATA/orcl/onlinelog/group_2.274.954903195
     3 +DATA/orcl/onlinelog/group_3.275.954903197
     3 +RECOVERY/orcl/onlinelog/group_3.299.954903197
     4 +DATA/orcl/onlinelog/group_4.278.954903353
     4 +RECOVERY/orcl/onlinelog/group_4.302.954903353
     5 +DATA/orcl/onlinelog/group_5.279.954903353
     5 +RECOVERY/orcl/onlinelog/group_5.303.954903355
     6 +DATA/orcl/onlinelog/group_6.280.954903355
     6 +RECOVERY/orcl/onlinelog/group_6.304.954903355

12 rows selected.

 

五、验证数据库及集群情况

1. 查看数据库的状态

[oracle@db1 ~]$ srvctl status database -d orcl

Instance orcl1 is running on node db1
Instance orcl2 is running on node db2

2. 查看数据的配置情况

[oracle@db1 ~]$ srvctl config database -d orcl

Database unique name: orcl
Database name: orcl
Oracle home: /u01/app/oracle/product/11.2.0/db_1
Oracle user: oracle
Spfile: +DATA/orcl/spfileorcl.ora
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: orcl
Database instances: orcl1,orcl2
Disk Groups: DATA,RECOVERY
Mount point paths: 
Services: 
Type: RAC
Database is administrator managed


3. 查看集群配置

[root@db1 ~]# su - grid
[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.CRS.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.LISTENER.lsnr
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.RECOVERY.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.asm
               ONLINE  ONLINE       db1                      Started             
               ONLINE  ONLINE       db2                      Started             
ora.gsd
               OFFLINE OFFLINE      db1                                          
               OFFLINE OFFLINE      db2                                          
ora.net1.network
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.ons
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.registry.acfs
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db1                                          
ora.cvu
      1        ONLINE  ONLINE       db2                                          
ora.db1.vip
      1        ONLINE  ONLINE       db1                                          
ora.db2.vip
      1        ONLINE  ONLINE       db2                                          
ora.oc4j
      1        ONLINE  ONLINE       db2                                          
ora.orcl.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.scan1.vip
      1        ONLINE  ONLINE       db1 





本文转自 koumm 51CTO博客,原文链接:http://blog.51cto.com/koumm/1966060,如需转载请自行联系原作者
上一篇:使用Apache Solr对数据库建立索引(包括处理CLOB、CLOB)


下一篇:Illustrator CS6选择工具的详细使用教程