In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The problem that must be avoided under master and master replication-synchronization conflict
Example:
Create table stu (
Id int primary key auto_increment.
).
2 mysql have equal status, if 2 requests arrive at 2 servers at the same time
The requested A node, the id of stu is 1
The requested B node, the id of stu is 1
Synchronization-> conflict
How to solve?
Let 1 server grow from 1 to 3 to 5 to 7.
The other server, 2pencils, 4pencils, 6pens, 8s to grow.
One server:
Set global auto_increment_increment = 2
Set global auto_increment_offset = 1
Set session auto_increment_increment = 2
Set session auto_increment_offset = 1
Another server:
Set global auto_increment_increment = 2
Set global auto_increment_offset = 2
Set session auto_increment_increment=2
Set session auto_increment_offset = 2
Note: auto-increment-increment and auto-increment-offset should be written to the configuration file to prevent failure after the next restart.
Similar results are obtained after operation as follows
If you need to add a server at a later stage, this method is limited.
We can solve it in terms of business logic.
For example, there is a sequnce sequence in oracle.
Each time the sequence is accessed, increasing / decreasing data is generated.
Taking redis as an example, we can build a special global:userid.
Every time PHP is inserted into Mysql, incr- > global:userid is used to get a non-repetitive userid.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.