Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

MySQL “master-master” replication is two independent replication channels: node A replicates from node B, while node B replicates from node A. It is asynchronous source-to-source replication, not automatic conflict resolution. The safest production design is one active writer at a time, with the second VPS ready for an explicit failover. If both servers must accept writes concurrently, the application must prevent overlapping writes and define deterministic conflict handling.

This guide shows a MySQL 8.0 design using unique server IDs, binary logs, GTIDs, and SOURCE_AUTO_POSITION=1. It also covers initial data synchronization, generated-key collisions, validation, failover, rejoining a recovered node, and the failure modes that make circular replication unsafe when it is treated like a cluster.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What this topology does—and what it does not do

Replication copies committed changes from a source to a replica. MySQL replication is asynchronous by default, so a commit on the writer can return before the peer has received and applied the event. Semisynchronous replication can make a commit wait for at least one replica to acknowledge receipt and logging, but it is still different from synchronous clustering. MySQL associates synchronous replication with NDB Cluster rather than ordinary source/replica channels.

In this article, node A has a channel reading from node B, and node B has a channel reading from node A. Each server therefore acts as both a source and a replica. A network partition can leave both nodes accepting writes, producing divergent transactions or duplicate keys. Replication will not merge those changes for you.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

Recommended operating model

  • Keep one node writable for normal traffic.
  • Keep the peer caught up and ready to become the writer after a controlled promotion.
  • Use fencing, a load-balancer decision, or an external leader mechanism so the old writer cannot continue accepting writes during a partition or failover.
  • Only use simultaneous writers after testing table ownership, conflict handling, and transaction ordering at the application layer.

Prerequisites for two VPS servers

Prepare both VPS instances before changing MySQL configuration. The servers should run supported, compatible MySQL installations and have stable private connectivity, a VPN, or firewall rules that expose port 3306 only to the peer. Use fixed private addresses or internal DNS names such as node-a.example.internal and node-b.example.internal.

  • Assign a different positive server_id to every server in the replication topology.
  • Enable binary logging on both nodes and reserve durable disk space for binary and relay logs.
  • Synchronize system clocks; consistent timestamps make incident analysis and failover decisions easier.
  • Use matching schemas and compatible storage engines. Existing data must begin from a consistent snapshot or logical backup.
  • Create a dedicated replication account on each server. Limit its source address and grant only the replication privileges required by your installed MySQL version.
  • Keep an independent backup. Replication copies mistakes, accidental deletes, and corrupted transactions as readily as valid changes.
  • Write a rollback and promotion plan before enabling unrestricted application writes on both VPS instances.

Plan the identities, logs, and generated-key ranges

The following values are an example topology. The IDs only need to be unique within your replication setup; they are not required to match the VPS addresses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting Node A Node B
Replication identity server_id=101 server_id=102
Example host name node-a.example.internal node-b.example.internal
Auto-increment offset when both nodes insert 1 2
Auto-increment increment when both nodes insert 2 2

Set log_bin and choose explicit locations for binary and relay logs in each server’s MySQL configuration. The paths below are examples; use filesystems with sufficient capacity and backup characteristics for your VPS.

[mysqld]
server_id=101
log_bin=/var/lib/mysql/binlog
relay_log=/var/lib/mysql/relay-bin

Use the same configuration shape on node B, changing server_id to 102 and selecting its local log paths. Keep binary logs long enough to cover your recovery objective, but monitor disk usage and rotate or purge them according to that objective.

Enable GTIDs consistently

Global transaction identifiers eliminate manual binary-log file and position bookkeeping. With GTIDs enabled on both servers, the channel can request missing transactions automatically by using SOURCE_AUTO_POSITION=1. This substantially simplifies rejoining a recovered node, provided the node’s data and executed GTID set are trustworthy.

New installations

Before starting replication, configure both servers with:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[mysqld]
gtid_mode=ON
enforce_gtid_consistency=ON

Restart each server according to your distribution’s service procedure and verify that the settings are active. Both nodes must use GTID mode; enabling it on only one side does not create a usable GTID topology.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Converting an existing topology

Do not switch a live, independently writable pair to GTIDs without a controlled cutover. Make both servers read-only for application traffic, allow current replication to catch up, stop the servers, and restart them with GTID mode and GTID consistency enforcement. Non-GTID transactions must be fully cleared from the topology first. After conversion, take a fresh backup.

