How to Make GoldenGate record the database SCN information in the trail File

Source: Internet
Author: User
How to enable GoldenGate to record the database's SCN information in the trail file? Generally, the OracleGoldenGate's trail file does not contain the database's SCN information, so you need to record this information in the trail file, the example of TOKENS must be set in the Extract process parameters: -- Normalextractmapping -- TABL

How to enable GoldenGate to record the database's SCN information in the trail file? Normally, the trail file of Oracle GoldenGate does not contain the database's SCN information, and this information should be recorded in the trail file, the example of TOKENS must be set in the Extract process parameters: -- Normal extract mapping -- TABL

How to Make GoldenGate record the database SCN information in the trail File

Generally, the trail file of Oracle GoldenGate does not contain the SCN information of the database. to record this information in the trail file, you must set TOKENS in the Extract process parameters.
Example:
-- Normal extract mapping --
TABLE scott .*;

-- To use tokens --
TABLE scott. *, tokens (tk-scn = @ getenv ("ORATRANSACTION", "SCN "));

After tokens is set, the Extract process writes a token to the trail file, which contains detailed information about SCN. Next, we will use the experiment to learn more about the difference between tokens setting and not setting.

Before tokens is set:
GGSCI (prod.oracle.com) 1> view params ESCOTT
EXTRACT escott
SETENV (NLS_LANG = AMERICAN_AMERICA.AL32UTF8)
USERID ggs, PASSWORD register
EXTTRAIL./dirdat/aa
TABLE scott. EMP_GGS, tokens (tk-scn = @ getenv ("ORATRANSACTION", "SCN "));
TABLE scott. DEPT_GGS, tokens (tk-scn = @ getenv ("ORATRANSACTION", "SCN "));

Logdump 15> open./dirdat/aa42416
Current LogTrail is/home/oracle/ggs/dirdat/aa42416
Logdump 16> ghdr on
Logdump 17> detail data
Logdump 18> usertoken detail
Logdump 51> n
___________________________________________________________________
Hdr-Ind: E (x45) Partition:. (x04)
UndoFlag:. (x00) BeforeAfter: A (x41)
RecLength: 120 (x0078) IO Time: 2013/03/21 23:31:55. 000.000
IOType: 5 (x05) OrigNode: 255 (xff)
TransInd:. (x03) FormatType: R (x52)
SyskeyLen: 0 (x00) Incomplete:. (x00)
AuditRBA: 131 AuditPos: 6994960
Continued: N (x00) RecCount: 1 (x01)


23:31:55. 000.000 Insert Len 120 RBA 1079
Name: SCOTT. EMP_GGS
After Image: Partition 4G s
0000 000a 0000 0000 0000 0000 1cd4 0001 0008 0000 | ....................
0004 4d49 4d49 0002 0009 0000 0005 434c 4552 4b00 |... MIMI ...... CLERK.
0300 0a00 0000 0000 0000 001e de00 0400 1500 | ...... 1
3938 372d 3132 2d31 373a 3030 3a30 303a 3030 | 0005-12-17: 00: 00: 00 ..
000a 0000 0000 0000 0001 3880 000a ffff 0006 | ...... 8 .........
0000 0000 0000 0007 000a 0000 0000 0000 0000 | ....................
Column 0 (x0000), Len 10 (x000a)
0000 0000 0000 0000 1cd4 | ..........
Column 1 (x0001), Len 8 (x0008)
0000 0004 4d49 4d49 |... MIMI
Column 2 (x0002), Len 9 (x0009)
0000 0005 434c 4552 4b |... CLERK
Column 3 (x0003), Len 10 (x000a)
0000 0000 0000 0000 1ede | ..........
Column 4 (x0004), Len 21 (x0015)
0000 3139 3837 2d31 322d 3137 3a30 303a 3030 3a30 | .. 1987-12-17: 00: 00: 0
30 | 0
Column 5 (x0005), Len 10 (x000a)
0000 0000 0000 0001 |... 8.
Column 6 (x0006), Len 10 (x000a)
Ffff 0000 0000 0000 | ..........
Column 7 (x0007), Len 10 (x000a)
0000 0000 0000 0000 | ..........

Next let's take a look at how to insert a record in the trail file after adding tokens settings to the Extract process parameters.

GGSCI (prod.oracle.com) 3> view params escott
TABLE scott. EMP_GGS;
EXTRACT escott
SETENV (NLS_LANG = AMERICAN_AMERICA.AL32UTF8)
USERID ggs, PASSWORD register
EXTTRAIL./dirdat/aa
TABLE scott. EMP_GGS, tokens (tk-scn = @ getenv ("ORATRANSACTION", "SCN "));
TABLE scott. DEPT_GGS, tokens (tk-scn = @ getenv ("ORATRANSACTION", "SCN "));

