测试ACTIVE DATAGUART出现ORA-01111等错误

在新建完Physical standby之后,想测试一下ACTIVE DATAGUARD的效果,在新建Tablespace和datafile的时候,会出现以下错误:

打开备库提示:

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-10458: standby database requires recovery
ORA-01157: 无法标识/锁定数据文件 5 - 请参阅 DBWR 跟踪文件
ORA-01111: 数据文件 5 名称未知 - 请重命名以更正文件
ORA-01110: 数据文件 5:
'E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\UNNAMED00005'

备库日志提示如下错误:

Mon Dec 22 22:19:27 2014
MRP0 started with pid=28, OS id=4436
 started logmerger process
Mon Dec 22 22:19:32 2014
Managed Standby Recovery not using Real Time Apply
MRP0: Background Media Recovery terminated with error 1111
Errors in file e:\app\oracle\diag\rdbms\standby\orcldb\trace\orcldb_pr00_7040.trc:
ORA-01111: name for data file 5 is unknown - rename to correct file
ORA-01110: data file 5: 'E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\UNNAMED00005'
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01111: name for data file 5 is unknown - rename to correct file
ORA-01110: data file 5: 'E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\UNNAMED00005'
Slave exiting with ORA-1111 exception
Errors in file e:\app\oracle\diag\rdbms\standby\orcldb\trace\orcldb_pr00_7040.trc:
ORA-01111: name for data file 5 is unknown - rename to correct file
ORA-01110: data file 5: 'E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\UNNAMED00005'
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01111: name for data file 5 is unknown - rename to correct file
ORA-01110: data file 5: 'E:\APP\ORACLE\PRODUCT\11.2.0\DBHOME_1\DATABASE\UNNAMED00005'
Recovery Slave PR00 previously exited with exception 1111

...

Mon Dec 22 22:01:45 2014
File #5 added to control file as 'UNNAMED00005' because
the parameter STANDBY_FILE_MANAGEMENT is set to MANUAL

The file should be manually created to continue.
MRP0: Background Media Recovery terminated with error 1274
Errors in file e:\app\oracle\diag\rdbms\standby\orcldb\trace\orcldb_pr00_5020.trc:
ORA-01274: cannot add datafile 'E:\APP\ORACLE\ORADATA\ORCLDB\TBSDATA1.DBF' - file could not be created
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Recovered data files to a consistent state at change 1078919
Errors in file e:\app\oracle\diag\rdbms\standby\orcldb\trace\orcldb_pr00_5020.trc:
ORA-01274: cannot add datafile 'E:\APP\ORACLE\ORADATA\ORCLDB\TBSDATA1.DBF' - file could not be created

日志提示了在备库参数STANDBY_FILE_MANAGEMENT是设置为手工模式,需要手工去把新建的数据文件复制到备库上,需要把这个值设置为auto后操作新增Tablespace和datafile。现在想解决备库同步的问题需执行以下:

1,把主库新建datafile数据文件offline后复制一份出来

SQL> alter database datafile 'E:\APP\ORACLE\ORADATA\ORCLDB\TBSDATA1.DBF' offline;

Database altered.

2,因为主库控制文件已经有变化,需要重建备库standby控制文件

关闭实例后挂载

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;

新建备库控制文件,并重命名3份

SQL> alter database create standby controlfile as 'e:\control01.ctl';

Database altered.

open主库如提示ora-01113,mount状态执行

SQL> recover datafile 5;

SQL> alter database open;

3,关闭备库实例

SQL> shutdown immediate;

4,把刚才offline的数据文件和3份控制文件拷贝到备库相应路径

5,挂载备库(如出现ora-00214的情况把最新的控制文件复制3份就可以了)

SQL> startup

SQL> alter database mount standby database;

SQL> select name from v$datafile;

NAME
----------------------------------------------------------------------
E:\APP\ORACLE\ORADATA\ORCLDB\DATAFILE\O1_MF_SYSTEM_B9HLJHCV_.DBF
E:\APP\ORACLE\ORADATA\ORCLDB\DATAFILE\O1_MF_SYSAUX_B9HLJHGZ_.DBF
E:\APP\ORACLE\ORADATA\ORCLDB\DATAFILE\O1_MF_UNDOTBS1_B9HLJHH9_.DBF
E:\APP\ORACLE\ORADATA\ORCLDB\DATAFILE\O1_MF_USERS_B9HLJHJ7_.DBF
E:\APP\ORACLE\ORADATA\ORCLDB\TBSDATA1.DBF

6,执行应用归档

SQL> alter database recover managed standby database disconnect from session;

查看归档应用情况

SQL> select name,sequence#,applied from v$archived_log; ­

7,添加主库备库参数standby_file_management后用pfile启动并生成spfile

 STANDBY_FILE_MANAGEMENT=AUTO

SQL> show parameter  STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
------------------------------------ ----------- ---------------
standby_file_management              string      AUTO


8,重新再试一下新建datafile。

切换日志
SQL> alter system switch logfile;

System altered.

打开备库read only with apply

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database open;

Database altered.

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

Database altered.

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY WITH APPLY

新建datafile

SQL> alter tablespace tbs_test add datafile 'e:\app\oracle\oradata\orcldb\tbsdata2.dbf' size 10m;

备库日志提示:

Tue Dec 23 01:17:38 2014
Successfully added datafile 6 to media recovery
Datafile #6: 'E:\APP\ORACLE\ORADATA\STANDBY\DATAFILE\O1_MF_TBS_TEST_B9JNKKW0_.DBF'

SQL> select name from v$datafile;

NAME
---------------------------------------------------------------------
E:\APP\ORACLE\ORADATA\ORCLDB\DATAFILE\O1_MF_SYSTEM_B9HLJHCV_.DBF
E:\APP\ORACLE\ORADATA\ORCLDB\DATAFILE\O1_MF_SYSAUX_B9HLJHGZ_.DBF
E:\APP\ORACLE\ORADATA\ORCLDB\DATAFILE\O1_MF_UNDOTBS1_B9HLJHH9_.DBF
E:\APP\ORACLE\ORADATA\ORCLDB\DATAFILE\O1_MF_USERS_B9HLJHJ7_.DBF
E:\APP\ORACLE\ORADATA\ORCLDB\TBSDATA1.DBF
E:\APP\ORACLE\ORADATA\STANDBY\DATAFILE\O1_MF_TBS_TEST_B9JNKKW0_.DBF  <-- 这个名字怎么这样?可能要设置一下什么东西吧。

新建用户和表实时测试查询

SQL> create user tbs_user1 identified by oracle default tablespace tbs_test;

User created.

SQL> grant connect,resource to tbs_user1;

Grant succeeded.

备库查询

SQL> select * from test1;

        ID
----------
         1

Active DataGuard 测试成功。


小结:之前做的active DG实验可能就是因为这一步的参数设置没有修改才会提示错误,那时候因为没有实时看日志记录没有了解到关键所在,以后再做每一步实验的时候都需要把警告和跟踪文件实时看一遍,才能更好去分析和解决问题。


你可能感兴趣的:(测试ACTIVE DATAGUART出现ORA-01111等错误)