Home Database Mysql Tutorial MySQL架构组成之物理文件组成_MySQL

MySQL架构组成之物理文件组成_MySQL

Jun 01, 2016 pm 01:14 PM
details

一、日志文件
1、错误日志:Error Log
内容:MyQL Server 运行过程中所有较为严重的警告和错误信息,以及MySQL Server 每次启动和关闭的详细信息。
路径:默认存放位置在数据目录下
名称:默认文件名以hostname.err 命名
修改:“--log-error[=file_name]”,修改其存放目录和文件名
扩展:FLUSH LOGS 命令来告诉MySQL 备份旧日志文件并生成新的日志文件。备份文件名以“.old”结尾。
2、二进制日志:Binary Log & Binary Log Index
内容:MySQL 会将所有修改数据库数据的query(query 语句、执行的时间、所消耗的资源,以及相关的事务信息) 以二进制形式记录到日志文件中。
路径:默认存放位置在数据目录下
名称:mysql-bin.******(*代表0~9 之间的某一个数字,来表示该日志的序号)
修改:“--log-bin[=file_name]”,修改其存放目录和文件名
扩展:“--max_binlog_size”设置binlog 的最大存储上限
“--binlog-do-db=db_name”对某个(db_name)数据库记录binlog
“--binlog-ignore-db=db_name”忽略某个(db_name)数据库的binlog 记录
注意:db_name 不是指query 语句更新的数据所在的数据库,而是当前连接所处的数据库
mysql-bin.index 文件(binary log index)的功能是记录所有Binary Log 的绝对路径,保证MySQL 各种线程能够顺利的根据它找到所有需要的Binary Log 文件。
3、更新日志:update log
从版本5.0 开始,MySQL 已经不再支持更新日志了。
4、查询日志:query log
内容:记录MySQL 中所有的query(包括所有的select,体积比较大,开启后影响性能,慎用!)
路径:默认存放位置在数据目录下
名称:默认文件名为hostname.log
修改:“--log[=fina_name]”,修改其存放目录和文件名
扩展:一般只用于跟踪某些特殊的sql 性能问题才会短暂打开该功能。
5、慢查询日志:slow query log
内容:慢查询日志中记录的是执行时间较长的query
路径:默认存放位置在数据目录下
名称:默认文件名为hostname-slow.log
修改:“--log-slow-queries[=file_name]”,修改其存放目录和文件名
扩展:慢查询日志采用的是简单的文本格式,可以通过各种文本编辑器查看其中的内容。其中记录了语句执行的时刻,执行所消耗的时间,执行用户,连接主机等相关信息。
MySQL 还提供了专门用来分析满查询日志的工具程序mysqlslowdump,用来帮助数据库管理人员解决可能存在的性能问题。
6、Innodb 的在线redo 日志:innodb redo log
内容:redo 日志中记录了Innodb 所做的所有物理变更和事务信息,通过redo 日志和undo 信息,Innodb 保证了在任何情况下的事务安全性
路径:默认存放位置在数据目录下
名称:ib_logfile******(*代表0~9 之间的某一个数字,来表示该日志的序号)
修改:通过innodb_log_group_home_dir 来更改设置日志的存放位置,通过innodb_log_files_in_group 设置日志的数量。
扩展:暂不提供

二、数据文件
1、“.frm”文件
与表相关的元数据(meta)信息都存放在“.frm”文件中,包括表结构的定义信息等(与表一对一存在)。
2、“.MYD”文件
“.MYD”文件是MyISAM 存储引擎专用,存放MyISAM 表的数据(与表一对一存在)。
3、“.MYI”文件
“.MYI”文件也是专属于MyISAM 存储引擎的,主要存放MyISAM 表的索引相关信息(与表一对一存在)。
4、“.ibd”文件和ibdata 文件
这两种文件都是存放Innodb 数据的文件,之所以有两种文件来存放Innodb 的数据(包括索引),是因为Innodb 的数据存储方式能够通过配置来决定是使用共享表(ibdata文件)空间存放存储数据,还是独享表(.ibd文件,与表一对一存在)空间存放存储数据。

三、Replication相关文件
1、master.info 文件
master.info 文件存在于Slave 端的数据目录下,里面存放了该Slave 的Master 端的相关信息,包括Master 的主机地址,连接用户,连接密码,连接端口,当前日志位置,已经读取到的日志位置等信息。
2、relay log 和relay log index
mysql-relay-bin.xxxxxn 文件用于存放Slave 端的I/O 线程从Master 端所读取到的Binary Log 信息,然后由Slave 端的SQL 线程从该relay log 中读取并解析相应的日志信息,转化成Master 所执行的SQL 语句,然后在Slave 端应用。
mysql-relay-bin.index 文件的功能类似于mysql-bin.index ,同样是记录日志的存放位置的绝对路径,只不过他所记录的不是Binary Log,而是Relay Log。
3、relay-log.info 文件
类似于master.info,它存放通过Slave 的I/O 线程写入到本地的relay log 的相关信息。供Slave 端的SQL 线程以及某些管理操作随时能够获取当前复制的相关信息。

四、其他文件
1、system config file
MySQL 的系统配置文件一般都是“my.cnf”,Unix/Linux 下默认存放在"/etc"目录下,Windows 环境一般存放在“c:/windows”目录下面。
2、pid file
pid file 是mysqld 应用程序在Unix/Linux 环境下的一个进程文件,和许多其他Unix/Linux 服务端程序一样,存放着自己的进程id。
3、socket file
socket 文件也是在Unix/Linux 环境下才有的,用户在Unix/Linux 环境下客户端连接可以不通过TCP/IP 网络而直接使用Unix Socket 来连接MySQL。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Can mysql and mariadb coexist Can mysql and mariadb coexist Apr 08, 2025 pm 02:27 PM

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

See all articles