[20160813]12c開啟附加日誌問題.txt
[20160813]12c開啟附加日誌問題.txt
--測試需要要在12c下開啟附加日誌,遇到一些問題,做1個記錄:
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
--我的測試環境有pdb資料庫的.
SYS@test> select * from CDB_PDBS;
PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN CON_ID
---------- -------------------- ---------- ---------- -------------------------------- ------------- ------------ ----------
3 TEST01P 1652643119 1652643119 A1EEB4B6462C40349D6EE072862CABA8 NORMAL 2454021 1
2 PDB$SEED 4063864810 4063864810 E328565B49E148BDBA65856218380E9D NORMAL 2256383 1
2.我開始沒有注意,在PDB=test01p下執行操作:
SCOTT@test01p> show con_name
CON_NAME
--------
TEST01P
SCOTT@test01p> alter database add supplemental log data;
Database altered.
--發現居然也可以.
SCOTT@test01p> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
YES NO NO
SYS@test> show con_name
CON_NAME
---------
CDB$ROOT
SYS@test> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
YES NO NO
--可以很好理解都是修改控制檔案.如果在pdb取消附加日誌:
SCOTT@test01p> alter database drop supplemental log data;
Database altered.
--//test01p
SCOTT@test01p> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
YES NO NO
--//CDB$ROOT
SYS@test> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
YES NO NO
--可以發現在pdb資料庫下無法取消附加日誌.
--//CDB$ROOT
SYS@test> alter database drop supplemental log data;
Database altered.
SYS@test> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
NO NO NO
--//test01p
SCOTT@test01p> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
NO NO NO
--可以發現在pdb下可以開啟附加日誌,這樣應該全部pdb我覺得應該都會開啟.但是要取消,僅僅在CDB$ROOT下操作才有效.
3.繼續測試:
--順便建立1張表插入資料.不提交.
--session 1:
SCOTT@test01p> insert into t1(a) values (1);
1 row created.
--切換到另外使用者執行;
SCOTT@test01p(243,27)> alter database add supplemental log data;
--可以發現會話掛起.
SYS@test> @ wait
P1RAW P2RAW P3RAW P1 P2 P3 SID SERIAL# SEQ# EVENT STATE WAIT_TIME_MICRO SECONDS_IN_WAIT
---------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------------------------------- ------------------- --------------- ---------------
0000000042455100 0000000000000001 00 1111838976 1 0 131 337 539 SQL*Net message to client WAITED SHORT TIME 9 0
0000000054580004 0000000000050018 0000000000006053 1415053316 327704 24659 243 27 768 enq: TX - contention WAITING 33832130 34
--可以發現1個等待事件是enq: TX - contention
--session 1:
SCOTT@test01p> @ s
SCOTT@test01p(10,1671)> @ spid
SID SERIAL# SPID PID P_SERIAL# C50
---------- ---------- ------ ------- ---------- --------------------------------------------------
10 1671 5720 56 61 alter system kill session '10,1671' immediate;
SYS@test> @ viewlock
SID SERIAL# USERNAME OSUSER MACHINE MODULE LOCK_TYPE MODE_HELD MODE_REQUE LOCK_ID1 LOCK_ID2 OWNER OBJECT_TYP OBJECT_NAME BLOCK LOCKWAIT
------ ---------- ---------- ---------- ---------- ------------ --------------- ---------- ---------- ---------- ---------- ------ ---------- -------------------- ----- --------------------
10 1671 SCOTT XXX\Admini WORKGROUP\ SQL*Plus TM DML(TM) Row-X (SX) None 105275 0 No
strator XXX
10 1671 SCOTT XXX\Admini WORKGROUP\ SQL*Plus TX Transaction Exclusive None 327704 24659 Yes
strator XXX
243 27 SCOTT XXX\Admini WORKGROUP\ SQL*Plus TX Transaction None Share 327704 24659 No 000007FF6161B848
strator XXX
--//沒有在pdb下執行, OWNER OBJECT_TYP OBJECT_NAME沒有顯示.
SYS@test> @xid
XIDUSN_XIDSLOT_XIDSQN
------------------------------
XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBASQN UBAREC STATUS USED_UBLK USED_UREC XID ADDR START_DATE C70
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ---------------- ---------------- ------------------- ----------------------------------------------------------------------
5 24 24659 5 2486 1487 26 ACTIVE 1 1 0500180053600000 000007FF5E9E8778 2016-08-13 22:43:26 ALTER SYSTEM DUMP UNDO BLOCK '_SYSSMU5_2367258232$' XID 5 24 24659;
ALTER SYSTEM DUMP UNDO HEADER '_SYSSMU5_2367258232$';
ALTER SYSTEM DUMP DATAFILE 5 BLOCK 2486;
select 327704,trunc(327704/65536) XIDUSN,mod(327704,65536) XIDSLOT from dual
327704 XIDUSN XIDSLOT
---------- ---------- ----------
327704 5 24
--//這些XIDUSN,XIDSLOT,XIDSQN=5,24,24659都與LOCK_ID1,LOCK_ID2對上.說明開啟附加日誌需要等待事務結束.
SCOTT@test01p(10,1671)> commit ;
Commit complete.
--session 2執行ok.
4.繼續測試:
SYS@test> alter database drop supplemental log data;
Database altered.
--session 1:再次插入資料,不提交:
SCOTT@test01p(10,1671)> insert into t1(a) values (2);
1 row created.
--//CDB$ROOT
SYS@test> alter database add supplemental log data;
Database altered.
--居然ok了.pdb下有事務,不影響cdb執行開啟附加日誌的功能!!
--//CDB$ROOT
SYS@test> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
YES NO NO
--//test01p
SCOTT@test01p(243,27)> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
YES NO NO
5.繼續測試:
SYS@test> create table t2 (id number);
Table created.
SYS@test> alter database drop supplemental log data;
Database altered.
--//CDB$ROOT
SYS@test> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
NO NO NO
--//test01p
SCOTT@test01p(243,27)> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
NO NO NO
--session 1:
SYS@test> insert into t2 values (1);
1 row created.
--session 2:
SYS@test> alter database add supplemental log data;
--再次掛起.
--session 1:
SYS@test> @s
SYS@test(131,337)> @spid
SID SERIAL# SPID PID P_SERIAL# C50
------ ---------- ------ ------- ---------- --------------------------------------------------
131 337 7844 53 67 alter system kill session '131,337' immediate;
SYS@test(131,337)> @wait
P1RAW P2RAW P3RAW P1 P2 P3 SID SERIAL# SEQ# EVENT STATE WAIT_TIME_MICRO SECONDS_IN_WAIT
---------------- ---------------- ---------------- ---------- ---------- ---------- ------ ---------- ---------- ---------------------------------------- ------------------- --------------- ---------------
0000000042455100 0000000000000001 00 1111838976 1 0 131 337 709 SQL*Net message to client WAITED SHORT TIME 12 0
0000000054580004 00000000000E000F 00000000000008D7 1415053316 917519 2263 10 1673 37 enq: TX - contention WAITING 100081106 100
SYS@test(131,337)> @viewlock
SID SERIAL# USERNAME OSUSER MACHINE MODULE LOCK_TYPE MODE_HELD MODE_REQUE LOCK_ID1 LOCK_ID2 OWNER OBJECT_TYP OBJECT_NAME BLOCK LOCKWAIT
------ ---------- ---------- ---------- ---------- ------------ --------------- ---------- ---------- ---------- ---------- ------ ---------- -------------------- ----- --------------------
10 1673 SYS XXX\Admini WORKGROUP\ sqlplus.exe TX Transaction None Share 917519 2263 No 000007FF6161B2D8
strator XXX
131 337 SYS XXX\Admini WORKGROUP\ sqlplus.exe TX Transaction Exclusive None 917519 2263 Yes
strator XXX
131 337 SYS XXX\Admini WORKGROUP\ sqlplus.exe TM DML(TM) Row-X (SX) None 100875 0 SYS TABLE T2 No
strator XXX
SYS@test(131,337)> @xid
XIDUSN_XIDSLOT_XIDSQN
------------------------------
14.15.2263
XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBASQN UBAREC STATUS USED_UBLK USED_UREC XID ADDR START_DATE C70
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ---------------- ---------------- ------------------- ----------------------------------------------------------------------
14 15 2263 5 1183 762 4 ACTIVE 1 1 0E000F00D7080000 000007FF5E981528 2016-08-13 23:03:02 ALTER SYSTEM DUMP UNDO BLOCK '_SYSSMU14_843651722$' XID 14 15 2263;
ALTER SYSTEM DUMP UNDO HEADER '_SYSSMU14_843651722$';
ALTER SYSTEM DUMP DATAFILE 5 BLOCK 1183;
select 917519,trunc(917519/65536) XIDUSN,mod(917519,65536) XIDSLOT from dual
917519 XIDUSN XIDSLOT
---------- ---------- ----------
917519 14 15
--說明在有事務下,執行開啟附加日誌必須等事務提交才ok.我有空給在11g下測試看看,存在事務沒提交的情況下,是否開啟附加日誌會阻塞.
--補充11g下linux的測試:
SYS@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SYS@book> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
NO NO NO
--開啟session 1,建立表,插入資料,不提交:
SCOTT@book> create table t2 (id number);
Table created.
SCOTT@book> insert into t2 values (1);
1 row created.
SCOTT@book> @ &r/s
SCOTT@book(101,7171)>
SCOTT@book(101,7171)> @ &r/xid
XIDUSN_XIDSLOT_XIDSQN
------------------------------
10.23.57204
XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBASQN UBAREC STATUS USED_UBLK USED_UREC XID ADDR START_DATE C70
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ---------------- ---------------- ------------------- ----------------------------------------------------------------------
10 23 57204 3 1761 11682 6 ACTIVE 1 1 0A00170074DF0000 0000000081932FD0 2016-08-15 08:42:10 ALTER SYSTEM DUMP UNDO BLOCK '_SYSSMU10_1197734989$' XID 10 23 57204;
ALTER SYSTEM DUMP UNDO HEADER '_SYSSMU10_1197734989$';
ALTER SYSTEM DUMP DATAFILE 3 BLOCK 1761;
--session 2:
SYS@book> alter database add supplemental log data;
--掛起!
--session 1:
SCOTT@book(101,7171)> @ &r/viewlock
SID SERIAL# USERNAME OSUSER MACHINE MODULE LOCK_TYPE MODE_HELD MODE_REQUE LOCK_ID1 LOCK_ID2 OWNER OBJECT_TYP OBJECT_NAME BLOCK LOCKWAIT
------ ---------- ---------- ---------- ---------- ------------ --------------- ---------- ---------- ---------- ---------- ------ ---------- -------------------- ----- --------------------
90 5421 SYS oracle gxqyydg4 sqlplus@gxqy TX Transaction None Share 655383 57204 No 00000000851E3C88
ydg4 (TNS V1
-V3)
101 7171 SCOTT oracle gxqyydg4 SQL*Plus TX Transaction Exclusive None 655383 57204 Yes
101 7171 SCOTT oracle gxqyydg4 SQL*Plus TM DML(TM) Row-X (SX) None 96016 0 SCOTT TABLE T2 No
SYS@book> alter database add supplemental log data;
alter database add supplemental log data
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation
SYS@book> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
YES NO NO
--中斷,你可以查詢發現SUPPLEMENTAL_LOG_DATA_MIN=yes.再次執行1次,估計已經開啟,不會有任何操作。
SYS@book> alter database add supplemental log data;
Database altered.
SYS@book> alter database drop supplemental log data;
--掛起!在有事務的情況下也會掛起。
SYS@book> select SUPPLEMENTAL_LOG_DATA_MIN,SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI from v$database;
SUPPLEME SUP SUP
-------- --- ---
NO NO NO
--檢查發現居然也取消了。
--我12c 使用的windows版本,無法中斷。按ctrl+c就退出。
--檢查alert*.log如下:
Mon Aug 15 08:43:39 2016
alter database add supplemental log data
SUPLOG: Previous supplemental logging attributes at scn = 13245951124
SUPLOG: minimal = OFF, primary key = OFF
SUPLOG: unique = OFF, foreign key = OFF, all column = OFF
SUPLOG: procedural replication = OFF
SUPLOG: New supplemental logging attributes at scn = 13245951124
SUPLOG: minimal = ON, primary key = OFF
SUPLOG: unique = OFF, foreign key = OFF, all column = OFF
SUPLOG: procedural replication = OFF
Mon Aug 15 08:43:43 2016
Incremental checkpoint up to RBA [0x1bd.5d30.0], current log tail at RBA [0x1bd.5e03.0]
Mon Aug 15 08:46:00 2016
ORA-1013 signalled during: alter database add supplemental log data...
Mon Aug 15 08:46:53 2016
alter database add supplemental log data
Completed: alter database add supplemental log data
Mon Aug 15 08:47:42 2016
alter database drop supplemental log data
SUPLOG: Previous supplemental logging attributes at scn = 13245951518
SUPLOG: minimal = ON, primary key = OFF
SUPLOG: unique = OFF, foreign key = OFF, all column = OFF
SUPLOG: procedural replication = OFF
SUPLOG: New supplemental logging attributes at scn = 13245951518
SUPLOG: minimal = OFF, primary key = OFF
SUPLOG: unique = OFF, foreign key = OFF, all column = OFF
SUPLOG: procedural replication = OFF
Mon Aug 15 08:48:13 2016
ORA-1013 signalled during: alter database drop supplemental log data...
--總結:
1.我不知道按ctrl+c,是否真正成功。
2.在11g下有事務的情況下無法開啟與關閉附件日誌,按ctrl+c中斷,查詢v$database提示操作成功,是否真有效。
3.12c 下pdb開啟附加日誌,全域性有效。而有事務存在的情況也會掛起。
4.但是存在1個例外(12c),就是pdb下有事務,cdb一樣可以正常開啟附加日誌。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2123472/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 開啟關閉oracle資料庫附加日誌Oracle資料庫
- Oracle 附加日誌Oracle
- 附加日誌(supplemental log)
- mysql5.7無法開啟二進位制日誌問題MySql
- mysql開啟慢日誌MySql
- Oracle寫日誌問題Oracle
- 日誌檔案問題
- 檢視mysql日誌及日誌編碼問題MySql
- mysql因為事務日誌問題無法啟動MySql
- Ubuntu 下開啟 crontab日誌Ubuntu
- mysql開啟日誌記錄MySql
- RAC 開啟歸檔日誌
- postgresql開啟歸檔日誌SQL
- Java日誌輸出問題Java
- storm 問題日誌記錄ORM
- SQL Server 無日誌檔案附加資料庫SQLServer資料庫
- [20221121]rman刪除歸檔日誌問題.txt
- 某Q友的問題--如何讓sqlplus spool產生的日誌附加sysdate日期資訊-shellSQL
- insert中啟用錯誤日誌的問題及分析
- 慢查詢日誌開啟分析
- PostgreSQL-開啟PG日誌(六)SQL
- 在Hibernate中開啟日誌
- 資料庫管理-第118期 記一次開啟附加日誌導致的效能問題(202301129)資料庫
- [20170228]dg的日誌傳輸與應用問題.txt
- 12c日誌檔案路徑
- 開啟PHP的錯誤log日誌PHP
- 開啟mysql和php慢日誌方法MySqlPHP
- oracle 歸檔日誌開啟,關閉Oracle
- 關閉和開啟歸檔日誌
- Laravel Daily 日誌許可權問題LaravelAI
- websphere日誌分析——程式隱患問題Web
- Checkpoint not complete 日誌檔案問題
- 關於日誌事務的問題
- 【日誌亂碼】解決Tomcat啟動控制檯亂碼問題Tomcat
- MYSQL啟用日誌和檢視日誌MySql
- 開啟php-fpm慢指令碼日誌PHP指令碼
- MYSQL開啟慢查詢日誌實施MySql
- ORACLE 歸檔日誌開啟關閉方法Oracle