How to View MySQL Temp Files and Temp Tables in Linux

Below is my MySQL Server's status and configuration. But I can not see
anything under /tmpfs/, it is showing empty to me.

here is the result of "ls -al"

drwxrwxrwx   2 mysql mysql    60 Apr  7 17:43 tmpfs
Could anyone tell me how to check the status of temp files and temp tables

on disk?

----
mysql> SHOW global STATUS LIKE 'created_tmp%';
+-------------------------+-------+
| Variable_name           | Value |
+-------------------------+-------+
| Created_tmp_disk_tables | 4682  |
| Created_tmp_files       | 291   |
| Created_tmp_tables      | 10997 |
+-------------------------+-------+
mysql> SHOW variables LIKE '%tmp%';
+-------------------+----------+
| Variable_name     | Value    |
+-------------------+----------+
| bdb_tmpdir        | /tmpfs/  |
| max_tmp_tables    | 32       |
| slave_load_tmpdir | /tmpfs/  |
| tmp_table_size    | 67108864 |
| tmpdir            | /tmpfs/  |
+-------------------+----------+
 show variables like '%temp%';
+----------------------------+-----------------------+
| Variable_name              | Value                 |
+----------------------------+-----------------------+
| avoid_temporal_upgrade     | OFF                   |
| innodb_temp_data_file_path | ibtmp1:12M:autoextend |
| show_old_temporals         | OFF                   |
+----------------------------+-----------------------+
3 rows in set (0.01 sec)


Where InnoDB Stores Temporary Files

As of MySQL 5.7.1, non-compressed InnoDB temporary tables are stored in a temporary tablespace file named ibtmp1, which is located in the MySQL data directory (datadir) by default. The innodb_temp_data_file_path option can be used at startup to specify a different file name and location. Compressed InnoDB temporary tables are stored in their own independent tablespace files (.ibd files) in the path specified by the TMPDIR environment variable.

If an ALTER TABLE operation on an InnoDB table uses the ALGORITHM=COPY technique, InnoDB creates a temporary copy of the table in the same directory as the original table. Temporary table file names begin with an #sql- prefix and only appear briefly during the ALTER TABLE operation.

If an ALTER TABLE operation rebuilds an InnoDB table using the ALGORITHM=INPLACE technique (online DDL), InnoDBcreates an intermediate copy of the table the same directory as the original table. Intermediate table file names begin with an #sql-ib prefix and only appear briefly during the ALTER TABLE operation.

ALTER TABLE operations that rebuild an InnoDB table using the ALGORITHM=INPLACE technique (online DDL) also create temporary sort files in the MySQL temporary directory ($TMPDIR on Unix, %TEMP% on Windows, or the directory specified by the --tmpdir configuration option). If the temporary directory is not large enough to hold such files, you may need to reconfigure tmpdir. Alternatively, you can define a separate temporary directory for InnoDB online ALTER TABLEoperations using the innodb_tmpdir configuration option. This option was introduced in MySQL 5.7.11 to help avoid temporary directory overflows that could occur as a result of large temporary sort files created during online ALTER TABLE operations. innodb_tmpdir can be configured dynamically using a SET GLOBAL or SET SESSION statement.

The innodb_tmpdir option is not applicable to intermediate table files, which are always created in the same directory as the original table.

In replication environments, only consider replicating an innodb_tmpdir setting if all servers have the same operating system environment. Otherwise, replicating an innodb_tmpdir setting could result in a replication failure when running online ALTER TABLE operations. If server operating environments differ, it is recommended that you configure innodb_tmpdir on each server individually.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值