MySQL dual master self-growth conflict handling

Source: Internet
Author: User

MySQL dual master self-growth conflict processing There are some differences between multi-master and master-slave replication, because there can be write access to the server in the host, so design to self-growing duplication problem (multi-master self-Growth ID duplication) 1: First we pass a A, a, a, B, the test table, There is a self-growth ID) to perform the insert operation, return an insert ID of 1 3: Stop B, insert the data table test on a (there is a self-growth ID), and return the insertion ID of 1 4: Then we start a A, a, and then a duplicate resolution of the primary key ID appears: We just need to ensure that the two servers inserted on the self-growth data is different, such as: a Chachi number id,b interpolation even ID, of course, if the server is more, you can define the algorithm, as long as the difference can be in here we add parameters on a, b to achieve the odd and even insert a:my.cnf parameters added Auto_ Increment_offset = 1 Auto_increment_increment = 2 The value produced by the Auto_increment field of a is: 1, 3, 5, 7, ... Equal odd ID is added on b:my.cnf parameter Auto_increment_offset = 2 Auto_increment_increment = 2 So the value of the Auto_increment field of B is: 2, 4, 6, 8, ... As you can see with even IDs, your auto_increment fields will never be duplicated between different servers, so there's no problem with the master-master structure. Of course, you can also use 3, 4, or n servers, just ensure that auto_increment_increment = N and then set the Auto_increment_offset as the appropriate initial value, then, Our MySQL can have dozens of master servers at the same time without the duplication of self-growth IDs. Http://www.2cto.com/database/201307/231397.html

MySQL dual master self-growth conflict handling

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.