분 단위로 수행되는 MVIEW가 서비스 되는 노드와는 반대의 노드에서 수행 하면서

GCS 가 대량으로 발생했고, 이로 인하여 active 세션마저 증가 하였다.

물론 refresh 완료 되고 스스로 풀리기는 했지만 이런 장애 상황을 방지 해 보자


-- 변경 전 JOB 확인

sql> col what for a60

sql> select job, log_user, what, instance

from dba_jobs

order by log_user, job;


       JOB LOG_USER                       WHAT                                                           INSTANCE

---------- ------------------------------ ------------------------------------------------------------ ----------

         2 AAAAAAAA                       dbms_refresh.refresh('"AAAAAAAA"."MST_PROD_INFO_VW"');                0

        21 AAAAAAAA                       dbms_refresh.refresh('"AAAAAAAA"."MST_PROD_VW"');                     0

         3 BBBBBBB                        dbms_refresh.refresh('"BBBBBBB"."PO2_GNR_SONG_CNT_VW"');              0



AAAAAAAA 는 node2 에서 서비스 하고, BBBBBBB 는 node1 에서 서비스 한다.


-- 해당 유저로 로그인

sql> conn AAAAAAAA/AAAAAAAA

Connected.


-- 인스턴스 변경

sql> exec dbms_job.instance(job=>2, instance=>2) ;


PL/SQL procedure successfully completed.


sql> exec dbms_job.instance(job=>21, instance=>2) ;


PL/SQL procedure successfully completed.


sql> commit;


Commit complete.


sql> conn BBBBBBB/BBBBBBB

Connected.


sql> exec dbms_job.instance(job=>3, instance=>1) ;


PL/SQL procedure successfully completed.


-- 변경 후 JOB 확인

sql> select job, log_user, what, instance

from dba_jobs

order by log_user, job;


       JOB LOG_USER                       WHAT                                                           INSTANCE

---------- ------------------------------ ------------------------------------------------------------ ----------

         2 AAAAAAAA                       dbms_refresh.refresh('"AAAAAAAA"."MST_PROD_INFO_VW"');                2

        21 AAAAAAAA                       dbms_refresh.refresh('"AAAAAAAA"."MST_PROD_VW"');                     2

         3 BBBBBBB                        dbms_refresh.refresh('"BBBBBBB"."PO2_GNR_SONG_CNT_VW"');              1


instance 가 '0' 이면 상대적으로 리소스 여유가 있는 node 에서 수행, '0'이 아니면 해당 노드에서 수행 된다.

'OraclE' 카테고리의 다른 글

DATAPUMP 암호화  (0) 2017.01.19
ORACLE 12c UNIFIED AUDIT 사용  (0) 2016.07.13
Auditing Enhancements (aud$ 테이블 관리)  (0) 2016.04.11
dbms_scheduler 변경  (2) 2016.01.04
flashback  (0) 2015.04.27

11g 들어 오면서 기본으로 audit 테이블이 활성화 되는 듯 하다.

audit$ 테이블 때문에 SYSAUX 의 사이즈가 커질텐데, 기본적으로 purge 하는 방법이 있고,
11g R2 부터 DBMS_AUDIT_MGMT 패키지를 통해서 간단하게 관리 할 수 있다.
자세한 내용은 아래 확인!!


[참고] https://oracle-base.com/articles/11g/auditing-enhancements-11gr2

Auditing Enhancements (DBMS_AUDIT_MGMT) in Oracle Database 11g Release 2

Oracle 11g Release 1 turned on auditng by default for the first time. Oracle 11g Release 2 now allows better management of the audit trail using the DBMS_AUDIT_MGMT package.

 This package has also been backported to previous versions down to 10g Release 2. See Oracle Support Note 731908.1.

Related articles.

Moving the Database Audit Trail to a Different Tablespace

