首页 » ORACLE 9i-23ai » How to Expdp Unified Audit Trail(AUDSYS.AUD$UNIFIED) in 12c 19c ..

How to Expdp Unified Audit Trail(AUDSYS.AUD$UNIFIED) in 12c 19c ..

我们可以使用datapump进行 Oracle 的 AUDIT 审计记录导出到其它库,但是导出时有一些限制,使用expdp或exp可能会提示ORA-39166或EXP-00064错误, 如之前审计记录在sys.aud$,使用了统一审计后,记录在audsys.AUD$UNIFIED。导出方法一样,仅记录。

环境oracle 19.24

尝试expdp

$ expdp system directory=ORACLE_BASE dumpfile=aud.dump tables=AUDSYS.AUD$UNIFIED

Export: Release 19.0.0.0.0 - Production on Fri May 16 16:42:11 2025
Version 19.24.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
Password:

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Warning: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.

Starting "SYSTEM"."SYS_EXPORT_TABLE_01":  system/******** directory=ORACLE_BASE dumpfile=aud.dump tables=AUDSYS.AUD
ORA-39166: Object AUDSYS.AUD was not found or could not be exported or imported.
ORA-31655: no data or metadata objects selected for job
Job "SYSTEM"."SYS_EXPORT_TABLE_01" completed with 2 error(s) at Fri May 16 16:42:22 2025 elapsed 0 00:00:04

$ expdp system directory=ORACLE_BASE dumpfile=aud.dump tables=AUDSYS.AUD\$UNIFIED

Export: Release 19.0.0.0.0 - Production on Fri May 16 16:42:39 2025
Version 19.24.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
Password:

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Warning: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.

Starting "SYSTEM"."SYS_EXPORT_TABLE_01":  system/******** directory=ORACLE_BASE dumpfile=aud.dump tables=AUDSYS.AUD$UNIFIED
ORA-39166: Object AUDSYS.AUD$UNIFIED was not found or could not be exported or imported.
ORA-31655: no data or metadata objects selected for job
Job "SYSTEM"."SYS_EXPORT_TABLE_01" completed with 2 error(s) at Fri May 16 16:42:51 2025 elapsed 0 00:00:02

sys@ORA19C > @o AUDSYS.AUD$UNIFIED

owner                     object_name                    object_type          status           OID      D_OID CREATED             LAST_DDL_TIME
------------------------- ------------------------------ -------------------- --------- ---------- ---------- ------------------- -------------------
AUDSYS                    AUD$UNIFIED                    TABLE                VALID          18570            2019-04-17 01:09:45 2019-04-17 01:09:45
AUDSYS                    AUD$UNIFIED                    TABLE PARTITION      VALID          90302      90302 2024-12-05 14:20:20 2024-12-05 14:20:20
AUDSYS                    AUD$UNIFIED                    TABLE PARTITION      VALID          79202      79202 2024-10-10 12:36:31 2024-10-10 12:36:31
AUDSYS                    AUD$UNIFIED                    TABLE PARTITION      VALID          85221      85221 2024-11-08 12:37:22 2024-11-08 12:37:22
AUDSYS                    AUD$UNIFIED                    TABLE PARTITION      VALID          18571      18571 2019-04-17 01:09:45 2019-04-17 01:09:45
AUDSYS                    AUD$UNIFIED                    TABLE PARTITION      VALID          72866      72866 2024-09-09 20:47:27 2024-09-09 20:47:27

sys@ORA19C > @seg AUDSYS.AUD$UNIFIED

    SEG_MB OWNER                SEGMENT_NAME                   SEG_PART_NAME                  SEGMENT_TYPE         SEG_TABLESPACE_NAME                BLOCKS     HDRFIL     HDRBLK
---------- -------------------- ------------------------------ ------------------------------ -------------------- ------------------------------ ---------- ---------- ----------
         0 AUDSYS               AUD$UNIFIED                    SYS_P181                       TABLE PARTITION      SYSAUX                                 16          3       8602
         0 AUDSYS               AUD$UNIFIED                    SYS_P1901                      TABLE PARTITION      SYSAUX                                  8          3      76466
         0 AUDSYS               AUD$UNIFIED                    SYS_P3321                      TABLE PARTITION      SYSAUX                                  8          3      82418
         0 AUDSYS               AUD$UNIFIED                    SYS_P4621                      TABLE PARTITION      SYSAUX                                  8          3     113042



$ expdp system directory=datapump dumpfile=aud.dump  tables=AUDSYS.AUD\$UNIFIED\:SYS_P181

Export: Release 19.0.0.0.0 - Production on Fri May 16 16:51:06 2025
Version 19.24.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
Password:

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Warning: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.

Starting "SYSTEM"."SYS_EXPORT_TABLE_01":  system/******** directory=datapump dumpfile=aud.dump tables=AUDSYS.AUD$UNIFIED:SYS_P181
ORA-39164: Partition AUDSYS.AUD$UNIFIED:SYS_P181 was not found.
ORA-39166: Object AUDSYS.AUD$UNIFIED was not found or could not be exported or imported.
ORA-31655: no data or metadata objects selected for job
Job "SYSTEM"."SYS_EXPORT_TABLE_01" completed with 3 error(s) at Fri May 16 16:51:20 2025 elapsed 0 00:00:03

尝试exp

exp system tables=AUDSYS.AUD\$UNIFIED file=aud.dmp

Export: Release 19.0.0.0.0 - Production on Fri May 16 17:01:45 2025
Version 19.24.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

Password:

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.24.0.0.0
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
Current user changed to AUDSYS
EXP-00064: AUD$UNIFIED is an inner nested table and cannot be exported.
Export terminated successfully with warnings.

正确的导出

$ expdp system directory=ORACLE_BASE dumpfile=aud.dump include=audit_trails

Export: Release 19.0.0.0.0 - Production on Fri May 16 16:43:40 2025
Version 19.24.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
Password:

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
ORA-39001: invalid argument value
ORA-39038: Object path "AUDIT_TRAILS" is not supported for SCHEMA jobs.

$ expdp system directory=ORACLE_BASE dumpfile=aud.dump include=audit_trails full=yes

Export: Release 19.0.0.0.0 - Production on Fri May 16 16:44:16 2025
Version 19.24.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
Password:

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Warning: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.

Starting "SYSTEM"."SYS_EXPORT_FULL_01":  system/******** directory=ORACLE_BASE dumpfile=aud.dump include=audit_trails full=yes
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE_DATA
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
Processing object type DATABASE_EXPORT/PRE_SYSTEM_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/PRE_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE
Processing object type DATABASE_EXPORT/EARLY_POST_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE
Processing object type DATABASE_EXPORT/NORMAL_POST_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/FINAL_POST_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/POST_SYSTEM_IMPCALLOUT/MARKER
. . exported "SYS"."KU$_USER_MAPPING_VIEW"               6.101 KB      38 rows
. . exported "AUDSYS"."AUD$UNIFIED":"SYS_P181"           131.2 KB     167 rows
. . exported "AUDSYS"."AUD$UNIFIED":"SYS_P3321"          56.99 KB      17 rows
. . exported "AUDSYS"."AUD$UNIFIED":"SYS_P1901"          56.38 KB      19 rows
. . exported "AUDSYS"."AUD$UNIFIED":"SYS_P4621"          55.69 KB      11 rows
. . exported "SYS"."DAM_CONFIG_PARAM$"                   6.531 KB      14 rows
. . exported "AUDSYS"."AUD$UNIFIED":"AUD_UNIFIED_P0"         0 KB       0 rows
. . exported "SYS"."AUD$"                                    0 KB       0 rows
. . exported "SYS"."DAM_CLEANUP_EVENTS$"                     0 KB       0 rows
. . exported "SYS"."DAM_CLEANUP_JOBS$"                       0 KB       0 rows
. . exported "SYS"."AUDTAB$TBS$FOR_EXPORT"               5.953 KB       2 rows
. . exported "SYS"."FGA_LOG$FOR_EXPORT"                      0 KB       0 rows
Master table "SYSTEM"."SYS_EXPORT_FULL_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_FULL_01 is:
  /data/app/oracle/aud.dump
Job "SYSTEM"."SYS_EXPORT_FULL_01" successfully completed at Fri May 16 16:45:39 2025 elapsed 0 00:01:06

Summary:

审计对象的导出需要使用include=audit_trails full=yes。

打赏

目前这篇文章还没有评论(Rss)

我要评论