Oracle ACE 总监 Syed Jaffer Hussain 对 Oracle 数据库 12c 新特性
的一个非常全面的总结,包括了数据库管理、可用性、RAC 以及开发等方面内容,让您从技术细节层面最全面地了解 Oracle 数据库 12c。
注意:该功能是Oracle12c的新特性,并不是ArcGIS的新特性。
在之前的版本中没有可选方法来对DDL操作进行日志记录。而在12c R1中,你现在可以将DDL操作写入xml和日志文件中。这对于了解谁在什么时间执行了create或drop命令是十分有用的。要开启这一功能必须对ENABLE_DDL_LOGGING 初始参数加以配置。这一参数可以在数据库或会话级加以设置。当此参数为启用状态,所有的DDL命令会记录在$ORACLE_BASE/diag/rdbms/DBNAME/log|ddl 路径下的xml和日志文件中。一个xml中包含DDL命令,IP地址,时间戳等信息。这可以帮助确定在什么时候对用户或表进行了删除亦或是一条DDL语句在何时触发。
系统捕捉类似DDL操作包括:
----------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
Blog: http://blog.csdn.net/linghe301
----------------------------------------------------------------------------------
使用该功能之前,需要开启DDL日志功能
SQL> conn sys/[email protected]/pdborcl as sysdba Connected. SQL> alter system set enable_ddl_logging=true; System altered.
注意该命令既可设置alter System级别,也可设置alter session级别。
我使用ArcGIS Desktop做测试,就设置System级别。
环境:Linux 5、Oracle12.1.0.1、ArcGIS10.2.1
操作步骤:
1:开启DDL日志2:使用ArcGIS Desktop导入一个要素类到ArcSDE中
3:查看指定路径下的日志信息,获得.log文件
[oracle@oracle12c log]$ pwd /home/oracle/app/oracle/diag/rdbms/orcl/orcl/log [oracle@oracle12c log]$ ll total 28 drwxr-x--- 2 oracle oracle 4096 Feb 15 17:31 ddl -rw-r----- 1 oracle oracle 2009 Feb 15 17:32 ddl_orcl.log drwxr-x--- 2 oracle oracle 4096 Jul 1 2013 debug drwxr-x--- 2 oracle oracle 4096 Jul 1 2013 test
----------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
Blog: http://blog.csdn.net/linghe301
----------------------------------------------------------------------------------
Sat Feb 15 17:31:52 2014 diag_adl:CREATE TABLE SDE.zd (OBJECTID INTEGER NOT NULL, BSM INTEGER NULL, YSDM NVARCHAR2(10) NULL, DJH NVARCHAR2(19) NULL, ZDSZ NVARCHAR2(200) NULL, TXDZ NVARCHAR2(100) NULL, TDZL NVARCHAR2(100) NULL, QSXZ NVARCHAR2(2) NULL, SYQLX NVARCHAR2(2) NULL, TDYT NVARCHAR2(4) NULL, SCMJ NUMBER(38,8) NULL, FZMJ NUMBER(38,8) NULL, JZRJL NUMBER(38,8) NULL, JZMD NUMBER(38,8) NULL, TDJB NVARCHAR2(2) NULL, SBDJ NUMBER(38,8) NULL, QDJG NUMBER(38,8) NULL, QLR NVARCHAR2(254) NULL, FZ NVARCHAR2(100) NULL, FM NVARCHAR2(100) NULL, MJ NVARCHAR2(100) NULL, SYCRENDER NVARCHAR2(100) NULL, HYDM NVARCHAR2(200) NULL) PCTFREE 0 INITRANS 4 diag_adl:CREATE UNIQUE INDEX R20_sde_rowid_uk on ZD (OBJECTID) PCTFREE 0 INITRANS 4 NOLOGGING diag_adl:CREATE SEQUENCE SDE.R20 INCREMENT BY 16 START WITH 1 MAXVALUE 2147483647 NOCYCLE diag_adl:ALTER TABLE SDE.ZD ADD (Shape SDE.ST_GEOMETRY NULL) LOB (Shape.points) STORE AS (CHUNK 8K CACHE ENABLE STORAGE IN ROW PCTVERSION 1) diag_adl:CREATE TABLE SDE.S9_IDX$ (gx integer, gy integer, minx integer,miny integer, maxx integer, maxy integer, sp_id rowid,constraint S9$_IX1 primary key(gx,gy,maxx,maxy,minx,miny,sp_id)) organization index pctthreshold 5 pctfree 0 initrans 4 tablespace SDE diag_adl:CREATE INDEX SDE.S9$_IX2 ON S9_IDX$ (sp_id) tablespace SDE diag_adl:CREATE INDEX SDE.A15_IX1 ON SDE.ZD(Shape) INDEXTYPE IS SDE.ST_SPATIAL_INDEX PARAMETERS('ST_GRIDS = 0 ST_SRID = 300005 ST_COMMIT_ROWS = 10000 PCTFREE 0 INITRANS 4') diag_adl:drop index A15_IX1 diag_adl:CREATE TABLE SDE.S9_IDX$ (gx integer, gy integer, minx integer,miny integer, maxx integer, maxy integer, sp_id rowid,constraint S9$_IX1 primary key(gx,gy,maxx,maxy,minx,miny,sp_id)) organization index pctthreshold 5 pctfree 0 initrans 4 tablespace SDE diag_adl:CREATE INDEX SDE.S9$_IX2 ON S9_IDX$ (sp_id) tablespace SDE diag_adl:CREATE INDEX SDE.A15_IX1 ON SDE.ZD(SHAPE) INDEXTYPE IS SDE.ST_SPATIAL_INDEX PARAMETERS('ST_GRIDS = 320 ST_SRID = 300005 ST_COMMIT_ROWS = 10000 PCTFREE 0 INITRANS 4')
----------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
Blog: http://blog.csdn.net/linghe301
----------------------------------------------------------------------------------
[oracle@oracle12c ddl]$ pwd /home/oracle/app/oracle/diag/rdbms/orcl/orcl/log/ddl [oracle@oracle12c ddl]$ ll total 8 -rw-r----- 1 oracle oracle 4404 Feb 15 17:32 log.xml
打开该XML文件
<msg time='2014-02-15T17:31:52.946-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203' version='1'> <txt>CREATE TABLE SDE.zd (OBJECTID INTEGER NOT NULL, BSM INTEGER NULL, YSDM NVARCHAR2(10) NULL, DJH NVARCHAR2(19) NULL, ZDSZ NVARCHAR2(200) NULL, TXDZ NVARCHAR2(100) NULL, TDZL NVARCHAR2(100) NULL, QSXZ NVARCHAR2(2) NULL, SYQLX NVARCHAR2(2) NULL, TDYT NVARCHAR2(4) NULL, SCMJ NUMBER(38,8) NULL, FZMJ NUMBER(38,8) NULL, JZRJL NUMBER(38,8) NULL, JZMD NUMBER(38,8) NULL, TDJB NVARCHAR2(2) NULL, SBDJ NUMBER(38,8) NULL, QDJG NUMBER(38,8) NULL, QLR NVARCHAR2(254) NULL, FZ NVARCHAR2(100) NULL, FM NVARCHAR2(100) NULL, MJ NVARCHAR2(100) NULL, SYCRENDER NVARCHAR2(100) NULL, HYDM NVARCHAR2(200) NULL) PCTFREE 0 INITRANS 4 </txt> </msg> <msg time='2014-02-15T17:31:53.390-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>CREATE UNIQUE INDEX R20_sde_rowid_uk on ZD (OBJECTID) PCTFREE 0 INITRANS 4 NOLOGGING </txt> </msg> <msg time='2014-02-15T17:31:53.485-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>CREATE SEQUENCE SDE.R20 INCREMENT BY 16 START WITH 1 MAXVALUE 2147483647 NOCYCLE </txt> </msg> <msg time='2014-02-15T17:31:54.845-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>ALTER TABLE SDE.ZD ADD (Shape SDE.ST_GEOMETRY NULL) LOB (Shape.points) STORE AS (CHUNK 8K CACHE ENABLE STORAGE IN ROW PCTVERSION 1) </txt> </msg> <msg time='2014-02-15T17:31:56.118-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>CREATE TABLE SDE.S9_IDX$ (gx integer, gy integer, minx integer,miny integer, maxx integer, maxy integer, sp_id rowid,constraint S9$_IX1 primary key(gx,gy,maxx,maxy,minx,miny,sp_id)) organization index pctthreshold 5 pctfree 0 initrans 4 tablespace SDE </txt> </msg> <msg time='2014-02-15T17:31:56.248-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>CREATE INDEX SDE.S9$_IX2 ON S9_IDX$ (sp_id) tablespace SDE </txt> </msg> <msg time='2014-02-15T17:31:56.354-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>CREATE INDEX SDE.A15_IX1 ON SDE.ZD(Shape) INDEXTYPE IS SDE.ST_SPATIAL_INDEX PARAMETERS('ST_GRIDS = 0 ST_SRID = 300005 ST_COMMIT_ROWS = 10000 PCTFREE 0 INITRANS 4') </txt> </msg> <msg time='2014-02-15T17:32:01.820-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>drop index A15_IX1 </txt> </msg> <msg time='2014-02-15T17:32:08.393-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>CREATE TABLE SDE.S9_IDX$ (gx integer, gy integer, minx integer,miny integer, maxx integer, maxy integer, sp_id rowid,constraint S9$_IX1 primary key(gx,gy,maxx,maxy,minx,miny,sp_id)) organization index pctthreshold 5 pctfree 0 initrans 4 tablespace SDE </txt> </msg> <msg time='2014-02-15T17:32:08.642-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>CREATE INDEX SDE.S9$_IX2 ON S9_IDX$ (sp_id) tablespace SDE </txt> </msg> <msg time='2014-02-15T17:32:08.657-05:00' org_id='oracle' comp_id='rdbms' msg_id='kpdbLogDDL:15115:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='oracle12c' host_addr='192.168.220.203'> <txt>CREATE INDEX SDE.A15_IX1 ON SDE.ZD(SHAPE) INDEXTYPE IS SDE.ST_SPATIAL_INDEX PARAMETERS('ST_GRIDS = 320 ST_SRID = 300005 ST_COMMIT_ROWS = 10000 PCTFREE 0 INITRANS 4') </txt> </msg>
通过该XML文件可以获得具体是哪个IP、那个时间、执行了那些操作,这个对一个管理员来说,有利于对错误信息进行分析。
而且,也有助于用户研究一个中间件提供了很好的理论依据。
特别是在一个没有专业Oracle DBA的环境下,我们可以使用这个简单的方法来粗粒度的进行操作监控。当然,专业的DBA可以使用Oracle收费的审计模块来对数据库行这些细粒度的操作进行监控。
----------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
Blog: http://blog.csdn.net/linghe301
欢迎添加微信公众号:ArcGIS技术分享(arcgis_share),直接回复1就可以在移动端获取最新技术文章
----------------------------------------------------------------------------------