Oracle 10g DataGuard学习(三)Creating a Physical Standby Database

在前三篇中我们解释了DG的基础知识及相关概念和原理,从这篇开始会从实战角度去演示物理逻辑备库的搭建、主备库切换、主备间库数据同步监控以及优化。本篇我们主要结合官方文档演示物理备库的创建过程。

在正式开始演示物理备库创建过程前,先描述一下测试环境:

Oracle VM VirtualBox + Oracle Linux 5.8
Host Name: 10g.localdomain
IP Address: 192.168.56.10
Oracle 10.2.0.5.12 DB + File System
Primary DB Name and Instance Nname: PROD
Standby DB Instance Nname: SBDB

注:以下演示过程由于是在笔记本虚拟机上进行测试,因此硬件虚拟资源有限,所以选择将主备库放在同一台虚拟主机上演示物理备库的搭建过程,但这并不影响演示过程及测试结果。

0.主备库准备工作

0.0 Create a primary DB with DB_NAME and SID PROD using DBCA
0.1 Enable PROD with archived mode using FRA
0.2 Add listeners and configure service name for the primary and standby databases
    netca --- Add Listener and Configure Service Name (PROD + SBDB)

1.主库操作过程及步骤

1.1 打开主库归档
SYS@PROD> ARCHIVE LOG LIST
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     7
Next log sequence to archive   9
Current log sequence           9
 
1.2 开启主库闪回
SYS@PROD> SELECT FLASHBACK_ON FROM V$DATABASE;
 
FLASHBACK_ON
------------------
YES
 
1.3 强制主库写日志
SYS@PROD> ALTER DATABASE FORCE LOGGING;
 
Database altered.
 
1.4 配置Standby Redo Log
Step 1 确认主库redo log大小使其备库上保持一致
Step 2 决定standby redo log数目,计算方法:(maximum number of logfiles for each thread + 1) * maximum number of threads
SYS@PROD> SELECT L.GROUP#,L.THREAD#,L.MEMBERS,F.MEMBER,BYTES/1024/1024,L.STATUS FROM V$LOG L,V$LOGFILE F WHERE L.GROUP#=F.GROUP#;
 
    GROUP#    THREAD#    MEMBERS MEMBER                                             BYTES/1024/1024 STATUS
---------- ---------- ---------- -------------------------------------------------- --------------- ----------------
         1          1          1 /u01/app/oracle/oradata/PROD/redo01.log                         50 CURRENT
         2          1          1 /u01/app/oracle/oradata/PROD/redo02.log                         50 INACTIVE
         3          1          1 /u01/app/oracle/oradata/PROD/redo03.log                         50 INACTIVE
 
SYS@PROD> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/u01/app/oracle/oradata/PROD/redo04.log') SIZE 50M;
 
Database altered.
 
SYS@PROD> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/u01/app/oracle/oradata/PROD/redo05.log') SIZE 50M;
 
Database altered.
 
SYS@PROD> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/u01/app/oracle/oradata/PROD/redo06.log') SIZE 50M;
 
Database altered.
 
SYS@PROD> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/u01/app/oracle/oradata/PROD/redo07.log') SIZE 50M;
 
Database altered.
 
1.5 查看已添加成功的Standby Redo Log
SYS@PROD> SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;
 
    GROUP#    THREAD#  SEQUENCE# ARC STATUS
---------- ---------- ---------- --- ----------
         4          0          0 YES UNASSIGNED
         5          0          0 YES UNASSIGNED
         6          0          0 YES UNASSIGNED
         7          0          0 YES UNASSIGNED
 
SYS@PROD> select * from v$logfile;
 
    GROUP# STATUS  TYPE    MEMBER                                             IS_
---------- ------- ------- -------------------------------------------------- ---
         1         ONLINE  /u01/app/oracle/oradata/PROD/redo01.log            NO
         2         ONLINE  /u01/app/oracle/oradata/PROD/redo02.log            NO
         3         ONLINE  /u01/app/oracle/oradata/PROD/redo03.log            NO
         4         STANDBY /u01/app/oracle/oradata/PROD/redo04.log            NO
         5         STANDBY /u01/app/oracle/oradata/PROD/redo05.log            NO
         6         STANDBY /u01/app/oracle/oradata/PROD/redo06.log            NO
         7         STANDBY /u01/app/oracle/oradata/PROD/redo07.log            NO
 