After a record is inserted, the trail file is switched to the next queue.
GGSCI (prod.oracle.com) 8> info ESCOTT, detail
Extract escott Last Started 2013-03-21 23:42 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:09 ago)
Log Read Checkpoint Oracle Redo Logs
23:43:34 Seqno 132, RBA 290816
SCN 0.1364750 (1364750)
Target Extract Trails:
Remote Trail Name Seqno RBA Max MB
./Dirdat/aa 17 1333 5

Logdump 54> open./dirdat/aa42417
Current LogTrail is/home/oracle/ggs/dirdat/aa42417
Logdump 55> ghdr on
Logdump 56> detail data
Logdump 57> usertoken on
Logdump 58> usertoken detail
Logdump 59> n

Logdump 61> n
___________________________________________________________________
Hdr-Ind: E (x45) Partition:. (x04)
UndoFlag:. (x00) BeforeAfter: A (x41)
RecLength: 120 (x0078) IO Time: 2013/03/21 23:43:34. 000.000
IOType: 5 (x05) OrigNode: 255 (xff)
TransInd:. (x03) FormatType: R (x52)
SyskeyLen: 0 (x00) Incomplete:. (x00)
AuditRBA: 132 AuditPos: 289296
Continued: N (x00) RecCount: 1 (x01)

23:43:34. 000.000 Insert Len 120 RBA 1079
Name: SCOTT. EMP_GGS
After Image: Partition 4 GU s
0000 000a 0000 0000 0000 0000 1cd5 0001 0008 | ....................
0004 4d49 4e49 0002 0009 0000 0005 434c 4552 4b00 |... MINI ......... CLERK.
0300 0a00 0000 0000 0000 001e de00 0400 1500 | ...... 1
3938 372d 3132 2d31 373a 3030 3a30 303a 3030 | 0005-12-17: 00: 00: 00 ..
000a 0000 0000 0000 0001 3880 000a ffff 0006 | ...... 8 .........
0000 0000 0000 0007 000a 0000 0000 0000 0000 | ....................
Column 0 (x0000), Len 10 (x000a)
0000 0000 0000 0000 1cd5 | ..........
Column 1 (x0001), Len 8 (x0008)
0000 0004 4d49 4e49 |... MINI
Column 2 (x0002), Len 9 (x0009)
0000 0005 434c 4552 4b |... CLERK
Column 3 (x0003), Len 10 (x000a)
0000 0000 0000 0000 1ede | ..........
Column 4 (x0004), Len 21 (x0015)
0000 3139 3837 2d31 322d 3137 3a30 303a 3030 3a30 | .. 1987-12-17: 00: 00: 0
30 | 0
Column 5 (x0005), Len 10 (x000a)
0000 0000 0000 0001 |... 8.
Column 6 (x0006), Len 10 (x000a)
Ffff 0000 0000 0000 | ..........
Column 7 (x0007), Len 10 (x000a)
0000 0000 0000 0000 | ..........

User tokens: 15 bytes
Tk-scn: 1364750

The tk-scn: 1364750 shown here is the database SCN number we want to display.

Next we will perform a more accurate test. We will update a record, record the SCN number before and after the record is inserted, and then
Check whether this is true in the trail file.

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
1365152
SQL> update scott. emp_ggs set ename = 'Daniel 'where empno = 7381;

1 row updated
SQL> commit;

Commit complete
SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
1365155

The database SCN before the record is modified is 1365152, and the modified value is 1365155. The SCN when the record is modified should be between the two:

Logdump 62> n
___________________________________________________________________
Hdr-Ind: E (x45) Partition:. (x04)
UndoFlag:. (x00) BeforeAfter: A (x41)
RecLength: 28 (x001c) IO Time: 23:53:03. 000.000
IOType: 15 (x0f) OrigNode: 255 (xff)
TransInd:. (x03) FormatType: R (x52)
SyskeyLen: 0 (x00) Incomplete:. (x00)
AuditRBA: 132 AuditPos: 526352
Continued: N (x00) RecCount: 1 (x01)

23:53:03. 000.000 FieldComp Len 28 RBA 1333
Name: SCOTT. EMP_GGS
After Image: Partition 4 GU s
0000 000a 0000 0000 0000 0000 1cd5 0001 000a 0000 | ....................
0006 4441 4e49 454c |... DANIEL
Column 0 (x0000), Len 10 (x000a)
0000 0000 0000 0000 1cd5 | ..........
Column 1 (x0001), Len 10 (x000a)
0000 0006 4441 4e49 454c |... DANIEL

User tokens: 15 bytes
Tk-scn: 1365154

Logdump shows that SCN 1365154 is indeed between 1365152 and 1365155.



Http://blog.csdn.net/xiangsir/article/details/8708626

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.