MySQL
DBA-
方案联盟
2009
&DBA
2012 2014
DBA DBA
方案联盟
•
方案联盟
• MySQL
• MySQL
•
•
方案联盟
MySQL
• MySQL
方案联盟
buffer pool log buffer os cache log file
innodb_flush_log_at_trx_commit
insert into table
commit
0
1
insert into table
commit
2
insert into table
commit
方案联盟
• sync_binlog=1
方案联盟
innodb_xa_suport
commit
ha_commit_trans
binlog_hton—>prepare
innobase_hton—>prepare
TC_LOG_BINLOG::log_xid
ha_commit_one_phase
prepare_commit_mutex
binlog_hton —> binlog_commit
innobase_hton —> innobase_commit
方案联盟
方案联盟
• MySQL
• MySQL
•
•
方案联盟
MySQL
•
•
方案联盟
master
slave
slave
succeed
方案联盟
master
semisync slave
semisync slave
succeed
ack
ack
wait acks
方案联盟
(loss-ness)
方案联盟
• Master
• install plugin rpl_semi_sync_master sonar ‘’
• Slave
• install plugin rpl_semi_sync_slave sonar ‘’
方案联盟
&
• rpl_semi_sync_master_enabled
• rpl_semi_sync_slave_enabled
• rpl_semi_sync_master_timeout
• rpl_semi_sync_master_clients
• rpl_semi_sync_master_status
方案联盟
QPS
方案联盟
方案联盟
方案联盟
crash-safe slaves
•
•
• master_info_repository=TABLE
• relay_log_info_repository=TABLE
方案联盟
• MySQL
• MySQL
•
•
方案联盟
•
• pt-table-checksum
•
方案联盟
方案联盟
pt-table-checksum
chunk
chunk
chunk
table
checksum
2f7ebcf3
next chunk
Y
N
statement
chunk
chunk
chunk
table
next table
Y
N
方案联盟
方案联盟
• --replicate
• --chunk-time
• --max-lag
• --max-load
• pt-table-checksum h="hostname",u="test",p="test" --
replicate= --databases=test --tables=cscard,giftcard
方案联盟
方案联盟
• MySQL
• MySQL
•
•
方案联盟
• pt-table-sync
方案联盟
方案联盟