The SET_AUDIT_TRAIL_LOCATION procedure allows you to alter the location of the standard and/or fine-grained database audit trail. It does not currently allow the alteration of the OS audit trail, although the documentation suggests this may happen in future. The procedure accepts two parameters.

  • AUDIT_TRAIL_TYPE: They type of audit trail that is to be moved.
  • AUDIT_TRAIL_LOCATION_VALUE: The tablespace the audit trail tables should be moved to.

The AUDIT_TRAIL_TYPE parameter is specified using one of three constants.

  • DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD: Standard audit trail (AUD$).
  • DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD: Fine-grained audit trail (FGA_LOG$).
  • DBMS_AUDIT_MGMT.AUDIT_TRAIL_DB_STD: Both standard and fine-grained audit trails.

Let's see this in action. First check the current location of the audit trail tables.

CONN / AS SYSDBA

SELECT table_name, tablespace_name
FROM   dba_tables
WHERE  table_name IN ('AUD$', 'FGA_LOG$')
ORDER BY table_name;

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
AUD$                           SYSTEM
FGA_LOG$                       SYSTEM

SQL>

Next, create a new tablespace to hold the audit trail.

CREATE TABLESPACE audit_aux
  DATAFILE '/u01/app/oracle/oradata/DB11G/audit_aux01.dbf'
  SIZE 1M AUTOEXTEND ON NEXT 1M;

Then we move the standard audit trail to the new tablespace.

BEGIN
  DBMS_AUDIT_MGMT.set_audit_trail_location(
    audit_trail_type           => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
    audit_trail_location_value => 'AUDIT_AUX');
END;
/

PL/SQL procedure successfully completed.

SQL>

-- Check locations.
SELECT table_name, tablespace_name
FROM   dba_tables
WHERE  table_name IN ('AUD$', 'FGA_LOG$')
ORDER BY table_name;

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
AUD$                           AUDIT_AUX
FGA_LOG$                       SYSTEM

SQL>

Next we move the fine-grained audit trail.

BEGIN
  DBMS_AUDIT_MGMT.set_audit_trail_location(
    audit_trail_type           => DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD,
    audit_trail_location_value => 'AUDIT_AUX');
END;
/

PL/SQL procedure successfully completed.

SQL>

-- Check locations.
SELECT table_name, tablespace_name
FROM   dba_tables
WHERE  table_name IN ('AUD$', 'FGA_LOG$')
ORDER BY table_name;

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
AUD$                           AUDIT_AUX
FGA_LOG$                       AUDIT_AUX

SQL>

Finally, we move them both back to their original location in a single step.

BEGIN
  DBMS_AUDIT_MGMT.set_audit_trail_location(
    audit_trail_type           => DBMS_AUDIT_MGMT.AUDIT_TRAIL_DB_STD,
    audit_trail_location_value => 'SYSTEM');
END;
/

PL/SQL procedure successfully completed.

SQL>

-- Check locations.
SELECT table_name, tablespace_name
FROM   dba_tables
WHERE  table_name IN ('AUD$', 'FGA_LOG$')
ORDER BY table_name;

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
AUD$                           SYSTEM
FGA_LOG$                       SYSTEM

SQL>

The AUDIT_AUX tablespace is no longer used so we can drop it.

DROP TABLESPACE audit_aux;

The time it takes to move the audit trail tables depends on the amount of data currently in the audit trail tables, and the resources available on your system.

Controlling the Size and Age of the OS Audit Trail

The SET_AUDIT_TRAIL_PROPERTY procedure allows you to set the maximum size and/or age of the OS audit trail files. The procedure can set parameters for several purposes, but I will restrict the discussion to only those relevant to this section. A full list of the constants available can be found here.

The procedure accepts three parameters.

  • AUDIT_TRAIL_TYPE: The type of audit trail to be modified (AUDIT_TRAIL_OSAUDIT_TRAIL_XML or AUDIT_TRAIL_FILES).
  • AUDIT_TRAIL_PROPERTY: The name of the property to be set (OS_FILE_MAX_SIZE or OS_FILE_MAX_AGE).
  • AUDIT_TRAIL_PROPERTY_VALUE: The required value for the property.