Backups and binary logs containing transactions without GTIDs may not be usable on GTID-enabled servers. Treat the post-conversion backup as a new recovery baseline rather than assuming an older backup can be restored into the new configuration.

Create reciprocal replication accounts

Each node needs an account that the other node can use to connect. On node A, create an account restricted to node B’s private address; on node B, create the reciprocal account restricted to node A. Use a secret manager instead of placing a reusable password in shell history or source control, and enable TLS for the replication connection when supported by your deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The exact replication privilege name and TLS options depend on the MySQL release and authentication policy. Follow the account-creation step for your installed version, grant only the privileges needed for a replica connection, and verify that firewall rules allow the peer’s address to reach port 3306. Do not expose the replication account or MySQL port to the public internet.

Synchronize the data before starting either channel

Replication assumes that the starting datasets are compatible. For an existing database, take a consistent backup or storage snapshot, restore it to the peer, and verify that schemas, table definitions, and storage engines match. A cold start can create the schema on both nodes before any application data is written.

Do not begin with two unrelated datasets and expect GTID auto-positioning to reconcile them. If the nodes already contain different rows, stop and choose a known-good source of truth. Provision the other node from that source, then configure its channel.

Configure the channel from node B to node A

On node A, stop any stale channel before replacing its source settings. MySQL 8.0.23 and later use CHANGE REPLICATION SOURCE TO and START REPLICA. Substitute the private host name and the account created on node B.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
STOP REPLICA;
CHANGE REPLICATION SOURCE TO
  SOURCE_HOST='node-b.example.internal',
  SOURCE_PORT=3306,
  SOURCE_USER='repl_from_b',
  SOURCE_PASSWORD='use-a-secret-manager',
  SOURCE_AUTO_POSITION=1;
START REPLICA;

On releases older than MySQL 8.0.23, the equivalent statement names are CHANGE MASTER TO and START SLAVE. Do not mix old and new names arbitrarily; use the syntax supported by the server you are operating.

Configure the channel from node A to node B

On node B, configure the reciprocal source and account:

STOP REPLICA;
CHANGE REPLICATION SOURCE TO
  SOURCE_HOST='node-a.example.internal',
  SOURCE_PORT=3306,
  SOURCE_USER='repl_from_a',
  SOURCE_PASSWORD='use-a-secret-manager',
  SOURCE_AUTO_POSITION=1;
START REPLICA;

Run the command only after node B has been provisioned with the consistent dataset described above. Starting a channel against an unrelated dataset can produce errors or conceal divergence until a later write exposes it.

Prevent AUTO_INCREMENT collisions

If both nodes can insert into the same AUTO_INCREMENT tables, configure disjoint generated-key sequences. Set auto_increment_increment=2 on both servers, with auto_increment_offset=1 on node A and auto_increment_offset=2 on node B.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[mysqld]
auto_increment_increment=2
auto_increment_offset=1

Use offset 2 in node B’s configuration. These are server-wide settings: they affect every AUTO_INCREMENT column on that server, not only one table. Review all such tables, migration scripts, bulk-load jobs, and session-level overrides before enabling the policy. The settings prevent collisions in generated numeric keys; they do not prevent two writers from updating the same logical row or violating another unique constraint.

Choose a write policy before production traffic

Single-writer failover

Route normal application writes to one active node. Keep the second node replicating and remove it from write traffic. During a failure, stop or fence the old writer, promote the peer, redirect clients, and verify that the application reconnects. This model is the simplest way to avoid circular-replication conflicts.

Multi-writer operation

Concurrent writes require more than different auto-increment offsets. Define which application or table owns each write, prevent two nodes from changing the same logical rows, and specify deterministic behavior for deletes, updates, retries, and transactions that cross ownership boundaries. Test network partitions and simultaneous failover; otherwise both nodes can accept valid-looking but incompatible transactions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Validate both replication threads

After starting the channels, inspect status on each node:

SHOW REPLICA STATUS	extbackslash G

On older releases, use the release’s equivalent status statement. Confirm that the receiver and applier threads are running, no last-error fields contain a failure, and retrieved and executed GTID sets continue to advance. A running connection alone is not sufficient: the applier can be stopped while the receiver remains connected.

