首页 > 代码库 > Oracle 11g Active Dataguard (RAC)的配置

Oracle 11g Active Dataguard (RAC)的配置

一:环境介绍
主库(RAC)
IP地址:192.168.1.210,192.168.1.211
操作系统版本:ole5.8 64bit
数据库版本:11.2.0.4 64bit
数据库sid名:MECBS1,MECBS2
数据库主机名:node1,node2
数据库db_unique_name:MECBS

备库1  物理备库 (只安装oracle数据库软件,无需建库)
IP地址:192.168.1.219
操作系统版本:ole5.8 64bit
数据库版本:11.2.0.4 64bit
数据库sid名:PHUB
数据库主机名:dataguard
数据库db_unique_name:PHUB

主库和备库均采用ASM管理

二.通过网络DUPLICAT 复制备库:

  1.配置备库监听:

       LISTENER =
 
     (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=dataguard)(PORT=1521))
       (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))

      SID_LIST_LISTENER=
   
    (SID_LIST=
       (SID_DESC=
       (GLOBAL_DBNAME=PHUB)
       (ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
       (SID_NAME=PHUB)
         )
        )

   2.TNS配置(主库各节点和备库):

MECBS1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.210)(PORT = 1521))
    (CONNECT_DATA =http://www.mamicode.com/
      (SERVER = DEDICATED)
        (SERVICE_NAME = MECBS)
      (SERVICE_NAME = MECBS1)
    )
  )
MECBS2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521))
    (CONNECT_DATA =http://www.mamicode.com/
      (SERVER = DEDICATED)
        (SERVICE_NAME = MECBS)
     (SERVICE_NAME = MECBS2)
    )
  )
  PHUB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.219)(PORT = 1521))
    (CONNECT_DATA =http://www.mamicode.com/
      (SERVER = DEDICATED)
      (SERVICE_NAME = PHUB)
    )
  )
配置
完成后用tnsping验证

   3.检查主库归档情况:

SQL> archive log list;
Database log mode       Archive Mode
Automatic archival       Enabled
Archive destination       +RECO
Oldest online log sequence     7
Next log sequence to archive   8
Current log sequence       8

    4.为了能主备切换,配置主数据库的Standby Redo日志,执行下面SQL语句查询主库联机REDO日志:

SQL> select thread#,bytes/1024/1024 "SIZE(MB)",MEMBERS FROM V$LOG;
   THREAD#   SIZE(MB) MEMBERS
---------- ---------- ----------
1   50      1
1   50      1
2   50      1
2   50      1

当前RAC环境包含2个节点,每个节点有两个日志组,每个日志组大小为50M,每个日志组有两个成员,根据这个情况,为每个节点添加3个大小为50M,每个日志组包含2个成员,分别位于DATA和RECO磁盘组:

SQL> alter database add standby logfile thread 1(‘+DATA‘,‘+RECO‘) size 50M;
Database altered.
SQL> alter database add standby logfile thread 1(‘+DATA‘,‘+RECO‘) size 50M;
Database altered.
SQL> alter database add standby logfile thread 1(‘+DATA‘,‘+RECO‘) size 50M;
Database altered.
SQL> alter database add standby logfile thread 2(‘+DATA‘,‘+RECO‘) size 50M;
Database altered.
SQL> alter database add standby logfile thread 2(‘+DATA‘,‘+RECO‘) size 50M;
Database altered.
SQL> alter database add standby logfile thread 2(‘+DATA‘,‘+RECO‘) size 50M;
Database altered.

``5.修改主库参数文件:

SQL> create pfile=‘/home/oracle/pfile.ora1‘ from spfile;
File created.