To check the current settings query the DBA_AUDIT_MGMT_CONFIG_PARAMS view.

COLUMN parameter_name FORMAT A30
COLUMN parameter_value FORMAT A20
COLUMN audit_trail FORMAT A20

SELECT *
FROM   dba_audit_mgmt_config_params
WHERE  parameter_name LIKE 'AUDIT FILE MAX%';

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
AUDIT FILE MAX SIZE            10000                OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                XML AUDIT TRAIL
AUDIT FILE MAX AGE             5                    OS AUDIT TRAIL
AUDIT FILE MAX AGE             5                    XML AUDIT TRAIL

SQL>

These defaults mean that OS and XML audit trail files will grow to a maximum of 10,000Kb, at which point a new file will be created. In addition, files older than 5 days will not be written to any more, even if they are below the maximum file size. Instead, a new file will be created and written to. Here are some examples of changing the settings.

-- Set the Maximum size of OS audit files to 15,000Kb.
BEGIN
  DBMS_AUDIT_MGMT.set_audit_trail_property(
    audit_trail_type           => DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS,
    audit_trail_property       => DBMS_AUDIT_MGMT.OS_FILE_MAX_SIZE,
    audit_trail_property_value => 15000);
END;
/

SELECT *
FROM   dba_audit_mgmt_config_params
WHERE  parameter_name LIKE 'AUDIT FILE MAX%';

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
AUDIT FILE MAX SIZE            15000                OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                XML AUDIT TRAIL
AUDIT FILE MAX AGE             5                    OS AUDIT TRAIL
AUDIT FILE MAX AGE             5                    XML AUDIT TRAIL

SQL>


-- Set the Maximum age of XML audit files to 10 days.
BEGIN
  DBMS_AUDIT_MGMT.set_audit_trail_property(
    audit_trail_type           => DBMS_AUDIT_MGMT.AUDIT_TRAIL_XML,
    audit_trail_property       => DBMS_AUDIT_MGMT.OS_FILE_MAX_AGE,
    audit_trail_property_value => 10);
END;
/

SELECT *
FROM   dba_audit_mgmt_config_params
WHERE  parameter_name LIKE 'AUDIT FILE MAX%';

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
AUDIT FILE MAX SIZE            15000                OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                XML AUDIT TRAIL
AUDIT FILE MAX AGE             5                    OS AUDIT TRAIL
AUDIT FILE MAX AGE             10                   XML AUDIT TRAIL

SQL>

The CLEAR_AUDIT_TRAIL_PROPERTY procedure can be used to remove the size and age restrictions, or reset them to the default values. Setting the USE_DEFAULT_VALUES parameter value to FALSE removes the restrictions, while setting it to TRUE returns the restriction to the default value.

-- Reset the max size default values for both OS and XML audit file.
BEGIN
  DBMS_AUDIT_MGMT.clear_audit_trail_property(
   audit_trail_type     => DBMS_AUDIT_MGMT.AUDIT_TRAIL_FILES,
   audit_trail_property => DBMS_AUDIT_MGMT.OS_FILE_MAX_SIZE,
   use_default_values   => TRUE );
END;
/

SELECT *
FROM   dba_audit_mgmt_config_params
WHERE  parameter_name LIKE 'AUDIT FILE MAX%';

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
AUDIT FILE MAX SIZE            10000                OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                XML AUDIT TRAIL
AUDIT FILE MAX AGE             5                    OS AUDIT TRAIL
AUDIT FILE MAX AGE             10                   XML AUDIT TRAIL

SQL>

-- Remove the max age restriction for both OS and XML audit file.
BEGIN
  DBMS_AUDIT_MGMT.clear_audit_trail_property(
   audit_trail_type     => DBMS_AUDIT_MGMT.AUDIT_TRAIL_FILES,
   audit_trail_property => DBMS_AUDIT_MGMT.OS_FILE_MAX_AGE,
   use_default_values   => FALSE );
END;
/

