ITPub博客

首页 > Linux操作系统 > Linux操作系统 > STANDBY_FILE_MANAGEMENT

STANDBY_FILE_MANAGEMENT

原创 Linux操作系统 作者:lsq_008 时间:2009-07-30 21:11:26 0 删除 编辑

standby_file_management如果设置为auto,则primary端创建表空间或添加数据文件时,standby端将自动添加,反之如果设置为manual,则必须要重建standby端的控制文件

SQL> create tablespace test datafile '/oracle/oradata/ebank/test01.dbf' size 10m;

Tablespace created.

SQL> show parameter standby

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_archive_dest                 string      /tools/archivelog
standby_file_management              string      AUTO
SQL>  select a.name ts_name,b.name file_name,bytes/1024/1024 from v$tablespace a,v$datafile b where a.ts#=b.ts#;

TS_NAME                        FILE_NAME                                BYTES/1024/1024
------------------------------ ---------------------------------------- ---------------
SYSTEM                         /oracle/oradata/ebank/system01.dbf                   300
UNDOTBS                        /oracle/oradata/ebank/undotbs01.dbf              299.375
SYSAUX                         /oracle/oradata/ebank/sysaux01.dbf                   250
USERS                          /oracle/oradata/ebank/users01.dbf                    300
TEST                           /oracle/oradata/ebank/test01.dbf                      10

SQL> alter system switch logfile;

System altered.

在standby段的alert日志里可以看到:

Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[2]: Assigned to RFS process 6165
RFS[2]: Identified database type as 'physical standby'
Primary database is in MAXIMUM PERFORMANCE mode
Primary database is in MAXIMUM PERFORMANCE mode
RFS[2]: Successfully opened standby log 5: '/oracle/oradata/ebank/redo05.log'
Thu Jul 16 11:26:10 2009
RFS[1]: Successfully opened standby log 6: '/oracle/oradata/ebank/redo06.log'
Thu Jul 16 11:26:18 2009
Media Recovery Log /oracle/arch/1_486_688836794.dbf
WARNING: File being created with same name as in Primary
Existing file may be overwritten
Thu Jul 16 11:26:28 2009
Recovery created file /oracle/oradata/ebank/test01.dbf
Successfully added datafile 5 to media recovery
Datafile #5: '/oracle/oradata/ebank/test01.dbf'
Media Recovery Waiting for thread 1 sequence 487 (in transit)

当在standby端将该参数设置为manual时,

SQL> alter system set standby_file_management=manual;

System altered.

此时在主端添加一个数据文件,并切换日志,在standby端的alert日志里可以发现:

Primary database is in MAXIMUM PERFORMANCE mode
RFS[2]: Successfully opened standby log 5: '/oracle/oradata/ebank/redo05.log'
Thu Jul 16 11:39:32 2009
Media Recovery Log /oracle/arch/1_488_688836794.dbf
File #7 added to control file as 'UNNAMED00007' because
the parameter STANDBY_FILE_MANAGEMENT is set to MANUAL
The file should be manually created to continue.
Errors with log /oracle/arch/1_488_688836794.dbf
MRP0: Background Media Recovery terminated with error 1274
Thu Jul 16 11:39:33 2009
Errors in file /oracle/admin/ebank/bdump/stby_mrp0_5617.trc:
ORA-01274: cannot add datafile '/oracle/oradata/ebank/test03.dbf' - file could not be created
Some recovered datafiles maybe left media fuzzy
Media recovery may continue but open resetlogs may fail
Thu Jul 16 11:39:34 2009
Errors in file /oracle/admin/ebank/bdump/stby_mrp0_5617.trc:
ORA-01274: cannot add datafile '/oracle/oradata/ebank/test03.dbf' - file could not be created
Thu Jul 16 11:39:34 2009
MRP0: Background Media Recovery process shutdown (stby)

此时需要手动同步standby端的控制文件,具体操作:
(1)在primary端生成standby控制文件,并传到standby端,手动添加数据文件,否则在alert日志里将报错:

Managed Standby Recovery not using Real Time Apply
Thu Jul 16 11:49:38 2009
Errors in file /oracle/admin/ebank/bdump/stby_dbw0_6341.trc:
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/oracle/oradata/ebank/test03.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
MRP0: Background Media Recovery terminated with error 1110
Thu Jul 16 11:49:38 2009
Errors in file /oracle/admin/ebank/bdump/stby_mrp0_6361.trc:
ORA-01110: data file 7: '/oracle/oradata/ebank/test03.dbf'
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/oracle/oradata/ebank/test03.dbf'
Thu Jul 16 11:49:38 2009
Errors in file /oracle/admin/ebank/bdump/stby_mrp0_6361.trc:
ORA-01110: data file 7: '/oracle/oradata/ebank/test03.dbf'
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/oracle/oradata/ebank/test03.dbf'
Thu Jul 16 11:49:38 2009
MRP0: Background Media Recovery process shutdown (stby)

MRP进程已经shutdown了

执行手动创建数据文件:

SQL> alter database create datafile '/oracle/oradata/ebank/test03.dbf' as '/oracle/oradata/ebank/test03.dbf';

Database altered.

重启standby端数据库,查看alert日志:
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[1]: Assigned to RFS process 6399
RFS[1]: Identified database type as 'physical standby'
Thu Jul 16 11:57:37 2009
RFS LogMiner: Client disabled from further notification
RFS[1]: Archived Log: '/tools/archivelog/1_488_688836794.dbf'
Thu Jul 16 11:58:06 2009
Media Recovery Log /tools/archivelog/1_488_688836794.dbf
Media Recovery Log /tools/archivelog/1_489_688836794.dbf
Media Recovery Log /tools/archivelog/1_490_688836794.dbf
Media Recovery Log /tools/archivelog/1_491_688836794.dbf
Media Recovery Log /tools/archivelog/1_492_688836794.dbf
Media Recovery Log /tools/archivelog/1_493_688836794.dbf
Media Recovery Waiting for thread 1 sequence 494

可见,MPR进程已经正常工作了。

查看两端数据文件的checkpoint时间,发现已经一致:

primary:

SQL> select to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') from v$datafile;

TO_CHAR(CHECKPOINT_
-------------------
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43

7 rows selected.

standby:

SQL> select to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') from v$datafile;

TO_CHAR(CHECKPOINT_
-------------------
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43
2009-07-16 07:23:43

7 rows selected.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10972173/viewspace-610904/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: Transitivity
请登录后发表评论 登录
全部评论
十余年大型金融及电信系统数据库管理经验,曾服务于中国建设银行、中国移动。对oracle,mysql数据库有深入了解。 擅长python开发,独立开发了开源数据库自动化监控运维平台Power Monitor。

注册时间:2008-02-29

  • 博文量
    335
  • 访问量
    1369130