架構圖
數(shù)據文件(innodb)
每張表都有兩種后綴名的文件,分別為frm后綴與ibd后綴召嘶。
.frm 后綴的文件中存儲了表的表結構信息忿薇。
.ibd 后綴的文件中存放了表的數(shù)據信息與索引信息鹅龄,又叫表空間文件淑仆。
ibdata 所有表公用的數(shù)據文件
如果在配置文件中沒有開啟innodb_file_per_table參數(shù)释涛,在數(shù)據庫對應的目錄中則不會出現(xiàn) .ibd 為后綴的文件,因為默認情況下會共用ibdata1倦沧。
如果在一開始沒有開啟innodb_file_per_table唇撬,并且已經存在某些使用innodb存儲類型的表,那么這些表將共用ibdata1展融。
如果這時局荚,又開啟了innodb_file_per_table,那么原來的表的數(shù)據仍然存在于ibdata1中愈污,新創(chuàng)建的表才會使用單獨的以.ibd為后綴的表空間文件。
bin log
The binary log contains “events” that describe database changes such as table creation operations or changes to table data.
It also contains events for statements that potentially could have made changes (for example, a DELETE which matched no rows),
unless row-based logging is used. The binary log also contains information about how long each statement took that updated data.
The binary log has two important purposes:
For replication, the binary log on a master replication server provides a record of the data changes to be sent to slave servers.
The master server sends the events contained in its binary log to its slaves, which execute those events to make the same data
changes that were made on the master. See Section 16.2, “Replication Implementation”.
Certain data recovery operations require use of the binary log. After a backup has been restored, the events in the binary log
that were recorded after the backup was made are re-executed. These events bring databases up to date from the point of the backup.
See Section 7.5, “Point-in-Time (Incremental) Recovery Using the Binary Log”.
bin log:記錄的是表的修改或表中數(shù)據的修改事件轮傍,包括一些潛在的修改暂雹,例如沒有任何匹配的刪除操作。有兩個重要的目的:
1创夜、replication杭跪,記錄master數(shù)據變更的bin log可以提供給slave服務器。
2驰吓、recovery, 某些數(shù)據恢復操作需要使用bin log涧尿。備份恢復后,重新執(zhí)行備份后記錄的二進制日志中的事件檬贰。 這些事件從備份的角度來說是最新的數(shù)據庫姑廉。
最優(yōu)配置:
For durability and consistency in a replication setup that uses InnoDB with transactions:
If binary logging is enabled, set sync_binlog=1.
Always set innodb_flush_log_at_trx_commit=1.
sync_binlog=1
如果設置為0或N,最好為操作系統(tǒng)準備帶有備用電源
參考:
https://hk.saowen.com/a/4626dd4d7e8d5224b6ac211068d3db0b212e1ebeb573fd04fcd47feed7bcb0d6
http://www.cnblogs.com/xinysu/p/6607658.html
https://dev.mysql.com/doc/refman/5.7/en/binary-log.html
http://www.cnblogs.com/xinysu/p/6607658.html
http://www.cnblogs.com/xinysu/p/6555082.html
http://www.zhdba.com/mysqlops/2012/04/06/innodb-log1/
http://9i9icenter.com/huanqiuNews/599f30ca2277046518e85878