SELECT *
FROM   dba_audit_mgmt_config_params
WHERE  parameter_name LIKE 'AUDIT FILE MAX%';

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
AUDIT FILE MAX SIZE            10000                OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                XML AUDIT TRAIL
AUDIT FILE MAX AGE             NOT SET              OS AUDIT TRAIL
AUDIT FILE MAX AGE             NOT SET              XML AUDIT TRAIL

SQL>

-- Reset the max age default values for both OS and XML audit file.
BEGIN
  DBMS_AUDIT_MGMT.clear_audit_trail_property(
   audit_trail_type     => DBMS_AUDIT_MGMT.AUDIT_TRAIL_FILES,
   audit_trail_property => DBMS_AUDIT_MGMT.OS_FILE_MAX_AGE,
   use_default_values   => TRUE );
END;
/

SELECT *
FROM   dba_audit_mgmt_config_params
WHERE  parameter_name LIKE 'AUDIT FILE MAX%';

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
AUDIT FILE MAX SIZE            10000                OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                XML AUDIT TRAIL
AUDIT FILE MAX AGE             5                    OS AUDIT TRAIL
AUDIT FILE MAX AGE             5                    XML AUDIT TRAIL

SQL>

Purging Audit Trail Records

As with previous versions, you can manually delete records from the AUD$ and FGA_LOG$ tables and manually delete OS audit files from the file system, but DBMS_AUDIT_MGMT package gives you some new and safer mechanisms for maintaining the audit trail.

 If you are using Oracle Audit Vault, use that to manage your audit trail, not this functionality.

Initializing the Management Infrastructure

Before you can purge the database audit trail you must perform a one-time initialization of the audit management infrastructure. This is done using the INIT_CLEANUP procedure. The procedure accepts two parameters.

  • AUDIT_TRAIL_TYPE: The audit trail to be initialized (Constants).
  • DEFAULT_CLEANUP_INTERVAL: The default interval in hours, after which the cleanup procedure should be called again (1-999).

 The documentation seems to be incorrect about 2 points.

  1. It claims that initializing the database audit trails move the AUD$ and FGA_LOG$ tables from the SYSTEM tablespace to the SYSAUX tablespace, unless they have already been moved out of the SYSTEM tablespace. This doesn't seem to be the case as the example below will show. Even though it doesn't happen automatically, it makes sense to move the audit tables into the SYSAUX tablespace or their own dedicated tablespace. This is fixed from 11.2.0.2 onward.
  2. It claims it is not necessary to initialize the OS audit trails, yet in the example below you can clearly see the default cleanup intervals being set by the initialization process.

The following code checks the current parameter settings, initializes the audit management infrastructure for all audit trails with a default interval of 12 hours and rechecks the settings.

COLUMN parameter_name FORMAT A30
COLUMN parameter_value FORMAT A20
COLUMN audit_trail FORMAT A20

SELECT * FROM dba_audit_mgmt_config_params;

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
DB AUDIT TABLESPACE            SYSTEM               STANDARD AUDIT TRAIL
DB AUDIT TABLESPACE            SYSTEM               FGA AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                XML AUDIT TRAIL
AUDIT FILE MAX AGE             5                    OS AUDIT TRAIL
AUDIT FILE MAX AGE             5                    XML AUDIT TRAIL
DB AUDIT CLEAN BATCH SIZE      10000                STANDARD AUDIT TRAIL
DB AUDIT CLEAN BATCH SIZE      10000                FGA AUDIT TRAIL
OS FILE CLEAN BATCH SIZE       1000                 OS AUDIT TRAIL
OS FILE CLEAN BATCH SIZE       1000                 XML AUDIT TRAIL

SQL>

BEGIN
  DBMS_AUDIT_MGMT.init_cleanup(
    audit_trail_type         => DBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL,
    default_cleanup_interval => 12 /* hours */);
END;
/

PL/SQL procedure successfully completed.

SQL>