Run a disposable round-trip check

  1. Create a disposable test schema that is not used by production traffic.
  2. Insert a uniquely identifiable row on node A and record its transaction time and identifier.
  3. Confirm that the row appears on node B and that node B’s executed GTID set advances.
  4. Repeat in the reverse direction, inserting a different value on node B and checking node A.
  5. Remove the test rows and verify that the cleanup transactions also replicate.

Record the observed delay under normal load. This is an operator runbook check, not a guarantee that production transactions will never conflict.

Perform a controlled failover and rejoin

Promote the peer

  1. Stop application writes to the failed or suspect node, or fence it so clients cannot continue sending traffic.
  2. Confirm the promoted node has applied the transactions required by the application. If the old writer was unreachable, account for any transactions that had not reached the peer.
  3. Redirect the application’s database endpoint to the promoted node and test new reads and writes.
  4. Start the reverse replication channel only after deciding which node’s data is authoritative.

Promotion is an operational decision, not an automatic consequence of a thread failure. A node can be reachable while its data is stale, or both nodes can be reachable while the network between them is partitioned.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Rejoin the recovered node

Do not blindly start stale channels on a node that was writable during the outage. Provision it from a known-good backup or use GTID auto-positioning only after comparing its data and GTID history with the promoted node. If the old node contains transactions absent from the new writer, preserve logs and resolve the difference before making it a replica again.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Diagnose common failure modes

Duplicate-key or row conflicts

These commonly result from concurrent writes to the same logical rows, reused server_id values, or unsafe key generation. Stop one writer, preserve binary and relay logs, identify the conflicting transaction, and repair the data deliberately before restarting the channel.

Errant transactions

An errant transaction exists in a node’s GTID history but was not produced by the expected source. Do not skip an error casually. Identify the transaction, compare affected data, and repair from a known-good backup or controlled SQL. Apply any GTID correction procedure only after documenting why the transaction can be discarded or represented safely.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Network partition

Both VPS instances may continue accepting writes while disconnected, and each can then replicate a different history when connectivity returns. Use fencing or an external leader decision so only one node remains writable during the partition. Reconcile any writes made on the isolated side before rejoining it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Version mismatch

Use supported MySQL compatibility paths and test upgrades in a staging topology. Statement names and startup options changed over time: MySQL 8.0.23 introduced CHANGE REPLICATION SOURCE TO, and from 8.0.26 the startup option is skip_replica_start rather than the older slave spelling. Keep both nodes on a tested compatibility combination during upgrades.

Storage exhaustion

Binary logs and relay logs can fill a VPS even when replication threads appear healthy. Alert on filesystem usage, relay-log growth, and delayed purge. Retain logs long enough for the recovery and rejoin procedures you have promised, then rotate them according to that policy.

Monitoring and maintenance checklist

  • Check receiver and applier thread state on both nodes.
  • Alert when replication lag increases or retrieved and executed GTID sets stop advancing.
  • Monitor relay-log and binary-log disk growth.
  • Alert on certificate expiry and failed TLS connections.
  • Compare row counts or checksums for important tables on a schedule appropriate to their size and write rate.
  • Test client reconnect behavior and the promotion runbook before an outage.
  • Take independent backups and periodically verify that they can be restored.

Replication is not a backup

A replicated delete, bad migration, or corrupted transaction is copied to the peer. Keep backups on separate storage and test restoration. After enabling GTIDs, create a fresh backup because backups and binary logs containing transactions without GTIDs may not be usable on GTID-enabled servers.

When another architecture is a better fit

Evaluate alternatives when your requirement is true multi-primary writing, automatic conflict resolution, or synchronous durability. Compare each option on write concurrency, consistency model, recovery time, conflict handling, operational complexity, backup and rejoin workflow, and cost.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Requirement Two-way circular replication What to evaluate if it is insufficient
One writer with a standby Appropriate when failover is controlled and conflicts are avoided. Automation for fencing, promotion, and health checks.
Concurrent writes on both nodes Possible only with tested application-level ownership and conflict rules. A multi-primary design or clustering product built for that consistency model.
Commit acknowledgment from another node Asynchronous by default; semisynchronous mode can wait for receipt and logging. A design with explicit synchronous durability requirements.
Automatic conflict resolution Not provided by ordinary source-to-source replication. Application conflict handling or a system designed for coordinated writes.

For many two-VPS deployments, circular replication is most defensible as a single-writer setup with a rehearsed promotion and rejoin procedure. Treat the channels as data-copy mechanisms, not as a substitute for leader election, fencing, backups, or application-level consistency.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.