logical standby ORA-1119
本站文章除注明转载外,均为本站原创: 转载自love wife love life —Roger的Oracle/MySQL/PostgreSQL数据恢复博客
本文链接地址: logical standby ORA-1119
群中一位网友的问题,logical standby 同步create tablespace操作,遇到如下问题:
1 2 3 4 5 6 |
ORA-1119 signalled during: create tablespace ts_test datafile 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\PRIMYDB2\ts_test.dbf' size 10m autoextend off... LOGSTDBY stmt: create tablespace ts_test datafile 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\PRIMYDB2\ts_test.dbf' size 10m autoextend off LOGSTDBY status: ORA-01119: 创建数据库文件 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\PRIMYDB2\ts_test.dbf' 时出错 ORA-27038: 所创建的文件已存在 |
我们知道,create tablespace属于ddl操作,可能有人会问,是不是logical standby不支持ddl?
其实是支持的,只是针对这种情况,不应该这样操作而已。
下面是mos提供的一个solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
Cause 1. If databse is OMF on both primary and standby then no issues in creating datafile at logical standby side. 2. If no OMF then Apply terminate with (ORA-1119) below errors, Because logcal standby will not honour the db_file_name_convert. Solution SOLUTION ========== 1. Use OMF as a proactive measure. 2. If not run skip handler. For example, 1. Stop SQL apply, alter database stop logical standby apply; 2. Create skip handler, SQL> CREATE OR REPLACE PROCEDURE SYS.HANDLE_TBS_DDL ( OLD_STMT IN VARCHAR2, STMT_TYP IN VARCHAR2, SCHEMA IN VARCHAR2, NAME IN VARCHAR2, XIDUSN IN NUMBER, XIDSLT IN NUMBER, XIDSQN IN NUMBER, ACTION OUT NUMBER, NEW_STMT OUT VARCHAR2 ) AS BEGIN -- All primary file specification that contains a directory -- /usr/orcl/primary/dbs -- should go to /usr/orcl/stdby directory specification NEW_STMT := REPLACE(OLD_STMT, 'D:\APP\NSELVAKU\ORADATA\BOSTON\BOSTON\DATAFILE\','D:\APP\NSELVAKU\ORADATA\BOSTON\', 'D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\'); ACTION := DBMS_LOGSTDBY.SKIP_ACTION_REPLACE; EXCEPTION WHEN OTHERS THEN ACTION := DBMS_LOGSTDBY.SKIP_ACTION_ERROR; NEW_STMT := NULL; END HANDLE_TBS_DDL; / Procedure created. SQL> EXECUTE DBMS_LOGSTDBY.SKIP (stmt => 'TABLESPACE',proc_name => 'sys.handle_tbs_ddl'); PL/SQL procedure successfully completed. 3. Start the SQL Apply, SQL> ALTER DATABASE START LOGICAL STANDBY APPLY; Database altered. 4. Check the v$datafile, SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\O1_MF_SYSTEM_DATA_D-BOSTON_I-24 57766127_TS-SYSTEM_FNO-1_0HMUP6IP_.DBF D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\O1_MF_SYSAUX_DATA_D-BOSTON_I-24 57766127_TS-SYSAUX_FNO-2_0IMUP6JS_.DBF D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\O1_MF_UNDOTBS1_DATA_D-BOSTON_I- 2457766127_TS-UNDOTBS1_FNO-3_0LMUP6L4_.DBF D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\O1_MF_USERS_DATA_D-BOSTON_I-245 7766127_TS-USERS_FNO-4_0MMUP6L7_.DBF NAME -------------------------------------------------------------------------------- D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\O1_MF_EXAMPLE_DATA_D-BOSTON_I-2 457766127_TS-EXAMPLE_FNO-5_0JMUP6KL_.DBF D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\O1_MF_TS1_DATA_D-BOSTON_I-24577 66127_TS-TS1_FNO-6_0KMUP6KS_.DBF D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\O1_MF_TS2_7H5FOZW2_.DBF D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\O1_MF_TS3_7H5FTGNG_.DBF D:\APP\NSELVAKU\ORADATA\CHICAGO\CHICAGO\DATAFILE\DATA04.ORA 9 rows selected. |
另外还有几篇相关文档,大家也可以看看参考下,如下:
ORA-18008: DDL Not Applied in Logical Standby [ID 233730.1]
SKIPPING PARTITION DDL ON YOUR LOGICAL STANDBY DATABASE [ID 417597.1]
2 Responses to “logical standby ORA-1119”
SKIPPING PARTITION DDL ON YOUR LOGICAL STANDBY DATABASE [ID 417597.1]
Skipping Partition DDL on your Logical Standby Database
This note addresses the following use case: Your application only needs to maintain 3 months of data on line, partitioned monthly, but you also have a requirement to keep the data for 7 years. You can use your Logical standby database to keep this data longer so that the Primary database does not have to maintain the data.
To do this you will need to manually maintain the physical structure changes to the partitioned table on both the primary database and the standby database so when you add next months partition and remove last months partition on the primary, the partitions on the Logical standby database will not be changed automatically (data in the table will continue to be maintained by SQL Apply). To do this you need to‘SKIP’ the “ALTER TABLE” command on the standby database so the delete partition will not be executed. You will then need to add next month’s partition on to the standby database. The ‘SKIP’ is done using the DBMS_LOGSTDBY.SKIP[1] procedure on the Logical Standby database. Consider the following simple table on the primary database.
create table orders
(order_date date not null
, order_number number not null
, customer_code varchar2(7) not null
) partition by range ( order_date )
( partition p200611 values less than (to_date(’01-Dec-2006′) )
, partition p200612 values less than (to_date(’01-Jan-2007′) )
, partition p200701 values less than (to_date(’01-Feb-2007′) )
, partition p200702 values less than (to_date(’01-Mar-2007′) )
, partition pnext values less than (maxvalue));
The normal process each month is to prepare next months partition and remove the oldest partition from this table on the 15th of each month. This would be performed using the “ALTER TABLE” command as follows.
alter table orders drop partition p2000611 update indexes;
alter table orders split partition pnext at (to_date(’01-Apr-2007′))
into ( partition p200703 , partition pnext ) update indexes;
By default these two DDL commands will be executed on the Logical standby database. To prevent that (and keep the data longer) you first must skip these commands by using the DBMS_LOGSTDBY.SKIP procedure, once, to setup the skip rule.
On the standby, define the skip as follows:
alter database stop logical standby apply;
execute dbms_logstdby.skip(‘alter table’,’scott’,’orders’);
alter database start logical standby apply;
Now when the “alter table drop partition” command is executed on the primary, the command will be skipped on the standby, preserving the data. However, this will also skip the “alter table split partition” command on the Logical standby database, something you do not want to happen. You address this on the standby database by manually executing the “alter table split partition” command after it has completed on the primary.
alter database stop logical standby apply;
alter session disable guard;
alter table scott.orders split partition pnext at (to_date(’01-Apr-2007′))
into ( partition p200703 , partition pnext ) update indexes;
alter session enable guard;
alter database start logical standby apply;
Note that you must specify the schema as well as the table (scott.orders) as you must be logged into the Logical standby database as SYS to disable the guard.
If you want to allow all other “ALTER TABLE” commands to be executed on this table and only skip the drop partition command, you can define a PL/SQL Procedure that you want to have executed whenever the “ALTER TABLE” command is received. Now, rather than skipping all “ALTER TABLE” commands for the “scott.orders” table, you can specify what commands should be skipped and which ones should execute normally.
The following PL/SQL Procedure is an example of an extremely simplified procedure that could be used.
create or replace procedure sys.sql_apply_partition_handler
(statement IN VARCHAR2
,statement_type IN VARCHAR2
,schema IN VARCHAR2
,name IN VARCHAR2
,lxidusn IN NUMBER
,lxidslt IN NUMBER
,lxidsqn IN NUMBER
,skip_action OUT NUMBER
,new_statement OUT VARCHAR2) AS
begin
IF upper(statement) like ‘%DROP%PARTITION%’
THEN
skip_action := sys.dbms_logstdby.SKIP_ACTION_SKIP;
new_statement := null;
ELSE –upper(statement) = ‘%DROP%PARTITION%’
skip_action := sys.dbms_logstdby.SKIP_ACTION_APPLY;
new_statement := null;
END IF; –Schema Check
end sql_apply_partition_handler;
/
This procedure will tell SQL Apply to skip all “DROP PARTITION”commands and allow all other “ALTER TABLE” commands to be applied normally.
To direct SQL Apply to call your procedure whenever it receives an“ALTER TABLE” command, you must change the skip definition changed so that the PL/SQL procedure is called as follows:
alter database stop logical standby apply;execute dbms_logstdby.skip(‘alter table’,’scott’,’orders’,’SYS.SQL_APPLY_PARTITION_HANDLER’);
alter database start logical standby apply;References:1. DBMS_LOGSTDBY.SKIP – Data Guard Concepts and Administrationhttp://download-west.oracle.com/docs/cd/B19306_01/server.102/b14239/manage_ls.htm- CHDDIHHI
Leave a Reply
You must be logged in to post a comment.