SELECT * FROM dba_audit_mgmt_config_params;

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
DB AUDIT TABLESPACE            SYSTEM               STANDARD AUDIT TRAIL
DB AUDIT TABLESPACE            SYSTEM               FGA AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                OS AUDIT TRAIL
AUDIT FILE MAX SIZE            10000                XML AUDIT TRAIL
AUDIT FILE MAX AGE             5                    OS AUDIT TRAIL
AUDIT FILE MAX AGE             5                    XML AUDIT TRAIL
DB AUDIT CLEAN BATCH SIZE      10000                STANDARD AUDIT TRAIL
DB AUDIT CLEAN BATCH SIZE      10000                FGA AUDIT TRAIL
OS FILE CLEAN BATCH SIZE       1000                 OS AUDIT TRAIL
OS FILE CLEAN BATCH SIZE       1000                 XML AUDIT TRAIL
DEFAULT CLEAN UP INTERVAL      12                   OS AUDIT TRAIL

PARAMETER_NAME                 PARAMETER_VALUE      AUDIT_TRAIL
------------------------------ -------------------- --------------------
DEFAULT CLEAN UP INTERVAL      12                   STANDARD AUDIT TRAIL
DEFAULT CLEAN UP INTERVAL      12                   FGA AUDIT TRAIL
DEFAULT CLEAN UP INTERVAL      12                   XML AUDIT TRAIL

Notice that the 'DB AUDIT TABLESPACE' for the database audit trails are unchanged and the 'DEFAULT CLEAN UP INTERVAL' for all four audit trails has been set.

The current initialization status of a specific audit trail can be checked using the IS_CLEANUP_INITIALIZED.

SET SERVEROUTPUT ON
BEGIN
  IF DBMS_AUDIT_MGMT.is_cleanup_initialized(DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD) THEN
    DBMS_OUTPUT.put_line('YES');
  ELSE
    DBMS_OUTPUT.put_line('NO');
  END IF;
END;
/
YES

PL/SQL procedure successfully completed.

SQL>

To deconfigure the audit management infrastructure run the DEINIT_CLEANUP procedure.

BEGIN
  DBMS_AUDIT_MGMT.deinit_cleanup(
    audit_trail_type         => DBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL);
END;
/

Timestamp Management

The next thing to consider before purging the audit trail is how much data you wish to purge. The DBMS_AUDIT_MGMT package allows us to purge all the records, or all the records older than a specific timestamp. The timestamp in question is specified individually for each audit trail using the SET_LAST_ARCHIVE_TIMESTAMP procedure, which accepts three parameters.

  • AUDIT_TRAIL_TYPE: The audit trail whose timestamp is to be set (Constants). Only individual audit trails are valid, not the constants that specify multiples.
  • LAST_ARCHIVE_TIME: Records or files older than this time will be deleted.
  • RAC_INSTANCE_NUMBER: Optionally specify the RAC node for OS audit trails. If unset it assumes the current instance.

The following code specifies a timestamp of 5 days ago for the standard database audit trail. The setting is then checked by querying the DBA_AUDIT_MGMT_LAST_ARCH_TS view.

BEGIN
  DBMS_AUDIT_MGMT.set_last_archive_timestamp(
    audit_trail_type  => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
    last_archive_time => SYSTIMESTAMP-5);
END;
/

COLUMN audit_trail FORMAT A20
COLUMN last_archive_ts FORMAT A40

SELECT * FROM dba_audit_mgmt_last_arch_ts;

AUDIT_TRAIL          RAC_INSTANCE LAST_ARCHIVE_TS
-------------------- ------------ ----------------------------------------
STANDARD AUDIT TRAIL            0 13-DEC-09 01.57.54.000000 PM +00:00

SQL>

The timestamps for each audit trail can be cleared to allow a complete purge using the CLEAR_LAST_ARCHIVE_TIMESTAMP procedure.

BEGIN
  DBMS_AUDIT_MGMT.clear_last_archive_timestamp(
    audit_trail_type     =>  DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD);
END;
/

Manual Purge

