你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle Data Guard_ 主库添加数据文件或创建表空间

[日期:2014-03-31] 来源:Linux社区  作者:rlhua [字体:大 中 小]
    1. 我的实验:主库添加新的表空间,备库中的STANDBY_FILE_MANAGEMENT参数设置为AUTO
    2. 主库:PROD
    3. 备库:PRODSTD

    1. 1.查看备库STANDBY_FILE_MANAGEMENT参数是否为AUTO
    2. SYS@PRODSTD>show parameter STANDBY_FILE_MANAGEMENT

    1. NAME TYPE VALUE
    2. ------------------------------------ ----------- ------------------------------
    3. standby_file_management string AUTO

    1. 2.在主库增加一个新的表空间
    2. SYS@PROD>create tablespace SWTICH_TBS datafile '/u01/app/Oracle/oradata/PROD/Disk1/swtich_tbs01.dbf' size 10m;

    1. Tablespace created.

    1. ---------------------------------------------------------------------------------------------------------------

    1. Sat Mar 29 16:27:18 2014
    2. create tablespace SWTICH_TBS datafile '/u01/app/oracle/oradata/PROD/Disk1/swtich_tbs01.dbf' size 10m
    3. Sat Mar 29 16:27:21 2014
    4. Completed: create tablespace SWTICH_TBS datafile '/u01/app/oracle/oradata/PROD/Disk1/swtich_tbs01.dbf' size 10m

    1. ---------------------------------------------------------------------------------------------------------------

    1. 3.手动归档,查看主备库告警日志
    2. SYS@PROD>alter system archive log current;

    1. System altered.
    2. ---------------------------------------------------------------------------------------------------------------
    3. 主库告警日志:
    4. LNS1 started with pid=55, OS id=3972
    5. Sat Mar 29 16:29:54 2014
    6. Thread 1 advanced to log sequence 32
    7. Current log# 5 seq# 32 mem# 0: /u01/app/oracle/oradata/PROD/Disk1/redo05.log
    8. Current log# 5 seq# 32 mem# 1: /u01/app/oracle/oradata/PROD/Disk2/redo05_1.log
    9. Sat Mar 29 16:29:56 2014
    10. LNS: Standby redo logfile selected for thread 1 sequence 32 for destination LOG_ARCHIVE_DEST_2
    11. Sat Mar 29 16:29:58 2014
    12. ARC7: Standby redo logfile selected for thread 1 sequence 31 for destination LOG_ARCHIVE_DEST_2

  •  

    1. 备库告警日志:
    2. Sat Mar 29 16:29:55 2014
    3. Redo Shipping Client Connected as PUBLIC
    4. -- Connected User is Valid
    5. RFS[2]: Assigned to RFS process 8613
    6. RFS[2]: Identified database type as 'physical standby'
    7. Primary database is in MAXIMUM PERFORMANCE mode
    8. Primary database is in MAXIMUM PERFORMANCE mode
    9. RFS[2]: Successfully opened standby log 7: '/u01/app/oracle/oradata/PRODSTD/Disk1/standby07.log'
    10. Sat Mar 29 16:29:57 2014
    11. Redo Shipping Client Connected as PUBLIC
    12. -- Connected User is Valid
    13. RFS[3]: Assigned to RFS process 8615
    14. RFS[3]: Identified database type as 'physical standby'
    15. RFS[3]: Successfully opened standby log 6: '/u01/app/oracle/oradata/PRODSTD/Disk1/standby06.log'
    16. ---------------------------------------------------------------------------------------------------------------
    17. 4,在主库验证是否有新的表空间和数据文件

  •  

    1. SYS@PROD>select name from v$datafile;

    1. NAME
    2. ---------------------------------------------------------------------------------------------------------------
    3. /u01/app/oracle/oradata/PROD/Disk1/system01.dbf
    4. /u01/app/oracle/oradata/PROD/Disk1/undotbs01.dbf
    5. /u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf
    6. /u01/app/oracle/oradata/PROD/Disk1/example01.dbf
    7. /u01/app/oracle/oradata/PROD/Disk1/swtich_tbs01.dbf
    8. /u01/app/oracle/oradata/PROD/Disk1/users01.dbf

    1. 6 rows selected.

  •  

    1. 5,在备库验证是否有新的表空间和数据文件

  •  

    1. SYS@PRODSTD>select name from v$datafile;

    1. NAME
    2. ----------------------------------------------------------------------------------------
    3. /u01/app/oracle/oradata/PRODSTD/Disk1/system01.dbf
    4. /u01/app/oracle/oradata/PRODSTD/Disk1/undotbs01.dbf
    5. /u01/app/oracle/oradata/PRODSTD/Disk1/sysaux01.dbf
    6. /u01/app/oracle/oradata/PRODSTD/Disk1/example01.dbf
    7. /u01/app/oracle/oradata/PRODSTD/Disk1/PRODSTD/datafile/o1_mf_swtich_t_9m21f1f0_.dbf
    8. /u01/app/oracle/oradata/PRODSTD/Disk1/users01.dbf

    1. 6 rows selected.

  1. 8.3.1.2When STANDBY_FILE_MANAGEMENT Is Set to MANUAL

