The disk structure of the structure in the MySQL database

 First look at the architecture diagram of the disk structure

 

1). System Tablespace

        The system tablespace is the storage area for the change buffer. It may also contain table and index data if the table is created in a system tablespace rather than a file-per-table or general tablespace. ( InnoDB data dictionary, undolog , etc. are also included in MySQL5.x version )
        Parameters: innodb_data_file_path
        System table space, the default file name is ibdata1 .

2). File-Per-Table Tablespaces

        If the innodb_file_per_table switch is turned on , a file-per-table tablespace contains the data and indexes for a single InnoDB table and is stored in a single data file on the file system.

        Switch parameter: innodb_file_per_table , this parameter is enabled by default.

3). General Tablespaces

        General table space, you need to create a general table space through the CREATE TABLESPACE syntax, you can specify the table space when creating a table.

       Create tablespace:

        CREATE TABLESPACE ts_name ADD DATAFILE 'file_name' ENGINE = engine_name;

       Specify empty table when creating table:

        CREATE TABLE xxx ... TABLESPACE ts_name;

4). Undo Tablespaces

        To undo tablespaces, the MySQL instance will automatically create two default undo tablespaces (initial size 16M ) during initialization to store undo log logs.

5). Temporary Tablespaces

        InnoDB uses session temporary tablespaces and global temporary tablespaces. Store data such as temporary tables created by users.

6). Doublewrite Buffer Files

        Double-write buffer. Before the innoDB engine flushes the data pages from the Buffer Pool to the disk, it first writes the data pages into the double-write buffer file, which is convenient for recovering data when the system is abnormal.

7). Redo Log

        Redo logs are used to achieve transaction persistence. The log file consists of two parts: redo log buffer (redo log
buffer ) and redo log files ( redo log ) , the former is in memory and the latter is in disk. When the transaction is committed, all
Any modification information will be stored in the log , which is used for data recovery when an error occurs when flushing dirty pages to disk .
        
        Write redo log files in a round-robin fashion, involving two files:
        ib_logfile0 and ib_logfile1

Guess you like

Origin blog.csdn.net/weixin_59526725/article/details/126036706