The CLEAN_AUDIT_TRAIL procedure is the basic mechanism for manually purging the audit trail. It accepts two parameters.

  • AUDIT_TRAIL_TYPE: The audit trail to be purged (Constants).
  • USE_LAST_ARCH_TIMESTAMP: Set to FALSE to purge all records/files, or TRUE to only purge records/files older than the timestamp specified for the audit trail.

The following code queries the last archive timestamp and total number of audit records, deletes standard database audit records older than the last archive timestamp, then returns the number of records again.

SELECT * FROM dba_audit_mgmt_last_arch_ts;

AUDIT_TRAIL          RAC_INSTANCE LAST_ARCHIVE_TS
-------------------- ------------ ----------------------------------------
STANDARD AUDIT TRAIL            0 13-DEC-09 01.57.54.000000 PM +00:00

SQL>

SELECT COUNT(*) FROM aud$;

  COUNT(*)
----------
      2438

SQL> 

BEGIN
  DBMS_AUDIT_MGMT.clean_audit_trail(
   audit_trail_type        => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
   use_last_arch_timestamp => TRUE);
END;
/

PL/SQL procedure successfully completed.

SELECT COUNT(*) FROM aud$;

  COUNT(*)
----------
        76

SQL>

Automated Purging

The CREATE_PURGE_JOB procedure allows you to schedule a job to call the CLEAN_AUDIT_TRAIL procedure. When creating a purge job you can specify 4 parameters.

  • AUDIT_TRAIL_TYPE: The audit trail to be purged by the scheduled job (Constants).
  • AUDIT_TRAIL_PURGE_INTERVAL: The interval in hours between purges.
  • AUDIT_TRAIL_PURGE_NAME: A name for the purge job.
  • USE_LAST_ARCH_TIMESTAMP: Set to FALSE to purge all records/files, or TRUE to only purge records/files older than the timestamp specified for the audit trail.

The following code schedules a purge of all audit trails every 24 hours. The resulting job is visible in the DBA_SCHEDULER_JOBS view.

BEGIN
  DBMS_AUDIT_MGMT.create_purge_job(
    audit_trail_type           => DBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL,
    audit_trail_purge_interval => 24 /* hours */,  
    audit_trail_purge_name     => 'PURGE_ALL_AUDIT_TRAILS',
    use_last_arch_timestamp    => TRUE);
END;
/

PL/SQL procedure successfully completed.

SQL>

SELECT job_action
FROM   dba_scheduler_jobs
WHERE  job_name = 'PURGE_ALL_AUDIT_TRAILS';

JOB_ACTION
--------------------------------------------------------------------------------
BEGIN DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL(15, TRUE);  END;

SQL>

The job can be disabled and enabled using the SET_PURGE_JOB_STATUS procedure.

BEGIN
  DBMS_AUDIT_MGMT.set_purge_job_status(
    audit_trail_purge_name   => 'PURGE_ALL_AUDIT_TRAILS',
    audit_trail_status_value => DBMS_AUDIT_MGMT.PURGE_JOB_DISABLE);

  DBMS_AUDIT_MGMT.set_purge_job_status(
    audit_trail_purge_name   => 'PURGE_ALL_AUDIT_TRAILS',
    audit_trail_status_value => DBMS_AUDIT_MGMT.PURGE_JOB_ENABLE);
END;
/

The interval of the purge job can be altered using the SET_PURGE_JOB_INTERVAL procedure.

BEGIN
  DBMS_AUDIT_MGMT.SET_PURGE_JOB_INTERVAL(
    audit_trail_purge_name     => 'PURGE_ALL_AUDIT_TRAILS',
    audit_trail_interval_value => 48);
END;
/

Purge jobs are removed using the DROP_PURGE_JOB procedure.

BEGIN
  DBMS_AUDIT_MGMT.drop_purge_job(
     audit_trail_purge_name     => 'PURGE_ALL_AUDIT_TRAILS');
END;
/

There are two things to note about the automated functionality.

  1. If purge jobs use the last archived timestamp and you do not manually move this timestamp forward, the job will run and have nothing to purge. You should reset the timestamp usingDBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP when you have made an archive of the audit information, that way your audit information is secure and the job can purge the excess data.
  2. The purge job functionality is simply a wrapper over the DBMS_SCHEDULER package to make automating purge jobs easier.

