The direct answer to your question is Yes, but it depends on the version of MySQL you are running. Before MySQL 5.5, replication would operate as follows:
- Master Executes SQL
- Master Records SQL Event in its Binary Logs
- Slave Reads SQL Event from Master Binary Logs
- Slave Stores SQL Event in its Relay Logs via I/O Thread
- Slave Reads Next SQL Event From Relay Log via SQL Thread
- Slave Executes SQL
- Slave Acknowledges Master of the Complete Execution of the SQL Event
As of MySQL 5.5, using Semisynchronous Replication, now replication would operate as follows:
- Master Executes SQL
- Master Records SQL Event in its Binary Logs
- Slave Reads SQL Event from Master Binary Logs
- Slave Acknowledges Master of the Receipt of the SQL Event
- Slave Stores SQL Event in its Relay Logs via I/O Thread
- Slave Reads Next SQL Event From Relay Log via SQL Thread
- Slave Executes SQL
- Slave Acknowledges Master of the Complete Execution of the SQL Event
This new paradigm will permit a Slave to be closer sync'd to its Master.
Notwithstanding, latency within the network could hamper MySQL Semisync Replication to the point where it reverts back to the old-style asynchronous replication. Why ? If a timeout occurs without any slave having acknowledged the transaction, the master reverts to asynchronous replication. When at least one semisynchronous slave catches up, the master returns to semisynchronous replication.
UPDATE 2011-08-08 14:22 EDT
The configuration of MySQL 5.5 Semisynchronous Replication is straightforward
Step 1) Add these four(4) lines to /etc/my.cnf
[mysqld]
plugin-dir=/usr/lib64/mysql/plugin
#rpl_semi_sync_master_enabled
#rpl_semi_sync_master_timeout=5000
#rpl_semi_sync_slave_enabled
Step 2) Restart MySQL
service mysql restart
Step 3) Run these commands in the MySQL client
INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
Step 4) Uncomment the three rpm_semi_sync options after the plugin-dir option
[mysqld]
plugin-dir=/usr/lib64/mysql/plugin
rpl_semi_sync_master_enabled
rpl_semi_sync_master_timeout=5000
rpl_semi_sync_slave_enabled
Step 5) Restart MySQL
service mysql restart
All Done !!! Now just setup MySQL Replication as usual.
I answered a question on how to use rsync to copy a live DB to another location.
You would repeat rsync process multiple times until two rsync's run in the same time.
Then, you would shutdown mysql on the master, perform a final rsync to the new server, and start mysql on the master.
You then properly prep the new server, make sure /var/lib/mysql has everything, make sure you erase all binary logs on the new server, and make sure you have the same my.cnf on both machines (you may want to change the server_id)
Here is an excerpt from that link:
Step 01) install the same version of mysql on ServerB that ServerA has
Step 02) On ServerA, run SET GLOBAL innodb_max_dirty_pages_pct = 0;
from mysql and about 10 minutes (This purges dirty pages from the InnoDB Buffer Pool. It also helps perform a mysql shutdown faster) If your database is all MyISAM, you can skip this step.
Step 03) rsync /var/lib/mysql of ServerA to /var/lib/mysql on ServerB
Step 04) Repeat Step 03 until an rsync takes less than 1 minute
Step 05) service mysql stop
on ServerA
Step 06) Perform one more rsync
Step 07) scp ServerA:/etc/my.cnf to ServerB:/etc/.
Step 08) service mysql start
on ServerB
Step 09) service mysql start
on ServerA (optional)
Give it a Try !!!
Best Answer
You can setup replication using SSL.
Source: https://dev.mysql.com/doc/refman/5.6/en/ssl-connections.html