1.6 设置主库初始化参数
[oracle@10g dbs]$ cat initPROD.ora 
PROD.__db_cache_size=427819008
PROD.__java_pool_size=4194304
PROD.__large_pool_size=4194304
PROD.__shared_pool_size=155189248
PROD.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/PROD/adump'
*.background_dump_dest='/u01/app/oracle/admin/PROD/bdump'
*.compatible='10.2.0.5.0'
*.control_files='/u01/app/oracle/oradata/PROD/control01.ctl','/u01/app/oracle/oradata/PROD/control02.ctl','/u01/app/oracle/oradata/PROD/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/PROD/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='PROD'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=199229440
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=597688320
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/PROD/udump'
###### Add Primary DB Initialization Parameters ######
DB_UNIQUE_NAME=PROD
LOG_ARCHIVE_CONFIG='DG_CONFIG=(PROD,SBDB)'
LOG_ARCHIVE_DEST_1=
 'LOCATION=USE_DB_RECOVERY_FILE_DEST
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=PROD'
LOG_ARCHIVE_DEST_2=
 'SERVICE=SBDB LGWR ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 
  DB_UNIQUE_NAME=SBDB'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=8
FAL_SERVER=SBDB
FAL_CLIENT=PROD
DB_FILE_NAME_CONVERT='SBDB','PROD'
LOG_FILE_NAME_CONVERT='SBDB','PROD'
STANDBY_FILE_MANAGEMENT=AUTO
关于主库初始化参数需要说明的几点:
①主库初始化参数中应去掉相关的shared server参数;
②参数文件中自###### Add Standby DB Initialization Parameters ######到文末内容粘贴官档修改;
③LOG_ARCHIVE_DEST_n定义了主库归档日志位置、主备库redo传输方式;
④DB_FILE_NAME_CONVERT及LOG_FILE_NAME_CONVERT定义了主备库数据文件及日志文件转换规则;
⑤STANDBY_FILE_MANAGEMENT定义了备库文件的管理方式。
 
1.7使用新初始化参数文件启动主库到mount状态使用RMAN冷备主库
SYS@PROD> alter system checkpoint;
 
System altered.
 
SYS@PROD> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
 
SYS@PROD> create spfile from pfile;
 
File created.
 
SYS@PROD> startup mount;
ORACLE instance started.
 
Total System Global Area  599785472 bytes
Fixed Size                  2098112 bytes
Variable Size             163580992 bytes
Database Buffers          427819008 bytes
Redo Buffers                6287360 bytes
Database mounted.
 
[oracle@10g ~]$ rman target /
 
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Oct 24 11:17:12 2013
 
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
 
connected to target database: PROD (DBID=241479471, not open)
 
RMAN> backup as compressed backupset full database plus archivelog delete input;
 
Starting backup at 24-OCT-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK
specification does not match any archive log in the recovery catalog
backup cancelled because all files were skipped
Finished backup at 24-OCT-13
 
Starting backup at 24-OCT-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-OCT-13
channel ORA_DISK_1: finished piece 1 at 24-OCT-13
piece handle=/u01/app/oracle/flash_recovery_area/PROD/backupset/2013_10_24/o1_mf_nnndf_TAG20131024T111756_96k4c4j8_.bkp tag=TAG20131024T111756 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 24-OCT-13
channel ORA_DISK_1: finished piece 1 at 24-OCT-13
piece handle=/u01/app/oracle/flash_recovery_area/PROD/backupset/2013_10_24/o1_mf_ncsnf_TAG20131024T111756_96k4cnys_.bkp tag=TAG20131024T111756 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 24-OCT-13
 
Starting backup at 24-OCT-13
using channel ORA_DISK_1
specification does not match any archive log in the recovery catalog
backup cancelled because all files were skipped
Finished backup at 24-OCT-13
注:由于主库使用FRA并开启闪回功能,因此归档及备份文件都放在FRA。
 
1.8 创建备库控制文件
SYS@PROD> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/home/oracle/SBDB.ctl';
 
Database altered.
 
---到此主库配置完成。

2.物理备库创建过程及步骤

2.1在备库上创建与主库相同的目录结构
[oracle@10g ~]$ mkdir -p /u01/app/oracle/admin/SBDB/{a,b,c,u}dump
[oracle@10g ~]$ mkdir -p /u01/app/oracle/oradata/SBDB
[oracle@10g ~]$ mkdir -p /u01/app/oracle/flash_recovery_area/SBDB/archivelog
[oracle@10g ~]$ mkdir -p /u01/app/oracle/flash_recovery_area/SBDB/backupset
[oracle@10g ~]$ mkdir -p /u01/app/oracle/flash_recovery_area/SBDB/flashback
 