If you want the purge job to maintain an audit trail of a specific number of days, the easiest way to accomplish this is to define a job to set the last archive time automatically. The following job resets the last archive time on a daily basis, keeping the last archive time 90 days in the past.

BEGIN
  DBMS_SCHEDULER.create_job (
    job_name        => 'audit_last_archive_time',
    job_type        => 'PLSQL_BLOCK',
    job_action      => 'BEGIN 
                          DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD, TRUNC(SYSTIMESTAMP)-90);
                          DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD, TRUNC(SYSTIMESTAMP)-90);
                          DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS, TRUNC(SYSTIMESTAMP)-90);
                          DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(DBMS_AUDIT_MGMT.AUDIT_TRAIL_XML, TRUNC(SYSTIMESTAMP)-90);
                        END;',
    start_date      => SYSTIMESTAMP,
    repeat_interval => 'freq=daily; byhour=0; byminute=0; bysecond=0;',
    end_date        => NULL,
    enabled         => TRUE,
    comments        => 'Automatically set audit last archive time.');
END;
/

For more information see:

Hope this helps. Regards Tim...

'OraclE' 카테고리의 다른 글

ORACLE 12c UNIFIED AUDIT 사용  (0) 2016.07.13
RAC 원하는 노드에서 mview refresh 수행  (0) 2016.04.11
dbms_scheduler 변경  (2) 2016.01.04
flashback  (0) 2015.04.27
append 힌트 재대로 사용하시나요?  (0) 2015.03.30

OS : Oracle Linux Server release 6.5

ORACLE : Oracle Database 11g Enterprise Edition Release 11.2.0.4.0



-- 기존 경로 정보 확인

# oracleasm querydisk -p VOL1

Disk "VOL1" is a valid ASM disk

/dev/mapper/vgora04-lvora04: LABEL="VOL1" TYPE="oracleasm" 



-- asm disk 만들기

# oracleasm createdisk VOL6 /dev/mapper/vgora06-lvora06

# oracleasm createdisk VOL7 /dev/mapper/vgora07-lvora07

# oracleasm createdisk VOL8 /dev/mapper/vgora08-lvora08



-- asm disk 조회

SQL> select group_number, disk_number, name, mount_status, path, total_mb

from v$asm_disk

order by path;


GROUP_NUMBER DISK_NUMBER NAME                 MOUNT_S PATH                             TOTAL_MB

------------ ----------- -------------------- ------- ------------------------------ ----------

           1           0 VOL1                 CACHED  ORCL:VOL1                         1048568

           1           1 VOL2                 CACHED  ORCL:VOL2                         1048568

           1           2 VOL3                 CACHED  ORCL:VOL3                         1048568

           1           3 VOL4                 CACHED  ORCL:VOL4                         1048568

           1           4 VOL5                 CACHED  ORCL:VOL5                         1048568

           0           0                      CLOSED  ORCL:VOL6                               0

           0           1                      CLOSED  ORCL:VOL7                               0

           0           2                      CLOSED  ORCL:VOL8                               0


8 rows selected.



-- asm disk 를 그룹에 추가

$ sqlplus "/as sysadm"


SQL> select NAME, COMPATIBILITY from v$asm_diskgroup;


NAME                 COMPATIBILITY

-------------------- ------------------------------

DATA                 11.2.0.0.0


※ rebalance power 설정시 COMPATIBLE.ASM disk group attribute가 11.2.0.2 이상은 0~1024, 11.2.0.1 이하는 0~11로 설정한다.

SQL> alter diskgroup DATA add disk 'ORCL:VOL6','ORCL:VOL7','ORCL:VOL8' rebalance power 11;



SQL> select group_number, disk_number, name, mount_status, path, total_mb

from v$asm_disk

order by path;


GROUP_NUMBER DISK_NUMBER NAME                 MOUNT_S PATH                             TOTAL_MB