8.3.1.2 当STANDBY_FILE_MANAGEMENT设置为MANUAL时

This section shows how to add a new datafile to the primary and standby database when theSTANDBY_FILE_MANAGEMENTinitialization parameter is set toMANUAL. You must set theSTANDBY_FILE_MANAGEMENTinitialization parameter toMANUALwhen the standby datafiles reside on raw devices. This section also describes how to recover from errors after they have occurred.

这个部分展示的是添加一个新的数据文件到主库,而备库的STANDBY_FILE_MANAGEMENT参数设置为MAUNAL,当备库的数据文件放在裸设备时,你必须将STANDBY_FILE_MANAGEMENT初始化参数设置为MANUAL。这部分也描述怎么恢复遇到的错误。

Note:

Do not use the following procedure with databases that use Oracle Managed Files. Also, if the raw device path names are not the same on the primary and standby servers, use theDB_FILE_NAME_CONVERTinitialization parameter to convert the path names.
数据库在OMF管理时不要使用以下的步骤,同样,如果裸设备路径不跟主库和备库的一样,使用DB_FILE_NAME_CONVERT初始化参数来转换路径的名称。

8.3.1.2.1Using the STANDBY_FILE_MANAGEMENT Parameter with Raw Devices

By setting theSTANDBY_FILE_MANAGEMENTparameter toAUTOwhenever new datafiles are added or dropped on the primary database, corresponding changes are made in the standby database without manual intervention. This is true as long as the standby database is using a file system. If the standby database is using raw devices for datafiles, then the STANDBY_FILE_MANAGEMENT initialization parameter will continue to work, but manual intervention is needed. This manual intervention involves ensuring the raw devices exist before log apply services on the standby database recover the redo data that will create the new datafile.On the primary database, create a new tablespace where the datafiles reside in a raw device. At the same time, create the same raw device on the standby database. For example:

STANDBY_FILE_MANAGEMENT设置为AUTO,无论什么时候在主库上添加或删掉新的数据文件,备库不用人工干预相应的改变即可发生在备库。这是针对于备库为文件系统才行的。如果备库使用裸设备来放数据文件,那么STANDBY_FILE_MANAGEMENT参数将继续工作,但是手动干预是必须的。这个手动干预包括确定裸设备是否存在在备库上日志应用服务恢复创建新的数据文件的重做日志。在主库上,在裸设备上创建一个新的表空间,同时,在备库创建相同的裸设备,例如:

SQL> CREATE TABLESPACE MTS2 DATAFILE '/dev/raw/raw100' size 1m;
Tablespace created.
 
SQL> ALTER SYSTEM SWITCH LOGFILE;
System altered.

The standby database automatically adds the datafile as the raw devices exist. The standby alert log shows the following:

备库自动添加数据文件到以存在的裸设备,备用告警之日如下:

Fri Apr 8 09:49:31 2005
Media Recovery Log /u01/MILLER/flash_recovery_area/MTS_STBY/archivelog/2005_04_08/o1_mf_1_7_15ffgt0z_.arc
Recovery created file /dev/raw/raw100
Successfully added datafile 6 to media recovery
Datafile #6: '/dev/raw/raw100'
Media Recovery Waiting for thread 1 sequence 8 (in transit)

However, if the raw device was created on the primary system but not on the standby, then the MRP process will shut down due to file-creation errors. For example, issue the following statements on the primary database:

然而,如果在主库上创建了裸设备而没有在备库上创建裸设备,那么MRP进程会因为文件创建错误而关闭,例如,在主库上发出以下语句:

SQL> CREATE TABLESPACE MTS3 DATAFILE '/dev/raw/raw101' size 1m;
Tablespace created.
 
SQL> ALTER SYSTEM SWITCH LOGFILE;
System altered.