2.2拷贝主库密码文件到备库
[oracle@10g dbs]$ pwd
/u01/app/oracle/product/10.2.0/db_1/dbs
[oracle@10g dbs]$ cp orapwPROD orapwSBDB
 
2.3设置备库初始化参数文件
Step 1 拷贝主库初始化参数文件到备库
Step 2 修改参数文件如下
[oracle@10g dbs]$ cat initSDBD.ora 
SBDB.__db_cache_size=427819008
SBDB.__java_pool_size=4194304
SBDB.__large_pool_size=4194304
SBDB.__shared_pool_size=155189248
SBDB.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/SBDB/adump'
*.background_dump_dest='/u01/app/oracle/admin/SBDB/bdump'
*.compatible='10.2.0.5.0'
*.control_files='/u01/app/oracle/oradata/SBDB/control01.ctl','/u01/app/oracle/oradata/SBDB/control02.ctl','/u01/app/oracle/oradata/SBDB/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/SBDB/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='PROD'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=199229440
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=597688320
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/SBDB/udump'
###### Add Standby DB Initialization Parameters ######
DB_UNIQUE_NAME=SBDB
LOG_ARCHIVE_CONFIG='DG_CONFIG=(PROD,SBDB)'
DB_FILE_NAME_CONVERT='PROD','SBDB'
LOG_FILE_NAME_CONVERT='PROD','SBDB'
LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
LOG_ARCHIVE_DEST_1=
 'LOCATION=USE_DB_RECOVERY_FILE_DEST
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) 
  DB_UNIQUE_NAME=SBDB'
LOG_ARCHIVE_DEST_2=
 'SERVICE=PROD LGWR ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 
  DB_UNIQUE_NAME=PROD'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=PROD
FAL_CLIENT=SBDB
关于备库初始化参数需要说明的几点:
①将主库初始化参数文件拷贝改名后,使用vi打开将自###### Add Primary DB Initialization Parameters ######到文末删除,使用全局替换将除*.db_name='PROD'外所有PROD换成SBDB;
②参数文件中自###### Add Standby DB Initialization Parameters ######到文末内容粘贴官档修改;
③LOG_ARCHIVE_DEST_n定义了主库归档日志位置、主备库redo传输方式;
④DB_FILE_NAME_CONVERT及LOG_FILE_NAME_CONVERT定义了主备库数据文件及日志文件转换规则;
⑤STANDBY_FILE_MANAGEMENT定义了备库文件的管理方式。
 
2.4启动备库到nomount将主库RMAN全备恢复到备库上
SYS@SBDB> create spfile from pfile;
 
File created.
 
SYS@SBDB> startup nomount;
ORACLE instance started.
 
Total System Global Area  599785472 bytes
Fixed Size                  2098112 bytes
Variable Size             163580992 bytes
Database Buffers          427819008 bytes
Redo Buffers                6287360 bytes
 
[oracle@10g ~]$ export ORACLE_SID=SBDB
[oracle@10g ~]$ rman target /
 
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Oct 24 11:30:24 2013
 
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
 
connected to target database: PROD (not mounted)
 
RMAN> restore controlfile from '/home/oracle/SBDB.ctl';
 
Starting restore at 24-OCT-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
 
channel ORA_DISK_1: copied control file copy
output filename=/u01/app/oracle/oradata/SBDB/control01.ctl
output filename=/u01/app/oracle/oradata/SBDB/control02.ctl
output filename=/u01/app/oracle/oradata/SBDB/control03.ctl
Finished restore at 24-OCT-13
 
RMAN> run {
2> allocate channel c1 type disk;
3> set newname for datafile 1 to '/u01/app/oracle/oradata/SBDB/system01.dbf'; 
4> set newname for datafile 2 to '/u01/app/oracle/oradata/SBDB/undotbs01.dbf';
5> set newname for datafile 3 to '/u01/app/oracle/oradata/SBDB/sysaux01.dbf';
6> set newname for datafile 4 to '/u01/app/oracle/oradata/SBDB/users01.dbf';
7> set newname for tempfile 1 to '/u01/app/oracle/oradata/SBDB/temp01.dbf';
8> released channel c1;
9> }
 
