Skip to main content

Posts

Showing posts with the label MySQL Master to Master replication with AUTO_INCREMENT

MySQL Master to Master Replication with AUTO_INCREMENT

Master-to-master replication: MySQL offers parameters auto_increment_increment, and auto_increment_offset for master to master replication. Most of the time folks believe when we set auto_increment_offset to odd no., such as 1 for server 1(Master 1),  and even no. such as 2, for server 2 (Master 2), we are all set. But according to Oracle these two parameter  " can be used to control the operation of AUTO_INCREMENT columns ." Means columns which are not using AUTO_INCREMENT for primary key, master to master replication could break at some point, and require human intervention. Default is 1 for these two parameters. Ref. https://dev.mysql.com/doc/refman/8.0/en/replication-options-master.html For auto_increment_increment - 10, and auto_increment_offset   auto_increment_increment: This parameter controls the interval between successive column values. Use of auto_increment_increment in table definition - col_name INT NOT NULL AUTO_INCREMENT PRIMARY KEY. When you SET @@auto_...