The standby system does not have the/Dave/raw/raw101raw device created. The standby alert log shows the following messages when recovering the archive:

备用系统没有创建/dev/raw/raw101这个裸设备,备用告警日志如下:

Fri Apr 8 10:00:22 2005
Media Recovery Log /u01/MILLER/flash_recovery_area/MTS_STBY/archivelog/2005_04_08/o1_mf_1_8_15ffjrov_.arc
File #7 added to control file as 'UNNAMED00007'.
Originally created as:
'/dev/raw/raw101'
Recovery was unable to create the file as:
'/dev/raw/raw101'
MRP0: Background Media Recovery terminated with error 1274
Fri Apr 8 10:00:22 2005
Errors in file /u01/MILLER/MTS/dump/mts_mrp0_21851.trc:
ORA-01274: cannot add datafile '/dev/raw/raw101' - file could not be created
ORA-01119: error in creating database file '/dev/raw/raw101'
ORA-27041: unable to open file
Linux Error: 13: Permission denied
Additional information: 1
Some recovered datafiles maybe left media fuzzy
Media recovery may continue but open resetlogs may fail
Fri Apr 8 10:00:22 2005
Errors in file /u01/MILLER/MTS/dump/mts_mrp0_21851.trc:
ORA-01274: cannot add datafile '/dev/raw/raw101' - file could not be created
ORA-01119: error in creating database file '/dev/raw/raw101'
ORA-27041: unable to open file
Linux Error: 13: Permission denied
Additional information: 1
Fri Apr 8 10:00:22 2005
MTS; MRP0: Background Media Recovery process shutdown
ARCH: Connecting to console port...

8.3.1.2.2Recovering From Errors
8.3.1.2.2 恢复以上错误

To correct the problems described inSection 8.3.1.2.1, perform the following steps:

修改上节提到的错误,执行以下步骤:

  1. Create the raw device on the standby database and assign permissions to the Oracle user.

    在备库上创建裸设备,赋予oracle用户权限

     

  2. Query theV$DATAFILEview. For example:

    SQL> SELECT NAME FROM V$DATAFILE;
     
    NAME
    --------------------------------------------------------------------------------
    /u01/MILLER/MTS/system01.dbf
    /u01/MILLER/MTS/undotbs01.dbf
    /u01/MILLER/MTS/sysaux01.dbf
    /u01/MILLER/MTS/users01.dbf
    /u01/MILLER/MTS/mts.dbf
    /dev/raw/raw100
    /u01/app/oracle/product/10.1.0/dbs/UNNAMED00007
     
    SQL>ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=MANUAL;
     
    SQL>ALTER DATABASE CREATE DATAFILE
    2 '/u01/app/oracle/product/10.1.0/dbs/UNNAMED00007'
    3 AS
    4 '/dev/raw/raw101';
     
  3. In the standby alert log you should see information similar to the following:

    在备用告警日志里你应该会看见以下相似的信息:

    Fri Apr 8 10:09:30 2005
    alter database create datafile
    '/dev/raw/raw101' as '/dev/raw/raw101'
    Fri Apr 8 10:09:30 2005
    Completed: alter database create datafile
    '/dev/raw/raw101' a
     
  4. On the standby database, setSTANDBY_FILE_MANAGEMENTtoAUTOand restart Redo Apply:

    在备库,设置STANDBY_FILE_MANAGEMENT 为AUTO,然后重新启用重做应用:

    SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
    SQL> RECOVER MANAGED STANDBY DATABASE DISCONNECT;
     

At this point Redo Apply uses the new raw device datafile and recovery continues.

在这一点,重做应用使用新的裸设备上的数据文件并继续恢复。

相关参考:

Oracle Data Guard 重要配置参数 http://www.linuxidc.com/Linux/2013-08/88784.htm

基于同一主机配置 Oracle 11g Data Guard http://www.linuxidc.com/Linux/2013-08/88848.htm

探索Oracle之11g DataGuard http://www.linuxidc.com/Linux/2013-08/88692.htm

Oracle Data Guard (RAC+DG) 归档删除策略及脚本 http://www.linuxidc.com/Linux/2013-07/87782.htm

Oracle Data Guard 的角色转换 http://www.linuxidc.com/Linux/2013-06/86190.htm

Oracle Data Guard的日志FAL gap问题 http://www.linuxidc.com/Linux/2013-04/82561.htm

Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法 http://www.linuxidc.com/Linux/2013-03/82009.htm

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款