|
LOGMINER ÀÇ ±â´É°ú »ç¿ë ¹æ¹ý
## °£´ÜÇÑ ¼³¸í
1. on Oracle 8.1.5
SVRMGRL> connect internal;
SVRMGRL> @?/rdbms/admin/dbmslogmnrd.sql
2. on Oracle 8.1.6 and 8.1.7 , Oracle9i
SVRMGRL> connect internal;
SVRMGRL> @?/rdbms/admin/dbmslm.sql
...
SVRMGRL> @?/rdbms/admin/dbmslmd.sql
3. dictionary fileÀÌ »ý¼ºµÉ À§Ä¡¸¦ parameter file¿¡ ÁöÁ¤
utl_file_dir='/hoem/oracle/logs'
4. sqlplus¸¦ »ç¿ëÇÏ¿© ºÐ¼® ´ë»óÀÌ µÇ´Â database¸¦ open
SQL> startup
----------- »õ·Î¿î ·Î±×ºÐ¼®À» ½ÃÀÛÇÒ¶§ ¿©±âºÎÅÍ ---------------
5. DBMS_LOGMNR_D.BUILD¸¦ »ç¿ëÇÏ¿© dictionary file»ý¼º
SQL> exec dbms_logmnr_d.build('dir_file','/home/oracle/logs');
* ¹Ýµå½Ã transactionÀÇ Ã³À½ ¹®ÀåÀ̾î¾ß ÇÑ´Ù.
6. redo logfile È®ÀÎ
SQL> select member from v$logfile;
7. 1(NEW) parameter¸¦ »ç¿ëÇÏ¿© ºÐ¼®ÇÒ logÀÇ list¸¦ »ý¼º
SQL> exec dbms_logmnr.add_logfile('/db/oracle/oradata/ORA9i/redo01.log',1);
8. log ¸®½ºÆ®¿¡ ÷°¡ Çϰųª »èÁ¦µîÀ» ½ÃÇà
ADD : SQL> exec dbms_logmnr.add_logfile('/db/oracle/oradata/ORA9i/redo02.log',3);
REMOVE : SQL> exec dbms_logmnr.add_logfile('/db/oracle/oradata/ORA9i/redo02.log',2);
9. dbms_logmnr.start_logmnrÀ» ½ÇÇàÇÑ´Ù.
SQL> execute dbms_logmnr.start_logmnr(
> dictfilename => '/home/oracle/logs/dir_file',
> starttime => to_date('2005051 10:37:44','YYYYMMDD HH24:MI:SS'),
> endtime => to_date('20050501 10:39:20','YYYYMMDD HH24:MI:SS'))
- StartSCN (default 0) / EndSCN (0) / StartTime (01-JAN-1988)
/ EndTime (01-JAN-2988) / DictFileName (Null) / Options (0)
** DictFileNameÀº null stringÀÌ ±âº»°ªÀ̹ǷΠ»ý¼ºÇÏ¿´´Ù¸é ¹Ýµå½Ã ÁöÁ¤ÇÑ´Ù.
10. V$LOGMNR_CONTENTS¸¦ Á¶È¸.
SQL> select operation, sql_redo, sql_undo
2 from v$logmnr_contents
3 where
4 seg_name='TEST' and operation='INSERT'
- column Á¤º¸
SCN
TIMESTAMP
SEG_OWNER
SEG_NAME
SEG_TYPE_NAME
USERNAME
SESSION_INFO
OPERATION : INSERT,DELETE...
SQL_REDO
SQL_UNDO
11. LogMiner¸¦ Á¾·á.
SQL> call dbms_logmnr.end_logmnr();
## LogMiner °³¿ä
1. transaction º°, »ç¿ëÀÚ º°, Å×ÀÌºí º°, ½Ã°£´ë º°·Î database¿¡ °¡ÇØÁø
º¯°æ »çÇ׿¡ ´ëÇÑ ÃßÀû
2. Tuning°ú capacity °èȹÀ» ¼ö¸³Çϱâ À§ÇÑ º¸Á¶ ÀÚ·á·Î¼ »ç¿ëµÉ ¼ö ÀÖ´Ù.
´Ù¾çÇÑ ÇüÅÂÀÇ ½Ã°£Àû ÃßÀÌ¿¡ µû¸¥ ¼ºÇâ°ú ÀÚ·áÀÇ ÆÐÅÏ ºÐ¼®ÀÌ °¡´ÉÇÏ´Ù.
3. ¾ðÁ¦ ³í¸®ÀûÀÎ º¯Á¶°¡ ¹ß»ýÇß´ÂÁö¸¦ °áÁ¤ÇÏ°í, ±×°Í¿¡ ´ëÇÑ º¹±¸ ÀÛ¾÷
(Incomplete recovery)À» ¼öÇàÇϱâ À§ÇØ ÇÊ¿äÇÑ SCN(system change number)³ª
½Ã°£ Á¤º¸¸¦ Á¦°øÇÑ´Ù.
## Á¦¾à »çÇ×
- oracle8i ÀÌ»ó.
- ºÐ¼®ÇÏ´Â instance¿Í °°Àº H/W platform¿¡¼ µ¿ÀÛÇÏ´Â °°Àº character setÀ»
»ç¿ëÇÏ´Â 8.0 À̻󿡼 »ý¼ºµÈ redo log fileÀ» ó¸®.
- pl/sql package¿¡ ÀÇÇØ »ý¼ºµÈ dicrionaryÀÇ µµ¿òÀ» ÅëÇؼ¸¸ redo log
fileÀÇ ³»¿ëÀ» ºÐ¼®.
- ÀÏ¹Ý table¿¡ Àû¿ëµÇ´Â DML¿¡ ´ëÇÑ Á¤º¸¸¸ ¾ò¾î³¾ ¼ö ÀÖ´Ù. Áï, ´ÙÀ½°ú °°Àº
table¿¡ ´ëÇؼ´Â Áö¿øÇÏÁö ¾Ê´Â´Ù.
** Áö¿øÀÌ µÇÁö ¾Ê´Â °æ¿ì view¿¡ "Unsupported"¶ó´Â ÀÚ·á·Î ÅëÁöµÈ´Ù. **
1. Index-Organized Table (IOT)
2. Clustered table / index
3. Non-scalar data type - varray / nested table°ú Object typeÁ¦¿Ü
4. Chained rows
- Rollback, Commit, Begin Transaction µîÀÇ ¸í·É¾î´Â Áö¿øÇÑ´Ù.
## Logminer »ç¿ëÇϱâ
# Step 0. Package file ½ÇÇà
1. on Oracle 8.1.5
SVRMGRL> connect internal;
SVRMGRL> @?/rdbms/admin/dbmslogmnrd.sql
2. on Oracle 8.1.6 and 8.1.7 , Oracle9i
SVRMGRL> connect internal;
SVRMGRL> @?/rdbms/admin/dbmslm.sql
...
SVRMGRL> @?/rdbms/admin/dbmslmd.sql
# Step 1. Dictionary file »ý¼º
- Logminer´Â database°¡ mount/unmount »óÅ¿¡ »ó°ü¾øÀÌ ¼öÇàÇÒ ¼ö ÀÖ´Ù
- umount¿¡¼µµ »ç¿ë °¡´ÉÇϱ⠶§¹®¿¡ dictionary Á¤º¸¸¦ µû·Î ÆÄÀÏ·Î °ü¸®Çϴµ¥
±×·¯±â À§Çؼ´Â ºÐ¼® ´ë»óÀÌ µÇ´Â redo log fileÀ» »ý¼ºÇÑ
database¸¦ mountÇÏ°í dictionary fileÀ» »ý¼ºÇØ¾ß ÇÑ´Ù
- LogMiner´Â dictionary fileÀ» »ç¿ëÇϴµ¥ ±× ³»¿ë¹°·ÎºÎÅÍ ±× fileÀ»
»ý¼ºÇÑ database¿Í ±× fileÀÌ »ý¼ºµÈ ½Ã°£À» ¾Ë ¼ö ÀÖ´Ù.
- dictionary fileÀÌ ¾øÀ» °æ¿ì, °á°ú·Î ³ªÅ¸³ sql ¹®Àå¿¡¼ object
À̸§¿¡ ÇØ´çÇÏ´Â object ID¿Í columnÀÌ hexa µ¥ÀÌŸ·Î Ç¥½ÃµÈ´Ù.
1. dictionary fileÀÌ »ý¼ºµÉ À§Ä¡¸¦ parameter file¿¡ ÁöÁ¤
utl_file_dir='/hoem/oracle/logs'
2. sqlplus¸¦ »ç¿ëÇÏ¿© ºÐ¼® ´ë»óÀÌ µÇ´Â database¸¦ open
SQL> startup
3. DBMS_LOGMNR_D.BUILD¸¦ »ç¿ëÇÏ¿© dictionary file»ý¼º
SQL> exec dbms_logmnr_d.build('dir_file','/home/oracle/logs');
* ¹Ýµå½Ã transactionÀÇ Ã³À½ ¹®ÀåÀ̾î¾ß ÇÑ´Ù.
* »õ·Î¿î ·Î±×ºÐ¼®À» ½ÃÀÛÇÒ¶§´Â 3¹ø °úÁ¤ºÎÅÍ ½ÃÀÛÇÑ´Ù.
# Step 2. ºÐ¼®À» À§ÇÑ Redo log ÁöÁ¤Çϱâ
1. redo logfile È®ÀÎ
SQL> select member from v$logfile;
MEMBER
------------------------------------
/db/oracle/oradata/ORA9i/redo03.log
/db/oracle/oradata/ORA9i/redo02.log
/db/oracle/oradata/ORA9i/redo01.log
2. 1(NEW) parameter¸¦ »ç¿ëÇÏ¿© ºÐ¼®ÇÒ logÀÇ list¸¦ »ý¼º
SQL> exec dbms_logmnr.add_logfile('/db/oracle/oradata/ORA9i/redo01.log',1);
3. log ¸®½ºÆ®¿¡ ÷°¡ Çϰųª »èÁ¦µîÀ» ½ÃÇà
SQL> exec dbms_logmnr.add_logfile('/db/oracle/oradata/ORA9i/redo02.log',3);
SQL> exec dbms_logmnr.add_logfile('/db/oracle/oradata/ORA9i/redo02.log',2);
- NEW : 1
- ADDFILE : 3
- REMOVEFILE : 2
* default´Â ADDFILE
# Step 3. LogMiner »ç¿ëÇϱâ
1. Logminer¿Í °ü·ÃµÈ view
- V$LOGMNR_DICTIONARY : »ç¿ëÁßÀÎ dictionary file
- V$LOGMNR_PARAMETERS : LogMiner¿¡ SettingµÈ ÇöÀçÀÇ parameterÀÇ °ª
- V$LOGMNR_LOGS : ºÐ¼®µÇ°í ÀÖ´Â redo log file
- V$LOGMNR_CONTENTS : ÇöÀç ºÐ¼®µÇ°í ÀÖ´Â redo log fileÀÇ ³»¿ë
2. dbms_logmnr.start_logmnrÀ» ½ÇÇàÇÑ´Ù.
SQL> execute dbms_logmnr.start_logmnr(
> dictfilename => '/home/oracle/logs/dir_file',
> starttime => to_date('2005051 10:37:44','YYYYMMDD HH24:MI:SS'),
> endtime => to_date('20050501 10:39:20','YYYYMMDD HH24:MI:SS'))
or
SQL> execute dbms_logmnr.start_logmnr(DictFileName=>'/home/oracle/logs/dir_file');
or
SQL> execute dbms_logmnr.start_logmnr(DictFileName=>'/home/oracle/logs/dir_file',
StartSCN=>100, EndSCN=>150);
* StartSCN (default 0) / EndSCN (0) / StartTime (01-JAN-1988)
/ EndTime (01-JAN-2988) / DictFileName (Null) / Options (0)
DictFileNameÀº null stringÀÌ ±âº»°ªÀ̹ǷΠ»ý¼ºÇÏ¿´´Ù¸é ¹Ýµå½Ã ÁöÁ¤ÇÑ´Ù.
3. V$LOGMNR_CONTENTS¸¦ Á¶È¸.
SQL> select operation, sql_redo, sql_undo
2 from v$logmnr_contents
3 where
4 seg_name='TEST' and operation='INSERT'
- column Á¤º¸
SCN
TIMESTAMP
SEG_OWNER
SEG_NAME
SEG_TYPE_NAME
USERNAME
SESSION_INFO
OPERATION
SQL_REDO
SQL_UNDO
SEQUENCE#
INFO
STATUS
4. LogMiner¸¦ Á¾·á.
SQL> call dbms_logmnr.end_logmnr();
## ±âŸ ÆÁ
# ´Ù¸¥ Database·ÎºÎÅÍ »ý¼ºµÈ archive redo log file ºÐ¼®
ÇöÀç logminer¸¦ ¿î¿µÇÏ´Â Database¸¦ LogmnrDB¶ó°í ÇÏ°í ´ë»ó database¸¦ SourceDB¶ó°í Çϸé
1. Á¦¾à»çÇ×
- LogmnrDB´Â SourceDB¿Í µ¿ÀÏÇÑ character set
- SourceDB¿¡¼ »ý¼ºµÈ dictionary fileÀ» »ç¿ë
- LogMiner ¸¦ ½ÇÇàÇÏ´Â system Àº ºÐ¼® ´ë»ó database °¡ ½Ç¸° systemÀÏ ÇÊ¿ä´Â ¾øÁö¸¸
hardware platform À̾î¾ß ÇÑ´Ù.
- Oracle8.0 À̻󿡼 »ý¼ºµÈ redo log file À» »ç¿ë.
# Oracle8ÀÇ log fileºÐ¼®
1. Oracle8i¿¡¼ dbmslogmnrd.sql(8.1.5) ¶Ç´Â dbmslmd.sql file copy
2. copyÇÑ ÈÀÏÀ» ´ÙÀ½°ú °°ÀÌ ½ÇÇà.
SVRMGRL> connect internal;
SVRMGRL> @dbmslogmnrd.sql
or
SVRMGRL> @dbmslmd.sql
3. utl_file_dir parameter¼³Á¤.
4. dbms_logmnr_d package¸¦ ÀÌ¿ëÇÏ¿© dictionary fileÀ» »ý¼º.
SQL> connect sys/manager
SQL> exec dbms_logmnr_d.build('dir_file','/home2/o8ii/logs');
5. »ý¼ºÇÑ dictionary file°ú ºÐ¼®ÇÏ°íÀÚ ÇÏ´Â archiving fileÀ»
oracle8i db·Î copyÇÑ ÈÄ¿¡ logminer¸¦ ½ÇÇà.
# 9I New feature
1) DDL Áö¿ø ´Ü, 9I ÀÌ»óÀÇ Redo/Archive log file¸¸ ºÐ¼® °¡´É
: V$LOGMNR_CONTENTS ÀÇ OPERATION column¿¡¼ DDL È®ÀÎ
2) LogMiner ºÐ¼®À» À§ÇØ »ý¼ºÇÑ dictioanry Á¤º¸¸¦ online redo ¿¡ ÀúÀå °¡´É
: ¹Ýµå½Ã Archive log mode ·Î ¿î¿µ ÁßÀ̾î¾ß ÇÑ´Ù.
: DBMS_LOGMNR_D.BUILD¸¦ »ç¿ëÇÏ¿© dictionary file »ý¼º
: ±âÁ¸ Flat file ¶Ç´Â Redo log ¿¡ »ý¼º °¡´É
: ¿¹) Flat file
- SQL> EXECUTE dbms_logmnr_d.build
(DICTIONARY_FILENAME => 'dictionary.ora'
,DICTIONARY_LOCATION => '/oracle/database'
,OPTIONS => DBMS_LOGMNR_D.STORE_IN_FLAT_FILE);
¿¹) Redo log
- SQL> EXECUTE dbms_logmnr_d.build
(OPTIONS => DBMS_LOGMNR_D.STORE_IN_REDO_LOGS);
3) Redo log block corruption ÀÌ ¹ß»ýÇÏ¿´À» °æ¿ì corruption µÈ ºÎºÐÀ» skipÇÏ°í ºÐ¼®
: 8I ¿¡¼ log corruption ¹ß»ý ½Ã LogMiner °¡ Á¾·áµÇ°í ºÐ¼® À§ÇØ ´Ù½Ã ½Ãµµ
: 9I ¿¡¼´Â DBMS_LOGMNR.START_LOGMNR ÀÇ SKIP_CORRUPTION option À¸·Î skip °¡´É
4) Commit µÈ transaction ¿¡ ´ëÇؼ¸¸ display
: DBMS_LOGMNR.START_LOGMNR ÀÇ COMMITTED_DATA_ONLY option
5) Index clustered ¿Í ¿¬°üµÈ DML Áö¿ø (8I Á¦°ø ¾È µÊ)
6) Chained and Migrated rows ºÐ¼®
2. Á¦¾à »çÇ×(9I LogMiner ¿¡¼ Áö¿øÇÏÁö ¾Ê´Â »çÇ×)
1) LONG and LOB data type
2) Object types
3) Nested tables
4) Object Refs
5) IOT(Index-Organized Table)
3. LogMiner Views
1) V$LOGMNR_CONTENTS - ÇöÀç ºÐ¼®µÇ°í ÀÖ´Â redo log fileÀÇ ³»¿ë
2) V$LOGMNR_DICTIONARY - »ç¿ë ÁßÀÎ dictionary file
3) V$LOGMNR_LOGS - ºÐ¼®µÇ°í ÀÖ´Â redo log file
4) V$LOGMNR_PARAMETERS - LogMiner¿¡ SettingµÈ ÇöÀçÀÇ parameterÀÇ °ª
4. LogMiner ¸¦ ÀÌ¿ëÇϱâ À§ÇÑ Setup
1) LogMiner ¸¦ À§ÇÑ dictionary »ý¼º(flatfile or on line redo log)
2) Archive log file or Redo log file µî·Ï
3) Redo log ºÐ¼® ½ÃÀÛ
4) Redo log ³»¿ë Á¶È¸
5) LogMiner Á¾·á
5. LogMiner Example
1) flatfileÀÌ »ý¼ºµÉ locationÀ» È®ÀÎ
SQL> show parameter utl
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
utl_file_dir string /home/ora920/product/9.2.0/smlee
2) dictionary Á¤º¸¸¦ ÀúÀåÇÒ flatfile Á¤ÀÇ -> dictionary.ora ·Î ÁöÁ¤
SQL> execute dbms_logmnr_d.build -
> (dictionary_filename => 'dictionary.ora', -
> dictionary_location => '/home/ora920/product/9.2.0/smlee', -
> options => dbms_logmnr_d.store_in_flat_file);
PL/SQL procedure successfully completed.
3) logfileÀ» switch ÇÏ°í current logfile name°ú current timeÀ» ±â¾ïÇÑ´Ù.
SQL> alter system switch logfile;
System altered.
SQL> select member from v$logfile, v$log
2 where v$logfile.group# = v$log.group#
3 and v$log.status='CURRENT';
MEMBER
----------------------------------------------------------------------
----------
/home/ora920/oradata/ORA920/redo02.log
SQL> select current_timestamp from dual;
CURRENT_TIMESTAMP
----------------------------------------------------------------------
-----
13-NOV-02 10.37.14.887671 AM +09:00
4) test¸¦ À§ÇØ table emp30 À» »ý¼ºÇÏ°í update -> drop ¼öÇà
SQL> create table emp30 as
2 select employee_id, last_name, salary from hr.employees
3 where department_id=30;
Table created.
SQL> alter table emp30 add (new_salary number(8,2));
Table altered.
SQL> update emp30 set new_salary = salary * 1.5;
6 rows updated.
SQL> rollback;
Rollback complete.
SQL> update emp30 set new_salary = salary * 1.2;
6 rows updated.
SQL> commit;
Commit complete.
SQL> drop table emp30;
select
Table dropped.
SQL> select current_timestamp from dual;
CURRENT_TIMESTAMP
----------------------------------------------------------------------
-----
13-NOV-02 10.39.20.390685 AM +09:00
5) logminer start (´Ù¸¥ sessionÀ» ¿¾î ÀÛ¾÷)
SQL> connect /as sysdba
Connected.
SQL> execute dbms_logmnr.add_logfile ( -
> logfilename => -
> '/home/ora920/oradata/ORA920/redo02.log', -
> options => dbms_logmnr.new)
PL/SQL procedure successfully completed.
SQL> execute dbms_logmnr.start_logmnr( -
> dictfilename => '/home/ora920/product/9.2.0/smlee/dictionary.ora', -
> starttime => to_date('13-NOV-02 10:37:44','DD_MON_RR HH24:MI:SS'), -
> endtime => to_date('13-NOV-02 10:39:20','DD_MON_RR HH24:MI:SS'), -
> options => dbms_logmnr.ddl_dict_tracking + dbms_logmnr.committed_data_only)
PL/SQL procedure successfully completed.
6) v$logmnr_contents view¸¦ Á¶È¸
SQL> select timestamp, username, operation, sql_redo
2 from v$logmnr_contents
3 where username='HR'
4 and (seg_name = 'EMP30' or seg_name is null);
TIMESTAMP USERNAME OPERATION SQL_REDO
----------------------------------------------------------------------
------------------------------------
13-NOV-02 10:38:20 HR START set transaction read write;
13-NOV-02 10:38:20 HR DDL CREATE TABLE emp30 AS
SELECT EMPLOYEE_ID, LAST_NAME,
SALARY FROM HR.EMPLOYEES
WHERE DEPARTMENT_ID=30;
13-NOV-02 10:38:20 HR COMMIT
commit;
13-NOV-02 10:38:50 HR DDL ALTER TABLE emp30 ADD
(new_salary NUMBER(8,2));
13-NOV-02 10:39:02 HR UPDATE UPDATE "HR"."EMP30" set
"NEW_SALARY" = '16500' WHERE
"NEW_SALARY" IS NULL AND ROWID
='AAABnFAAEAALkUAAA';
13-NOV-02 10:39:02-10 HR DDL DROP TABLE emp30;
7) logminer ¸¦ Á¾·áÇÑ´Ù.
SQL> execute dbms_logmnr.end_logmnr
PL/SQL procedure successfully completed.
## 10G New feature
1. LogMiner in a Shared Server Environment
±âÁ¸¿¡´Â Dedicated mode¿¡¼¸¸ logminer½ÇÇàÀÌ °¡´ÉÇßÀ¸³ª Oracle10g ¿¡¼´Â
MTS ȯ°æ¿¡¼µµ logminerÀÇ ½ÇÇàÀÌ °¡´ÉÇÏ´Ù.
2. Support for Index Organized Tables
Logminer ´Â IOT ¿¡ ´ëÇؼµµ Logminer¸¦ ÅëÇؼ Á¤È®ÇÑ record º¯È¸¦ ãÀ» ¼ö
ÀÖ´Ù. Oracle9i ±îÁö´Â Logminer¿¡¼ IOT ¸¦ Áö¿øÇÏÁö ¸øÇß´Ù.
3. Support for new datatypes
LogMiner 10g ¿¡¼´Â ¾Æ·¡ÀÇ data typeÀ» redo/undo transaction¿¡¼ Á¤È®È÷
¹Ý¿µÇÏ°Ô µÇ¾ú´Ù. Áï, ¾Æ·¡ÀÇ parameter°¡ »õ·Î Áö¿øµÈ´Ù.
- LONG
- Multibyte CLOB
- NCLOB
4. SQL_REDO/SQL_UNDO without rowids - NO_ROWID_IN_STMT
DBMS_LOGMNR.START_LOGMNR procedure½ÇÇà½Ã¿¡ NO_ROWID_IN_STMT optionÀ»
Ãß°¡ÇÒ ¼ö ÀÖ´Ù. ÀÌ ±â´ÉÀº v$logmnr_contents viewÀÇ SQL_REDO ¿Í SQL_UNDO column¿¡¼
rowid ¸¦ ³ªÅ¸³»Áö ¾Êµµ·Ï ÇÏ´Â optionÀÌ´Ù.
ÀÌ rowid ¸¦ ³ªÅ¸³»Áö ¾ÊÀ¸¸é ÀÌ sqlµéÀ» rowid °¡ ´Ù¸¥ ȯ°æ¿¡¼µµ »ç¿ëÇÒ ¼ö ÀÖÀ¸¹Ç·Î
´õ À¯¿ëÇÏ´Ù. logminer ±â´ÉÀ» object°¡ ¿ø·¡ ÀÖ´Â db°¡ ¾Æ´Ñ ´Ù¸¥ db¿¡¼ ½ÇÇàÇÒ ¶§
ÀÌ ±â´ÉÀ» ÀÌ¿ëÇÏ¿© rowid °¡ ¾Æ´Ñ primary key µî¿¡ ÀÇÇØ sql À» Àû¿ëÇÒ ¼ö ÀÖ´Ù.
[¿¹Á¦]
SQL> EXECUTE DBMS_LOGMNR.START_LOGMNR(-
OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + -
DBMS_LOGMNR.NO_ROWID_IN_STMT);
5. Removing a logfile from the LogMiner session
Oracle9i ±îÁö´Â Logminer sessionÀ» ½ÇÇàÇÏ¿© log fileÀ̳ª archiving fileÀ»
addÇÑ ÈÄ¿¡´Â list ¿¡¼ »èÁ¦ÇÒ ¼ö°¡ ¾ø¾ú´Ù. Oracle10g ºÎÅÍ´Â addÇÑ fileÀ»
»èÁ¦ÇÒ ¼ö ÀÖ´Â ±â´ÉÀÌ Ãß°¡µÇ¾ú´Ù.
ÀÌ ±â´ÉÀº ´ÙÀ½°ú °°ÀÌ DBMS_LOGMNR.REMOVE_LOGFILE()¸¦ ÀÌ¿ëÇÏ¿© °¡´ÉÇÏ´Ù.
[¿¹Á¦]
SQL> EXEC DBMS_LOGMNR.REMOVE_LOGFILE(LOGFILENAME => '/oracle/logs/log2.f');
¸¸¾à À§¿Í °°ÀÌ logfileÀ» »èÁ¦ÇÑ ÈÄ¿¡ ¹Ù·Î v$logmnr_contents view¸¦ Á¶È¸Çϸé
¾Æ·¡¿Í °°ÀÌ ora-1306 error°¡ ¹ß»ýÇÑ´Ù. ±×·¯¹Ç·Î ´Ù½Ã DBMS_LOGMNR.START_LOGMNR ¸¦
½ÇÇàÇÑ ÈÄ Á¶È¸ÇØ¾ß ÇÑ´Ù.
SQL> select count(*) from v$logmnr_contents;
select count(*) from v$logmnr_contents
*
ERROR at line 1:
ORA-01306: dbms_logmnr.start_logmnr() must be invoked before selecting from
v$logmnr_contents
## LOGMINER¸¦ ÀÌ¿ëÇÑ ºÐ¼® ¿¹Á¦ - DELETEµÈ DATA º¹±¸¹æ¹ý
Data¸¦ deleteÇÑ ÈÄ¿¡ logminer¸¦ ÀÌ¿ëÇÏ¿© È®ÀÎÇÏ°í »èÁ¦µÈ
record¸¦ º¹±¸ÇÏ´Â °£´ÜÇÑ ¿¹Á¦¸¦ »ìÆ캸ÀÚ.
1. scott user¿¡¼ dept table Àüü¿Í emp tableÀÇ ÇÑ row¸¦ »èÁ¦ÇÑ´Ù.
SQL> connect scott/tiger
SQL> delete from dept;
4 rows deleted.
SQL> commit;
Commit complete.
SQL> delete from emp where deptno = 10 and empno= 7934;
1 row deleted.
SQL> commit;
Commit complete.
2. ºÐ¼®ÇÒ log fileÀ» È®ÀÎÇÑ´Ù.
SQL> connect system/manager
SQL> select a.group#, a.sequence#, b.member
2 from v$log a, v$logfile b
3 where a.status = 'CURRENT' and a.group# = b.group#;
GROUP# SEQUENCE# MEMBER
---------- ---------- -------------------------------------------------------
1 801 /app/ora817/oradata/ORA817/oradata/ORA817/redo01.log
3. logminer¸¦ »ç¿ëÇϱâ À§ÇØ dictionary fileÀ» »ý¼ºÇÏ°í deleteµÇ¾úÀ» ¶§ÀÇ
redo log file ¶Ç´Â archiving fileÀ» µî·ÏÇÑ´Ù.
(1) dictionary fileÀ» »ý¼ºÇÑ´Ù.
SQL> call dbms_logmnr_d.build('dir_file','/app/ora817/utl_dir');
Call completed.
(2) ºÐ¼®ÇÒ fileÀ» µî·ÏÇÑ´Ù.
SQL> call dbms_logmnr.add_logfile('/app/ora817/admin/ORA817/arch/arch_1_801.arc'
,1);
¶Ç´Â ´ÙÀ½°ú °°ÀÌ archiving fileÀ» µî·ÏÇÑ´Ù. º¸ÅëÀÇ °æ¿ì online redo log fileÀº
±Ý¹æ overwriteµÉ ¼ö Àֱ⠶§¹®¿¡ archiving fileÀ» ÀÌ¿ëÇÑ´Ù.
SQL> call dbms_logmnr.add_logfile('/app/ora817/oradata/ORA817/oradata/ORA817/red
o01.log',1);
4. logminer¸¦ ½ÇÇàÇÑ´Ù. ´ÙÀ½°ú °°ÀÌ archiving file ÀüüÀÇ Á¤º¸¸¦ »Ì¾Æ³»°Å³ª
ƯÁ¤ÇÑ scn ¹øÈ£ ¶Ç´Â ½Ã°£ÀÇ ÁöÁ¤ÇÒ ¼öµµ ÀÖ´Ù.
SQL> execute dbms_logmnr.start_logmnr(DictFileName=>'/app/ora817/utl_dir/dir_file');
¶Ç´Â
SQL> execute dbms_logmnr.start_logmnr(DictFileName=>'/app/ora817/utl_dir/dir_file',
startTime=>to_date('2002/04/20 13:00:00','yyyy/mm/dd hh24:mi:ss'),
endTime=>to_date('2002/04/30 18:00:00','yyyy/mm/dd hh24:mi:ss'));
5. v$logmnr_contents view¸¦ ÅëÇÑ log fileÀÇ Á¤º¸¸¦ È®ÀÎ
(1) DEPT table¿¡¼ »èÁ¦ÇÑ data È®ÀÎÇϱâ.
SQL> select seg_owner, seg_name, operation, sql_redo, sql_undo
2 from v$logmnr_contents
3 where seg_owenr = 'SCOTT' and seg_name = 'DEPT' ;
SEG_OWNER SEG_NAME
-------------------------------- --------------------------------
OPERATION
--------------------------------
SQL_REDO
----------------------------------------------------------------------
----------
SQL_UNDO
----------------------------------------------------------------------
----------
SCOTT DEPT
DELETE
delete from "SCOTT"."DEPT" where "DEPTNO" = 10 and "DNAME" = 'ACCOUNTING' and "L
OC" = 'NEW YORK' and ROWID = 'AAAAxCAAFAAAAAzAAA';
insert into "SCOTT"."DEPT"("DEPTNO","DNAME","LOC") values (10,'ACCOUNTING','NEW
YORK');
SCOTT DEPT
DELETE
delete from "SCOTT"."DEPT" where "DEPTNO" = 20 and "DNAME" = 'RESEARCH' and "LOC
" = 'DALLAS' and ROWID = 'AAAAxCAAFAAAAAzAAB';
insert into "SCOTT"."DEPT"("DEPTNO","DNAME","LOC") values (20,'RESEARCH','DALLAS
');
SCOTT DEPT
DELETE
delete from "SCOTT"."DEPT" where "DEPTNO" = 30 and "DNAME" = 'SALES' and "LOC" =
'CHICAGO' and ROWID = 'AAAAxCAAFAAAAAzAAC';
insert into "SCOTT"."DEPT"("DEPTNO","DNAME","LOC") values (30,'SALES','CHICAGO')
;
SCOTT DEPT
DELETE
delete from "SCOTT"."DEPT" where "DEPTNO" = 40 and "DNAME" = 'OPERATIONS' and "L
OC" = 'BOSTON' and ROWID = 'AAAAxCAAFAAAAAzAAD';
insert into "SCOTT"."DEPT"("DEPTNO","DNAME","LOC") values (40,'OPERATIONS','BOST
ON');
=> column SQL_REDO ´Â ½ÇÇàµÈ DELETE¹®ÀåÀ̸ç, SQL_UNDO´Â ÀÌ ÀÛ¾÷À» ´Ù½Ã µÇµ¹¸®±â
À§ÇÑ ¹®ÀåÀÌ´Ù. ½ÇÁ¦·Î user°¡ ½ÇÇàÇÑ ¹®ÀåÀº 'delete from dept;' ÀÌÁö¸¸,
redo log file¿¡´Â ÀÌ ÀÛ¾÷À» µÇµ¹¸± ¼ö ÀÖ´Â °¢°¢ÀÇ ¹®ÀåÀ¸·Î ÀúÀåµÈ´Ù. ±×·¡¼
user°¡ ½ÇÇàÇÑ commandº¸´Ù ¸¹Àº row°¡ ³ª¿Â´Ù.
À§ÀÇ °æ¿ì´Â SQL_UNDO column¿¡ ³ª¿À´Â insert ¹®ÀåÀ» ½ÇÇàÇϸé deleteµÈ Á¤º¸¸¦ ´Ù½Ã
µÇµ¹¸± ¼ö°¡ ÀÖ´Ù.
(2) EMP table¿¡¼ »èÁ¦µÈ data È®ÀÎÇϱâ.
SQL> select seg_owner, seg_name, operation, sql_redo, sql_undo
2 from v$logmnr_contents
3 where seg_owenr = 'SCOTT' and seg_name = 'EMP' ;
SEG_OWNER SEG_NAME
-------------------------------- --------------------------------
OPERATION
--------------------------------
SQL_UNDO
----------------------------------------------------------------------
----------
SCOTT EMP
DELETE
insert into "SCOTT"."EMP"("EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","D
EPTNO") values (7934,'MILLER','CLERK',7782,TO_DATE('23-JAN-1982 00:00:00', 'DD-M
ON-YYYY HH24:MI:SS'),1300,NULL,10);
=> À§ÀÇ °æ¿ìµµ insert¹®ÀåÀ» ½ÇÇàÇÏ¿© deleteµÈ data¸¦ º¹±¸ÇÒ ¼ö ÀÖ´Ù.
(3) ½ÇÇàÇÑ sessionÀÇ Á¤º¸ È®ÀÎÇϱâ.
delete ¹®ÀåÀ» ½ÇÇàÇÑ ½Ã°£°ú sessionÁ¤º¸¸¦ È®ÀÎÇÒ ¼ö ÀÖ´Ù.
SQL> select to_char(timestamp,'yyyy/mm/dd hh24:mi:ss') "Time", session_info
2 from v$logmnr_contents where seg_name = 'EMP';
Time
-------------------
SESSION_INFO
----------------------------------------------------------------------
----------
2002/04/25 21:06:24
LoginUserName = SCOTT, ClientInfo = , OsUserName = ora817, MachineName = rcsunin
tel, OsTerminal = pts/9, OsProcessId = 5327, OsProgramName = sqlplus@rcsunintel
(TNS V1-V3)
6. ÀÛ¾÷ÀÌ ³¡³ª¸é ´ÙÀ½°ú °°ÀÌ logminer¸¦ Á¾·áÇÑ´Ù.
SQL> call dbms_logmnr.end_logmnr();
ÀÌ ¹®ÀåÀ» ½ÇÇàÇϸé v$logmnr_contents view³ª µî·ÏÇÑ log fileÀÇ Á¤º¸µîÀÌ ¸ðµÎ
ÀÚµ¿À¸·Î ¾ø¾îÁö¹Ç·Î ±× Àü¿¡ ºÐ¼®ÇÑ ³»¿ëÀ» ¸ðµÎ È®ÀÎÇϰųª v$logmnr_contents
viewÀÇ ³»¿ëÀ» ´Ù¸¥ table·Î backup¹Þ¾Æ µÎ¾î¾ß ÇÑ´Ù.
|