亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle 11g單實例RMAN恢復到Oracle 11g RAC

發布時間:2020-06-08 19:43:40 來源:網絡 閱讀:2134 作者:koumm 欄目:關系型數據庫

一、環境說明

操作系統版本: 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 


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

项城市| 乐东| 延寿县| 离岛区| 上林县| 基隆市| 新密市| 栾川县| 灵川县| 白银市| 宁化县| 阿城市| 龙游县| 乌鲁木齐县| 前郭尔| 安平县| 那坡县| 宁明县| 孝昌县| 兰西县| 宁远县| 康马县| 卢龙县| 惠州市| 临朐县| 金寨县| 安岳县| 三江| 乌拉特前旗| 穆棱市| 育儿| 庄河市| 明光市| 建昌县| 定襄县| 宿州市| 萍乡市| 平舆县| 湖南省| 陆丰市| 砚山县|