为什么80%的码农都做不了架构师?>>>
binlog 的主要用途是归档日志,二进制日志,也称二进制日志,记录对数据发生或潜在发生更改的SQL语句,并以二进制的形式保存在磁盘中。
binlog 文件位置:默认存放位置为数据库文件所在目录下;
binary log 文件中各种事件含义,以下描述简单描述了每个事件类型的含义:
-
UNKNOWN_EVENT
此事件类型从来都不应该发生。不会写入binary log。如果从二进制日志中读取到不能识别为其他任何的事件,则视为:
UNKNOWN_EVENT
-
START_EVENT_V3
A descriptor event that is written to the beginning of the each binary log file. (In MySQL 4.0 and 4.1, this event is written only to the first binary log file that the server creates after startup.) This event is used in MySQL 3.23 through 4.1 and superseded in MySQL 5.0 by
FORMAT_DESCRIPTION_EVENT
. -
QUERY_EVENT
当更新语句完成时写入。
-
STOP_EVENT
当
mysqld
停止时写入。 -
ROTATE_EVENT
当
mysqld
切换到一个新的binary log 文件时写入。switches to a new binary log file. This occurs when someone issues aFLUSH LOGS
statement or the current binary log file becomes too large. The maximum size is determined by max_binlog_size. -
INTVAR_EVENT
Written every time a statement uses an
AUTO_INCREMENT
column or theLAST_INSERT_ID()
function; precedes other events for the statement. This is written only before aQUERY_EVENT
and is not used with row-based logging. AnINTVAR_EVENT
is written with a "subtype" in the event data part:-
INSERT_ID_EVENT
indicates the value to use for anAUTO_INCREMENT
column in the next statement. -
LAST_INSERT_ID_EVENT
indicates the value to use for theLAST_INSERT_ID()
function in the next statement.
-
-
LOAD_EVENT
Used for
LOAD DATA INFILE
statements in MySQL 3.23. See LOAD DATA INFILE Events. -
SLAVE_EVENT
不曾使用。
-
CREATE_FILE_EVENT
Used for
LOAD DATA INFILE
statements in MySQL 4.0 and 4.1. See LOAD DATA INFILE Events. -
APPEND_BLOCK_EVENT
Used for
LOAD DATA INFILE
statements as of MySQL 4.0. See LOAD DATA INFILE Events. -
EXEC_LOAD_EVENT
Used for
LOAD DATA INFILE
statements in 4.0 and 4.1. See LOAD DATA INFILE Events. -
DELETE_FILE_EVENT
Used for
LOAD DATA INFILE
statements as of MySQL 4.0. See LOAD DATA INFILE Events. -
NEW_LOAD_EVENT
Used for
LOAD DATA INFILE
statements in MySQL 4.0 and 4.1. See LOAD DATA INFILE Events. -
RAND_EVENT
Written every time a statement uses the
RAND()
function; precedes other events for the statement. Indicates the seed values to use for generating a random number withRAND()
in the next statement. This is written only before aQUERY_EVENT
and is not used with row-based logging. -
USER_VAR_EVENT
Written every time a statement uses a user variable; precedes other events for the statement. Indicates the value to use for the user variable in the next statement. This is written only before a
QUERY_EVENT
and is not used with row-based logging. -
FORMAT_DESCRIPTION_EVENT
A descriptor event that is written to the beginning of the each binary log file. This event is used as of MySQL 5.0; it supersedes
START_EVENT_V3
. -
XID_EVENT
Generated for a commit of a transaction that modifies one or more tables of an XA-capable storage engine. Normal transactions are implemented by sending a
QUERY_EVENT
containing aBEGIN
statement and aQUERY_EVENT
containing aCOMMIT
statement (or aROLLBACK
statement if the transaction is rolled back). -
BEGIN_LOAD_QUERY_EVENT
Used for
LOAD DATA INFILE
statements as of MySQL 5.0. See LOAD DATA INFILE Events. -
EXECUTE_LOAD_QUERY_EVENT
Used for
LOAD DATA INFILE
statements as of MySQL 5.0. See LOAD DATA INFILE Events. -
TABLE_MAP_EVENT
Used for row-based binary logging. This event precedes each row operation event. It maps a table definition to a number, where the table definition consists of database and table names and column definitions. The purpose of this event is to enable replication when a table has different definitions on the master and slave. Row operation events that belong to the same transaction may be grouped into sequences, in which case each such sequence of events begins with a sequence of
TABLE_MAP_EVENT
events: one per table used by events in the sequence. -
PRE_GA_WRITE_ROWS_EVENT
WRITE_ROWS_EVENT
的过时版本。 -
PRE_GA_UPDATE_ROWS_EVENT
UPDATE_ROWS_EVENT
的过时版本。 -
PRE_GA_DELETE_ROWS_EVENT
DELETE_ROWS_EVENT
的过时版本。 -
WRITE_ROWS_EVENT
用于基于行的binary logging。此事件记录在单表中的插入行。
-
UPDATE_ROWS_EVENT
用于基于行的binary logging。此事件记录在单表中的更新行。
-
DELETE_ROWS_EVENT
Used for row-based binary logging. This event logs deletions of rows in a single table.
-
INCIDENT_EVENT
Used to log an out of the ordinary event that occurred on the master. It notifies the slave that something happened on the master that might cause data to be in an inconsistent state.
-
HEARTBEAT_LOG_EVENT
master 发消息给 slave 并告知slave master 是存活的。不写入日志文件;