MySQL now supports an interface for semisynchronous replication:

Steven1981發表於2010-11-26
Mysql半同步SLAVE,類似於ORACLE安全模式的DATAGUARD(但不完全是);
為什麼是半同步呢,因為MYSQL只保證“至少一個”SLAVE接收到日誌後返回;
雖然可能不會有太多的人去用這個東西(因為對網路的要求和機器的穩定性很高);但MYSQL還是補全了這一塊的功能缺失
[@more@]

A commit performed on the master side blocks before returning to the session
that performed the transaction until at least one slave acknowledges that it has received
and logged the events for the transaction.

Semisynchronous replication is implemented through an optional plugin component.
See Section 17.3.8, “Semisynchronous Replication”.
http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html


The slave acknowledges receipt of a transaction's events only after the events have been written to its relay log and flushed to disk.
只有SLAVE接收到日誌寫入到RELAY-LOG,並重新整理到磁碟才算同步成功;
If a timeout occurs without any slave having acknowledged the transaction, the master reverts to asynchronous replication
如果日誌傳輸過程中發生超時現象;那麼SLAVE將恢復到非同步方式;
Semisynchronous replication must be enabled on both the master and slave sides. If semisynchronous replication is disabled on the master, or enabled on the master but on no slaves, the master uses asynchronous replication
半同步複製方式必須在MASTER和SLAVE同時開啟;否則還是採用非同步方式;
While the master is blocking (waiting for acknowledgment from a slave after having performed a commit), it does not return to the session that performed the transaction
在SLAVE接受到日誌或超時之前,MASTER對SESSION的COMMIT請求不作返回響應;
The rolled-back transaction is logged even though it has no effect for transactional tables because the modifications to the nontransactional tables cannot be rolled back and must be sent to slaves.
滾回操作,即使對事務表沒有影響,也同樣會被記錄到日誌裡,因為“修改”會非事務表是不可回滾的,所以必須也傳輸到SLAVE;
對於自動提交的語句; MASTER將被在每個語句結束後BLOCK住;

## 幾個系統變數設定
rpl_semi_sync_master_enabled=1 # 開啟MASTER支援semisynchronous replication
rpl_semi_sync_slave_enabled=1 # 開啟Slave 支援semisynchronous replication
rpl_semi_sync_master_timeout # 等待SLAVE超時時間;1MS,預設10000MS
rpl_semi_sync_master_wait_no_slave # 在超時之前,如果SLAVE都DOWN了,是不是還繼續等待直到超時;預設開啟 ;

## 幾個狀態變數
Rpl_semi_sync_master_status # 檢視MASTER是否支援semisynchronous replication
Rpl_semi_sync_slave_status # 檢視SLAVE 是否支援semisynchronous replication
Rpl_semi_sync_master_clients # 檢視後面跟著幾個semisynchronous slaves
Rpl_semi_sync_master_yes_tx # 成功傳輸了多少個事務;
Rpl_semi_sync_master_no_tx # 失敗傳輸了多少個事務;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/703656/viewspace-1042160/,如需轉載,請註明出處,否則將追究法律責任。

相關文章