[oracle@node2 ~]$ cat pfile.ora1
MECBS2.__db_cache_size=251658240
MECBS1.__db_cache_size=234881024
MECBS1.__java_pool_size=4194304
MECBS2.__java_pool_size=4194304
MECBS1.__large_pool_size=16777216
MECBS2.__large_pool_size=16777216
MECBS2.__oracle_base=‘/u01/app/oracle‘#ORACLE_BASE set from environment
MECBS1.__pga_aggregate_target=163577856
MECBS2.__pga_aggregate_target=163577856
MECBS1.__sga_target=486539264
MECBS2.__sga_target=486539264
MECBS1.__shared_io_pool_size=0
MECBS2.__shared_io_pool_size=0
MECBS2.__shared_pool_size=201326592
MECBS1.__shared_pool_size=218103808
MECBS1.__streams_pool_size=0
MECBS2.__streams_pool_size=0
*.audit_file_dest=‘/u01/app/oracle/admin/MECBS/adump‘
*.audit_trail=‘db‘
*.cluster_database=true
*.compatible=‘11.2.0.4.0‘
*.control_files=‘+DATA/mecbs/controlfile/current.260.862339599‘
*.db_block_size=8192
*.db_create_file_dest=‘+DATA‘
*.db_domain=‘‘
*.db_name=‘MECBS‘
*.diagnostic_dest=‘/u01/app/oracle‘
*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=MECBSXDB)‘
MECBS1.instance_number=1
MECBS2.instance_number=2
*.log_archive_format=‘%t_%s_%r.dbf‘
*.open_cursors=300
*.pga_aggregate_target=161480704
*.processes=150
*.remote_listener=‘scan.cowell.com:1521‘
*.remote_login_passwordfile=‘exclusive‘
*.sga_target=486539264
MECBS2.thread=2
MECBS1.thread=1
MECBS2.undo_tablespace=‘UNDOTBS2‘
MECBS1.undo_tablespace=‘UNDOTBS1‘
*.DB_UNIQUE_NAME=MECBS
*.LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(PHUB,MECBS)‘
*.LOG_ARCHIVE_DEST_2=‘SERVICE=PHUB LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PHUB‘
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable
*.standby_file_management=auto
*.log_archive_dest_1=‘location=+RECO valid_for=(all_logfiles,all_roles) db_unique_name=MECBS‘

SQL> create spfile from pfile=‘/home/oracle/pfile.ora1‘;
File created.

修改过的pfile文件启动另外的节点:

SQL> startup pfile=‘/home/oracle/pfile.ora1‘;
ORACLE instance started.
Total System Global Area  484356096 bytes
Fixed Size    2254464 bytes
Variable Size  264243584 bytes
Database Buffers  209715200 bytes
Redo Buffers    8142848 bytes
Database mounted.
Database opened.

创建主库的spfile文件:

SQL> create spfile=‘+DATA/MECBS/spfileMECBS.ora‘ from pfile=‘/home/oracle/pfile.ora1‘;
File created.

   6.完全备份主库:

[oracle@node2 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Nov 2 14:11:47 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: MECBS (DBID=1527329870)
RMAN> run
{
allocate channel C1 device type disk;
allocate channel C2 device type disk;
sql ‘alter system switch logfile‘;
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog until time ‘sysdate-30‘;
crosscheck backup;
delete noprompt obsolete;
delete noprompt expired backup;
backup incremental level=0 as compressed backupset database include current
controlfile format ‘+BACK/backup/level0/data_%U.bak‘;
release channel C1;
release channel C2;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 
using target database control file instead of recovery catalog
allocated channel: C1
channel C1: SID=16 instance=MECBS2 device type=DISK

allocated channel: C2
channel C2: SID=84 instance=MECBS2 device type=DISK
sql statement: alter system switch logfile
validation succeeded for archived log
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_30/thread_1_seq_7.260.862352857 RECID=5 STAMP=862352863
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_31/thread_1_seq_8.268.862418333 RECID=7 STAMP=862418364
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_31/thread_1_seq_9.267.862418331 RECID=6 STAMP=862418346
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_1_seq_10.273.862565675 RECID=12 STAMP=862565728
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_1_seq_11.275.862569951 RECID=14 STAMP=862569986
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_1_seq_12.276.862576389 RECID=15 STAMP=862576397
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_1_seq_13.278.862577579 RECID=17 STAMP=862577581
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_1_seq_14.279.862578801 RECID=18 STAMP=862578803
validation succeeded for archived log
archived log file name=+RECO/mecbs/1_15_862339605.dbf RECID=21 STAMP=862580541
validation succeeded for archived log
archived log file name=+RECO/mecbs/1_16_862339605.dbf RECID=25 STAMP=862580557
validation succeeded for archived log
archived log file name=+RECO/mecbs/1_17_862339605.dbf RECID=27 STAMP=862580561
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_1_seq_18.289.862581999 RECID=38 STAMP=862582000
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_1_seq_19.290.862582059 RECID=40 STAMP=862582066
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_1_seq_20.292.862582373 RECID=44 STAMP=862582372
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_30/thread_2_seq_1.256.862341997 RECID=1 STAMP=862341998
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_30/thread_2_seq_2.258.862352379 RECID=2 STAMP=862352387
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_30/thread_2_seq_3.259.862352391 RECID=3 STAMP=862352391
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_31/thread_2_seq_4.269.862418365 RECID=8 STAMP=862418373
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_31/thread_2_seq_5.270.862418375 RECID=9 STAMP=862418375
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_10_31/thread_2_seq_6.271.862418409 RECID=10 STAMP=862418414
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_2_seq_7.272.862565649 RECID=11 STAMP=862565724
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_2_seq_8.274.862565733 RECID=13 STAMP=862565745
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_2_seq_9.277.862576395 RECID=16 STAMP=862576399
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_2_seq_10.280.862578805 RECID=19 STAMP=862578811
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_2_seq_11.281.862579957 RECID=20 STAMP=862579960
validation succeeded for archived log
archived log file name=+RECO/mecbs/2_12_862339605.dbf RECID=23 STAMP=862580548
validation succeeded for archived log
archived log file name=+RECO/mecbs/2_13_862339605.dbf RECID=24 STAMP=862580557
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_2_seq_14.287.862581161 RECID=34 STAMP=862581162
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_2_seq_15.288.862581165 RECID=35 STAMP=862581165
validation succeeded for archived log
archived log file name=+RECO/mecbs/archivelog/2014_11_02/thread_2_seq_16.291.862582065 RECID=41 STAMP=862582070
Crosschecked 31 objects
specification does not match any archived log in the repository
specification does not match any archived log in the repository
crosschecked backup piece: found to be ‘AVAILABLE‘
backup piece handle=+BACK/backup/level0/data_1npmjou3_1_1.bak RECID=1 STAMP=862577604
crosschecked backup piece: found to be ‘AVAILABLE‘
backup piece handle=+BACK/backup/level0/data_1opmjp41_1_1.bak RECID=2 STAMP=862577844
crosschecked backup piece: found to be ‘AVAILABLE‘
backup piece handle=+BACK/backup/level0/data_1mpmjou2_1_1.bak RECID=3 STAMP=862577604
Crosschecked 3 objects
crosschecked backup piece: found to be ‘EXPIRED‘
backup piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/c-1527329870-20141102-00 RECID=4 STAMP=862577872
Crosschecked 1 objects
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Starting backup at 02-NOV-14
channel C1: starting compressed incremental level 0 datafile backup set
channel C1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/mecbs/datafile/system.256.862339387
input datafile file number=00004 name=+DATA/mecbs/datafile/users.259.862339391
input datafile file number=00005 name=+DATA/mecbs/datafile/example.264.862339751
channel C1: starting piece 1 at 02-NOV-14
channel C2: starting compressed incremental level 0 datafile backup set
channel C2: specifying datafile(s) in backup set
input datafile file number=00002 name=+DATA/mecbs/datafile/sysaux.257.862339391
input datafile file number=00003 name=+DATA/mecbs/datafile/undotbs1.258.862339391
input datafile file number=00006 name=+DATA/mecbs/datafile/undotbs2.265.862341013
channel C2: starting piece 1 at 02-NOV-14

piece handle=+BACK/backup/level0/data_22pmjtm9_1_1.bak tag=TAG20141102T141430 comment=NONE
channel C2: backup set complete, elapsed time: 00:04:21
channel C2: starting compressed incremental level 0 datafile backup set
channel C2: specifying datafile(s) in backup set
including current control file in backup set
channel C2: starting piece 1 at 02-NOV-14
channel C1: finished piece 1 at 02-NOV-14
piece handle=+BACK/backup/level0/data_21pmjtm8_1_1.bak tag=TAG20141102T141430 comment=NONE
channel C1: backup set complete, elapsed time: 00:05:16
channel C2: finished piece 1 at 02-NOV-14
piece handle=+BACK/backup/level0/data_23pmjtup_1_1.bak tag=TAG20141102T141430 comment=NONE
channel C2: backup set complete, elapsed time: 00:00:16
Finished backup at 02-NOV-14
Starting Control File Autobackup at 02-NOV-14
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/c-1527329870-20141102-01 comment=NONE
Finished Control File Autobackup at 02-NOV-14
released channel: C1
released channel: C2

  7.根据主库的参数文件修改然后初始化备库,修改过的备库参数文件文件如下:

PHUB.__db_cache_size=255852544
PHUB.__java_pool_size=4194304
PHUB.__large_pool_size=16777216
PHUB.__oracle_base=‘/u01/app/oracle‘
PHUB.__pga_aggregate_target=163577856
PHUB.__sga_target=486539264
HUB.__shared_io_pool_size=0
PHUB.__shared_pool_size=197132288
PHUB.__streams_pool_size=0
*.audit_file_dest=‘/u01/app/oracle/admin/PHUB/adump‘
*.audit_trail=‘db‘
*.cluster_database=false
PHUB.__shared_pool_size=197132288
PHUB.__streams_pool_size=0
*.audit_file_dest=‘/u01/app/oracle/admin/PHUB/adump‘
*.audit_trail=‘db‘
*.cluster_database=false
*.compatible=‘11.2.0.4.0‘
*.control_files=‘+DATA/PHUB/controlfile/controlfile.ctl01‘
*.db_block_size=8192
*.db_create_file_dest=‘+DATA‘
*.db_file_name_convert=‘+DATA/mecbs‘,‘+DATA/phub‘
*.log_file_name_convert=‘+DATA/mecbs‘,‘+DATA/phub‘
*.db_domain=‘‘
*.db_name=‘MECBS‘ ---不用修改
*.log_archive_config=‘dg_config=(MECBS,PHUB)‘
*.log_archive_dest_1=‘location=+RECO valid_for=(all_logfiles,all_roles) db_unique_name=PHUB‘
*.log_archive_dest_2=‘service=MECBS lgwr sync affirm valid_for=(online_logfiles,primary_role) db_unique_name=MECBS‘
*.log_archive_dest_state_1=enable
*.log_archive_dest_state_2=enable

*.diagnostic_dest=‘/u01/app/oracle‘
*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=PHUBXDB)‘
*.log_archive_format=‘%t_%s_%r.dbf‘
*.open_cursors=300
*.pga_aggregate_target=161480704
*.processes=150
*.remote_login_passwordfile=‘exclusive‘
*.sga_target=486539264
*.undo_tablespace=‘UNDOTBS1‘
*.standby_file_management=auto
*.db_unique_name=‘PHUB‘

拷贝密码文件和参数文件到备库并重命名:

[oracle@node1 dbs]$ scp orapwMECBS1 192.168.1.219:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwPHUB
oracle@192.168.1.219‘s password: 
orapwMECBS1                                                                                  100% 1536     1.5KB/s   00:00     [oracle@node1 ~]$ scp pfile.ora 192.168.1.219:/u01/app/oracle/product/11.2.0/db_1/dbs/initPHUB.ora
oracle@192.168.1.219‘s password: 
pfile.ora                                                                                     100% 1175     1.2KB/s   00:00    8.启动备库到nomount状态,并在主库上执行复制:

[oracle@dataguard ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 31 13:24:53 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area  484356096 bytes
Fixed Size    2254464 bytes
Variable Size  201329024 bytes
Database Buffers  272629760 bytes
Redo Buffers    8142848 bytes

主库上执行复制:

[oracle@node1 ~]$rman target / auxiliary sys/123123@192.168.1.219/PHUB
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Nov 2 14:39:53 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: MECBS (DBID=1527329870)
connected to auxiliary database: MECBS (not mounted)

RMAN> duplicate target database for standby from active database nofilenamecheck;
Starting Duplicate Db at 02-NOV-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=131 device type=DISK
contents of Memory Script:
{
   backup as copy reuse
    targetfile  ‘/u01/app/oracle/product/11.2.0/db_1/dbs/orapwMECBS1‘ auxiliary format 
 ‘/u01/app/oracle/product/11.2.0/db_1/dbs/orapwPHUB‘   ;
}
executing Memory Script
Starting backup at 02-NOV-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=197 instance=MECBS1 device type=DISK
Finished backup at 02-NOV-14
contents of Memory Script:
{
    backup as copy current controlfile for standby auxiliary format  ‘+DATA/phub/controlfile/controlfile.ctl01‘;
}
executing Memory Script
Starting backup at 02-NOV-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_MECBS1.f tag=TAG20141102T144152 RECID=28 STAMP=862584123
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:27
Finished backup at 02-NOV-14
contents of Memory Script:
{
   sql clone ‘alter database mount standby database‘;
}
executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script:
{
   set newname for clone tempfile  1 to new;
    switch clone tempfile all;
    set newname for clone datafile  1 to new;
    set newname for clone datafile  2 to new;
    set newname for clone datafile  3 to new;
    set newname for clone datafile  4 to new;
    set newname for clone datafile  5 to new;
    set newname for clone datafile  6 to new;
    backup as copy reuse
    datafile  1 auxiliary format new
    datafile  2 auxiliary format new
    datafile  3 auxiliary format new
    datafile  4 auxiliary format new
    datafile  5 auxiliary format new
    datafile  6 auxiliary format new
    ;
    sql ‘alter system archive log current‘;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to +DATA in control file
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 backup at 02-NOV-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/mecbs/datafile/system.256.862339387
output file name=+DATA/phub/datafile/system.264.862586307 tag=TAG20141102T144257
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:58
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/mecbs/datafile/sysaux.257.862339391
output file name=+DATA/phub/datafile/sysaux.262.862586481 tag=TAG20141102T144257
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:46
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATA/mecbs/datafile/example.264.862339751
output file name=+DATA/phub/datafile/example.261.862586587 tag=TAG20141102T144257
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:26
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATA/mecbs/datafile/undotbs1.258.862339391
output file name=+DATA/phub/datafile/undotbs1.259.862586673 tag=TAG20141102T144257
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=+DATA/mecbs/datafile/undotbs2.265.862341013
output file name=+DATA/phub/datafile/undotbs2.258.862586711 tag=TAG20141102T144257
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/mecbs/datafile/users.259.862339391
output file name=+DATA/phub/datafile/users.256.862586719 tag=TAG20141102T144257
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 02-NOV-14
sql statement: alter system archive log current
contents of Memory Script:
{
    switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=28 STAMP=862586750 file name=+DATA/phub/datafile/system.264.862586307
datafile 2 switched to datafile copy
input datafile copy RECID=29 STAMP=862586750 file name=+DATA/phub/datafile/sysaux.262.862586481
datafile 3 switched to datafile copy
input datafile copy RECID=30 STAMP=862586750 file name=+DATA/phub/datafile/undotbs1.259.862586673
datafile 4 switched to datafile copy
input datafile copy RECID=31 STAMP=862586750 file name=+DATA/phub/datafile/users.256.862586719
datafile 5 switched to datafile copy
input datafile copy RECID=32 STAMP=862586750 file name=+DATA/phub/datafile/example.261.862586587
datafile 6 switched to datafile copy
input datafile copy RECID=33 STAMP=862586751 file name=+DATA/phub/datafile/undotbs2.258.862586711
Finished Duplicate Db at 02-NOV-14

  9.启动Redo Apply

(1)查看实例状态:

SQL> select status from v$instance;
STATUS
------------
MOUNTED

(2)打开数据库(11g可以以只读的方式打开):

SQL> alter database open;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY

(3)启动redo apply

SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.

  10.注册standby为restart数据库:

    (1)查看监听注册情况:

[oracle@dataguard ~]$ srvctl status listener -l listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): dataguard

如果没有注册,用以下命令注册:

srvctl add listener -l listener -o /u01/app/11.2.0/grid/(grid用户家目录) -s

   (2) 将database注册为clusterware资源:

[oracle@dataguard ~]$ srvctl add database -d PHUB -o /u01/app/oracle/product/11.2.0/db_1/

[oracle@dataguard ~]$ srvctl start database -d PHUB
[oracle@dataguard ~]$ srvctl status database -d PHUB
Database is running.

    (3)查看clusterware资源状态:

[grid@dataguard ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.CRS.dg
               ONLINE  ONLINE       dataguard                                    
ora.DATA.dg
               ONLINE  ONLINE       dataguard                                    
ora.LISTENER.lsnr
               ONLINE  ONLINE       dataguard                                    
ora.RECO.dg
               ONLINE  ONLINE       dataguard                                    
ora.asm
               ONLINE  ONLINE       dataguard                Started             
ora.ons
               ONLINE  ONLINE       dataguard                                    
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       dataguard                                    
ora.diskmon
      1        OFFLINE OFFLINE                                                   
ora.evmd
      1        ONLINE  ONLINE       dataguard                                    
ora.phub.db
      1        ONLINE  ONLINE       dataguard                Open   

11.正常开启和关闭DATAGUARD流程:

       (1)正常关闭:执行以下sql停止standby数据库redo日志应用:

alter database recover managed standby database cancel

关闭主数据库======》关闭standby数据库

(2)启动standby数据库====================》启动主数据库========》启动standby数据库redo日志应用。

  12.监控日志传输服务:

(1)检查实例名对应的线程号:

SQL> select thread#,instance_name from gv$instance;
   THREAD# INSTANCE_NAME
---------- ----------------
2 MECBS2
1 MECBS1

(2)检查每个实例所有目的地生成日志的最大序列号:

SQL> select thread#,dest_id,max(sequence#) from v$archived_log group by thread#,dest_id order by thread#;
    THREAD#    DEST_ID MAX(SEQUENCE#)
---------- ---------- --------------
1    1  22
1    2  22
2    1  19
2    2  19

上面结果表示所有实例的日志都成功归档到所有目的地:

手动切换RAC所有节点日志:

SQL> alter system archive log current;
System altered.
SQL> /
System altered.

SQL> select thread#,dest_id,max(sequence#) from v$archived_log group by thread#,dest_id order by thread#;
    THREAD#    DEST_ID MAX(SEQUENCE#)
---------- ---------- --------------
1    1  26
1    2  26
2    1  23
2    2  23


上面结果表示所有实例的日志都成功归档到所有目的地:

  13.查看standby数据库使用情况:

SQL> select thread#,sequence#,archived,status from v$standby_log;
   THREAD#  SEQUENCE# ARC STATUS
---------- ---------- --- ----------
1   27 YES ACTIVE
1    0 NO  UNASSIGNED
1    0 YES UNASSIGNED
2   24 YES ACTIVE
2    0 NO  UNASSIGNED
2    0 YES UNASSIGNED
6 rows selected.

在主库上查询日志序列号:

SQL> select thread#,sequence#,status from v$log;
    THREAD#  SEQUENCE# STATUS
---------- ---------- ----------------
1   27 CURRENT
1   26 INACTIVE
2   23 INACTIVE
2   24 CURRENT

证明传输服务启动了实时传输。


本文出自 “热爱生活” 博客,请务必保留此出处http://7642644.blog.51cto.com/7632644/1576675

Oracle 11g Active Dataguard (RAC)的配置