目录 一、查看磁盘的时候发现磁盘空间100% 二、 排查的时候:查看是什么文件占用的时候,发现是数据库临时表空间增长的 三、为了避免以后再次出现ibtmp1文件暴涨,限制其大小,需在配置文件加入 四、重启Mysql实例(重启
目录
二、 排查的时候:查看是什么文件占用的时候,发现是数据库临时表空间增长的
备注:默认配置为ibtmp1:12M:autoextend,也就是说在默认情况下支持大文件的系统这个文件大小是可以无限增长的。
mysql> show variables like 'innodb_temp_data_file_path';
+----------------------------+-----------------------+
| Variable_name | Value |
+----------------------------+-----------------------+
| innodb_temp_data_file_path | ibtmp1:12M:autoextend |
+----------------------------+-----------------------+
1 row in set (0.01 sec)
vim /etc/my.cnf
# For advice on how to change settings please see
# Http://dev.Mysql.com/doc/refman/5.7/en/server-configuration-defaults.html[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in Mysql. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#datadir=/var/lib/mysql
#Socket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security risks
#port=31306
datadir=/datah/data/mysqldata/mysql
socket=/var/lib/mysql/mysql.socksymbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pidcharacter-set-server=utf8
collation-server=utf8_general_ci
lower_case_table_names=1
init_connect='SET NAMES utf8'
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_connections=5000
wait_timeout=20000
max_user_connections=5000
max_allowed_packet=128M
thread_stack=262144#为了避免以后再次出现ibtmp1文件暴涨,限制其大小
innodb_temp_data_file_path=ibtmp1:12M:autoextend:max:20G#skip-grant-tables
systemctl restart mysqld
mysql> show variables like 'innodb_temp_data_file_path';
+----------------------------+-------------------------------+
| Variable_name | Value |
+----------------------------+-------------------------------+
| innodb_temp_data_file_path | ibtmp1:12M:autoextend:max:20G |
+----------------------------+-------------------------------+
1 row in set (0.01 sec)
可能导致ibtmp1文件暴涨的情况:
- 用到临时表,当EXPLAIN 查看执行计划结果的 Extra 列中,如果包含 Using Temporary就表示会用到临时表。
- GROUP BY无索引字段或GROUP BY + ORDER BY的子句字段不一样时。
- order by与distinct共用,其中distinct与order by里的字段不一致(主键字段除外)。
- insert into table1 select xxx from table2。
解决办法:
- 限制 ibtmp1 文件大小:innodb_temp_data_file_path = ibtmp1:12M:autoextend:max:20G
- 优化 SQL,避免使用临时表。
- 重启 mysql 实例释放 ibtmp1 文件
来源地址:https://blog.csdn.net/qq_33283901/article/details/129123666
--结束END--
本文标题: Mysql里的ibtmp1文件太大,导致磁盘空间被占满
本文链接: https://lsjlt.com/news/422811.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0