------------ ----------- -------------------- ------- ------------------------------ ----------

           1           0 VOL1                 CACHED  ORCL:VOL1                         1048568

           1           1 VOL2                 CACHED  ORCL:VOL2                         1048568

           1           2 VOL3                 CACHED  ORCL:VOL3                         1048568

           1           3 VOL4                 CACHED  ORCL:VOL4                         1048568

           1           4 VOL5                 CACHED  ORCL:VOL5                         1048568

           1           5 VOL6                 CACHED  ORCL:VOL6                         1023992

           1           6 VOL7                 CACHED  ORCL:VOL7                         1023992

           1           7 VOL8                 CACHED  ORCL:VOL8                         1023984


8 rows selected.



SQL> select d.name, o.operation, o.state, o.power, o.est_minutes

from v$asm_disk d, v$asm_operation o

where d.group_number=o.group_number

order by 1;


NAME                           OPERA STAT      POWER EST_MINUTES

------------------------------ ----- ---- ---------- -----------

VOL1                           REBAL RUN          11         112

VOL2                           REBAL RUN          11         112

VOL3                           REBAL RUN          11         112

VOL4                           REBAL RUN          11         112

VOL5                           REBAL RUN          11         112

VOL6                           REBAL RUN          11         112

VOL7                           REBAL RUN          11         112

VOL8                           REBAL RUN          11         112


8 rows selected.



-- 거의 완료 된 상태에서 파워 변경 11->8

SQL> alter diskgroup DATA rebalance power 8;



SQL> select d.name, o.operation, o.state, o.power, o.est_minutes

from v$asm_disk d, v$asm_operation o

where d.group_number=o.group_number

order by 1; 


NAME                           OPERA STAT      POWER EST_MINUTES

------------------------------ ----- ---- ---------- -----------

VOL1                           REBAL RUN           8           8

VOL2                           REBAL RUN           8           8

VOL3                           REBAL RUN           8           8

VOL4                           REBAL RUN           8           8

VOL5                           REBAL RUN           8           8

VOL6                           REBAL RUN           8           8

VOL7                           REBAL RUN           8           8

VOL8                           REBAL RUN           8           8


8 rows selected.


완료시 위 결과가 아무것도 안나옴.


-- 4.7TB/5TB 에 3TB 추가시 약 150분 소요 (transaction 없음)


'OraclE > ASM' 카테고리의 다른 글

ASM DISK 추가 하기 2  (0) 2017.04.21

dbms_scheduler 변경 방법



-- window check

select window_name, repeat_interval,duration,ENABLED ,NEXT_START_DATE

from dba_scheduler_windows;


-- clients check

select window_name, window_next_time, autotask_status, OPTIMIZER_STATS, SEGMENT_ADVISOR, SQL_TUNE_ADVISOR

from dba_autotask_window_clients;




윈도우 수정은 다음 단계로 진행 한다.


-- 수행중인 윈도우 종료

exec dbms_scheduler.close_window('MONDAY_WINDOW');


-- 비 활성화

exec dbms_scheduler.disable('MONDAY_WINDOW');


-- 속성 변경(수행주기)

exec dbms_scheduler.set_attribute(name => 'MONDAY_WINDOW', attribute => 'REPEAT_INTERVAL', value =>'freq=daily;byday=MON;byhour=2;byminute=0; bysecond=0');


-- 속성 변경(수행시간)

exec dbms_scheduler.set_attribute(name => 'MONDAY_WINDOW', attribute => 'DURATION', value => '+000 05:00:00');


-- 활성화

exec dbms_scheduler.enable('MONDAY_WINDOW');

'OraclE' 카테고리의 다른 글

RAC 원하는 노드에서 mview refresh 수행  (0) 2016.04.11
Auditing Enhancements (aud$ 테이블 관리)  (0) 2016.04.11
flashback  (0) 2015.04.27
append 힌트 재대로 사용하시나요?  (0) 2015.03.30
object 변경시 dependency  (0) 2015.01.06

+ Recent posts