Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[Otter] A question about otter double A mode

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

What is the double A mode: it can be simply understood as the double master mode of mysql, which is dominant and subordinate to each other.

For more information, please see https://github.com/alibaba/otter/wiki/Manager configuration introduction.

How to configure the official blog:

Double A synchronization compared with two-way synchronization, the whole configuration is mainly due to changes in some parameters, specific steps:

Configure a channel

Configure two pipeline

* Note: in addition to defining a main site, you need to set the "support DDL" of one pipeline to false and the other to true in the advanced settings, otherwise it will prompt "only one-way ddl synchronization is allowed in a channel!" Error each pipeline configures canal and defines the mapping relationship

Background:

111112 double A mode

111-> 112_canal:111 synchronizes data to 112

Main site: true

Support for ddl synchronization: off

Skip ddl exception: on

112-> 111_canal:112 synchronizes data to 111,

Main site: flase

Support for ddl synchronization: enable

Skip ddl exception: on

In the above context

Question 1: there is no problem with adding, deleting, checking or changing the data, but when the DDL statement such as create table/Truncate is executed on 111111, it will not be synchronized to 11212. on the contrary, it can be synchronized to 11112because the parameter ddl synchronization is supported.

Solution:

To be continued

Question 2: when the table does not have a primary key constraint, executing insert on a non-primary site will repeatedly insert an entry such as:

Execute on a non-primary site:

Mysql > insert into test3 values (5)

Query OK, 1 row affected (0.01sec)

Mysql > select * from test3

+-+

| | id |

+-+

| | 4 |

| | 5 |

| | 5 |

+-+

3 rows in set (0.00 sec)

On the main site:

Mysql > select * from test3

+-+

| | id |

+-+

| | 4 |

| | 5 |

+-+

2 rows in set (0.00 sec) synchronized to the primary site, but the non-primary site will be inserted again

Reason: one-way loop designed by otter

Idea: ultimate consistency

Applicable scenarios: the data of An and B are not equal, for example, An is the main place, the amount of writing is relatively high, and there is a small amount of data written in B

One-way loopback process: (for example, HZ is used as the trusted source site in the figure)

Data synchronized with us- > hz will enter the hz- > us queue again to form an one-way loopback hz- > us synchronized data, and will not enter the us- > hz queue (loopback terminates to ensure that it will not enter an endless loop)

Solution: design tables with self-increasing primary keys

Question 3: if both sides insert a piece of data at the same time, what about the self-increasing id?

Mysql > select * from admin

+-+ +

| | id | role_id |

+-+ +

| | 8 | 77 |

| | 9 | 777 |

| | 11 | 99 | |

| | 12 | 999 |

| | 16 | 888 |-you can see that the main site is missing and not inserted! |

+-+ +

5 rows in set (0.00 sec)

In the section of "otter database storage algorithm" on github, we can see the following paragraph: after the merge algorithm is executed, there is only one record for a single competitive primary key, which reduces the complexity of parallel load algorithm (such as batch merge, parallel / serial processing, etc.)

Because the time interval between concurrent insertions is very short, which is shorter than the delay between synchronization, it is the same competitive construction after the primary and secondary sites are inserted respectively, and after the secondary sites are inserted, then the secondary sites are the latest replica set, that is, trust points, and the secondary site data covers the main site data. "otter data consistency" detailed explanation!

Solution: refer to the official practice of double a, set the step size and starting value

Modify the step size of the two sets mysql > show global variables like'% auto_increment_increment%'

+-+ +

| | Variable_name | Value |

+-+ +

| | auto_increment_increment | 2 | |

+-+ +

Mysql > show global variables like'% auto_increment_increment%'

+-+ +

| | Variable_name | Value |

+-+ +

| | auto_increment_increment | 1 | |

+-+ +

Test [root@DB-22 dbaadmin] # python test.py again

()

()

All over Mon Jul 31 17:54:10 2017

[root@DB-22 dbaadmin] # python test.py

()

()

All over Mon Jul 31 17:54:21 2017

Mysql > select * from admin

+-+ +

| | id | role_id |

+-+ +

| | 28 | 111 | |

+-+ +

1 row in set (0.00 sec)

Mysql > select * from admin

+-+ +

| | id | role_id |

+-+ +

| | 28 | 111 | |

| | 29 | 888 |

| | 30 | 88 |

+-+ +

3 rows in set (0.00 sec)

Mysql > select * from admin

+-+ +

| | id | role_id |

+-+ +

| | 28 | 111 | |

| | 29 | 888 |

| | 30 | 88 |

| | 31 | 888 |

| | 32 | 88 |

+-+ +

5 rows in set (0.00 sec)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report