allocated channel: c1
channel c1: sid=156 devtype=DISK
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
released channel: c1
 
RMAN> restore database;
 
Starting restore at 24-OCT-13
Starting implicit crosscheck backup at 24-OCT-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 11 objects
Finished implicit crosscheck backup at 24-OCT-13
 
Starting implicit crosscheck copy at 24-OCT-13
using channel ORA_DISK_1
Crosschecked 1 objects
Finished implicit crosscheck copy at 24-OCT-13
 
searching for all files in the recovery area
cataloging files...
no files cataloged
 
using channel ORA_DISK_1
 
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/SBDB/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/SBDB/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/SBDB/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/SBDB/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/PROD/backupset/2013_10_24/o1_mf_nnndf_TAG20131024T111756_96k4c4j8_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/PROD/backupset/2013_10_24/o1_mf_nnndf_TAG20131024T111756_96k4c4j8_.bkp tag=TAG20131024T111756
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 24-OCT-13
关于将主库RMAN全备恢复到备库上的几点说明:
①由于主库使用RMAN做冷全备份,因此在备库上使用RMAN恢复时只需要执行restore;
②由于主库数据文件等命名与备库不同,因此在备库上使用RMAN恢复时需要在RUN块中执行set newname for命令转换;
③如果不清楚RMAN异机恢复过程建议查阅官方文档。
 
2.5检查备库是否恢复完成
SYS@PROD> select * from v$log;
 
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1         13   52428800          1 YES INACTIVE                183935 24-OCT-13
         3          1         12   52428800          1 YES INACTIVE                183375 24-OCT-13
         2          1         14   52428800          1 NO  CURRENT                 183951 24-OCT-13
 
SYS@SBDB> select * from v$log;
 
    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
         1          1         13   52428800          1 YES INACTIVE                183935 24-OCT-13
         3          1         12   52428800          1 YES INACTIVE                183375 24-OCT-13
         2          1         14   52428800          1 NO  CURRENT                 183951 24-OCT-13
 
2.6检查此时主备库监听状态
[oracle@10g ~]$ lsnrctl status
 
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 24-OCT-2013 12:08:45
 
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10g.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                24-OCT-2013 10:39:05
Uptime                    0 days 1 hr. 29 min. 39 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10g.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PROD" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
Service "PROD_XPT" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
Service "SBDB" has 1 instance(s).
  Instance "SBDB", status READY, has 1 handler(s) for this service...
Service "SBDB_XPT" has 1 instance(s).
  Instance "SBDB", status READY, has 1 handler(s) for this service...
The command completed successfully
 
2.7启动备库应用redo
SYS@SBDB> select instance_name,status from v$instance;
 
INSTANCE_NAME    STATUS
---------------- ------------
SBDB             MOUNTED
 
SYS@SBDB> select name,open_mode from v$database;
 
NAME      OPEN_MODE
--------- ----------
PROD      MOUNTED
 
SYS@SBDB> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION PARALLEL 2;
 
Database altered.
 
---到此备库创建完成。

3.打开主库查看主备库日志同步及备库日志应用情况

3.1检查备库已归档日志情况
SYS@SBDB> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
 
 SEQUENCE# FIRST_TIM NEXT_TIME
---------- --------- ---------
        14 24-OCT-13 24-OCT-13
        15 24-OCT-13 24-OCT-13
        16 24-OCT-13 24-OCT-13
        17 24-OCT-13 24-OCT-13
        18 24-OCT-13 24-OCT-13
        19 24-OCT-13 24-OCT-13
        20 24-OCT-13 24-OCT-13
        21 24-OCT-13 24-OCT-13
        22 24-OCT-13 24-OCT-13
        23 24-OCT-13 24-OCT-13
        24 24-OCT-13 24-OCT-13
        25 24-OCT-13 24-OCT-13
        26 24-OCT-13 24-OCT-13
        27 24-OCT-13 24-OCT-13
        28 24-OCT-13 24-OCT-13
        29 24-OCT-13 24-OCT-13
        30 24-OCT-13 24-OCT-13
        31 24-OCT-13 24-OCT-13
        32 24-OCT-13 24-OCT-13
        33 24-OCT-13 24-OCT-13
        34 24-OCT-13 24-OCT-13
        35 24-OCT-13 24-OCT-13
        36 24-OCT-13 24-OCT-13
        37 24-OCT-13 24-OCT-13
        38 24-OCT-13 24-OCT-13
        39 24-OCT-13 24-OCT-13
        40 24-OCT-13 24-OCT-13
        41 24-OCT-13 24-OCT-13
        42 24-OCT-13 24-OCT-13
 
