-
Notifications
You must be signed in to change notification settings - Fork 0
/
Edge_Case_Seq_MultiMaster.txt
153 lines (95 loc) · 3.73 KB
/
Edge_Case_Seq_MultiMaster.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
-- Edge Case Sequences Multi-Master n-way replication --
This can be used to create a unique number on each site and then replicating that unique number to all the other sites with same value without collision. The trick is to ensure that each site writes the primary key on the table using a sequence with next val and incrementing it with a unique number
For 4-Node Multi-Master Replication
The following is an example sequence management for a 4-way active-active replication.
SQL>create sequence member_seq_1 start with 100 increment by 4 cache 100;
Sequence created.
SQL>create sequence member_seq_2 start with 101 increment by 4 cache 100;
Sequence created.
SQL>create sequence member_seq_3 start with 102 increment by 4 cache 100;
Sequence created.
SQL>create sequence member_seq_4 start with 103 increment by 4 cache 100;
Sequence created.
SQL>select member_seq_1.nextval, member_seq_2.nextval, member_seq_3.nextval,
member_seq_4.nextval from dual;
Now create the table and sequences in each site. Make sure you are not replicating the DDL and create each individual table and sequences in each site
-- Sydney --
create table customers_seq (
customer_id NUMBER PRIMARY KEY ,
email_address varchar2(255 char) not null,
full_name varchar2(255 char) not null)
;
create sequence member_seq_syd start with 100 increment by 4 cache 100;
select * from customers_seq;
insert into customers_seq
values (member_seq_syd.nextval,'[email protected]','thelpa');
commit;
drop table customers_seq;
delete from customers_seq;
-- Singapore --
create table customers_seq (
customer_id NUMBER PRIMARY KEY ,
email_address varchar2(255 char) not null,
full_name varchar2(255 char) not null)
;
create sequence member_seq_sgp start with 101 increment by 4 cache 100;
select * from customers_seq;
insert into customers_seq
values (member_seq_sgp.nextval,'[email protected]','frank');
commit;
update customers_seq set email_address='[email protected]' where customer_id=101;
commit;
drop table customers_seq;
delete from customers_seq;
-- Frankfurt --
create table customers_seq (
customer_id NUMBER PRIMARY KEY ,
email_address varchar2(255 char) not null,
full_name varchar2(255 char) not null)
;
create sequence member_seq_fra start with 102 increment by 4 cache 100;
select * from customers_seq;
insert into customers_seq
values (member_seq_fra.nextval,'[email protected]','mark');
commit;
drop table customers_seq;
delete from customers_seq;
-- Ashburn --
create table customers_seq (
customer_id NUMBER PRIMARY KEY ,
email_address varchar2(255 char) not null,
full_name varchar2(255 char) not null)
;
create sequence member_seq_iad start with 103 increment by 4 cache 100;
select * from customers_seq;
insert into customers_seq
values (member_seq_iad.nextval,'[email protected]','sempre');
commit;
drop table customers_seq;
delete from customers_seq;
#############################
Extract and Replicats Code :
#############################
EXTRACT EXTSYD
USERIDALIAS ggsydney DOMAIN OracleGoldenGate
EXTTRAIL BB
TRANLOGOPTIONS EXCLUDETAG 70
TABLE ADMIN.customers;
TABLE ADMIN.inventory;
TABLE ADMIN.stores;
TABLE ADMIN.products;
TABLE ADMIN.orders;
TABLE ADMIN.shipments;
TABLE ADMIN.order_items;
TABLE ADMIN.customers_seq;
REPLICAT REPSYD
USERIDALIAS ggsydney DOMAIN OracleGoldenGate
DBOPTIONS SETTAG 70
MAP ADMIN.customers, TARGET ADMIN.customers;
MAP ADMIN.inventory, TARGET ADMIN.inventory;
MAP ADMIN.stores, TARGET ADMIN.stores;
MAP ADMIN.products, TARGET ADMIN.products;
MAP ADMIN.orders, TARGET ADMIN.orders;
MAP ADMIN.shipments, TARGET ADMIN.shipments;
MAP ADMIN.order_items, TARGET ADMIN.order_items;
MAP ADMIN.customers_seq, TARGET ADMIN.customers_seq;