29 rows selected.
 
3.2主库手动切换日志(可以多切换几组)
SYS@PROD> alter database open;
 
Database altered.
 
3.3检查备库新日志归档情况
SYS@SBDB> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
 
 SEQUENCE# FIRST_TIM NEXT_TIME
---------- --------- ---------
        14 24-OCT-13 24-OCT-13
        15 24-OCT-13 24-OCT-13
        16 24-OCT-13 24-OCT-13
        17 24-OCT-13 24-OCT-13
        18 24-OCT-13 24-OCT-13
        19 24-OCT-13 24-OCT-13
        20 24-OCT-13 24-OCT-13
        21 24-OCT-13 24-OCT-13
        22 24-OCT-13 24-OCT-13
        23 24-OCT-13 24-OCT-13
        24 24-OCT-13 24-OCT-13
        25 24-OCT-13 24-OCT-13
        26 24-OCT-13 24-OCT-13
        27 24-OCT-13 24-OCT-13
        28 24-OCT-13 24-OCT-13
        29 24-OCT-13 24-OCT-13
        30 24-OCT-13 24-OCT-13
        31 24-OCT-13 24-OCT-13
        32 24-OCT-13 24-OCT-13
        33 24-OCT-13 24-OCT-13
        34 24-OCT-13 24-OCT-13
        35 24-OCT-13 24-OCT-13
        36 24-OCT-13 24-OCT-13
        37 24-OCT-13 24-OCT-13
        38 24-OCT-13 24-OCT-13
        39 24-OCT-13 24-OCT-13
        40 24-OCT-13 24-OCT-13
        41 24-OCT-13 24-OCT-13
        42 24-OCT-13 24-OCT-13
        43 24-OCT-13 24-OCT-13
 
30 rows selected.
 
3.4检查备库新日志应用情况
SYS@SBDB> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
 
 SEQUENCE# APP
---------- ---
        14 YES
        15 YES
        16 YES
        17 YES
        18 YES
        19 YES
        20 YES
        21 YES
        22 YES
        23 YES
        24 YES
        25 YES
        26 YES
        27 YES
        28 YES
        29 YES
        30 YES
        31 YES
        32 YES
        33 YES
        34 YES
        35 YES
        36 YES
        37 YES
        38 YES
        39 YES
        40 YES
        41 YES
        42 YES
        43 YES
 
30 rows selected.
 
3.5检查主备库当前状态
SYS@PROD> select DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
 
DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PRIMARY          TO STANDBY
 
SYS@SBDB> select DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
 
DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY TO PRIMARY
 
---到此主备数据库日志传输及备库日志应用均正常。

该篇结合官方文档演示了物理备库的创建过程,为了使该演示过程简介清晰,未将主备库日志同步及备库日志应用情况时的alert.log贴出,但在此不得不指出,主备库alert.log中相关信息的重要性,很多时候我们在配置主备库过程中难免会出现错误,此时就需要仔细查阅主备库alert.log日志中的相关信息才能定位错误发生的原因。对于该篇中的演示过程,虽然我们是在同一太主机上进行,但是这和我们在两天机器上演示该过程并没有本质的变化,唯一不同的操作是拷贝文件及恢复出备库都是在异机上操作而已。下一篇将会介绍物理主备库在两种情况下的角色转换,敬请期待!

Oracle 10g DataGuard学习(三)Creating a Physical Standby Database》上有2条评论

  1. 赵娟

    我说来看看你的个人站点到底更新什么,然后我发现我只能看懂标题,其余的一个也看不懂。好吧!我承认这就是技术男与文科女之间的差距,太高端了,我表示看不懂@-@。难怪你的邮件都是直接上英语的,原来是有基础的。我只有这一个感觉,技术男都是牛人。。。。。。。。

    回复
    1. oracledream 文章作者

      有句话叫”做隔行如隔山“,我这些在我们同行业里真的是小儿科,最基础的,所以不是像你说的那样哟!同样你的那些我也是看不懂啊!~

      回复

赵娟进行回复 取消回复

电子邮件地址不会被公开。

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>