2

I had to kill an alter table (copy to tmp table) process, because my server was running low on disk space. My ibdata file is now 40 GB big and there are just 8 GB disk space left (no, I can't add disk space atm and I can't use a ram disk, since the server only has 8 GB ram).

From my understanding even I killed the alter table process MySQL will try to complete it as soon as there's enough disk space available.

According to "show status like '%tmp%';" there are 0 tmp tables and 5 tmp files.

According to "SHOW ENGINE INNODB STATUS;" there is just one "transaction 0, not started" entry (and a few file I/O ones).

According to the information schema my table is approx. 20 GB and my ibdata file is 40 GB (I just have a single InnoDB table on this database).

Is there a way to flush all pending changes and/or delete all tmp tables (even show status does not list one)?

I also wondering why my innodb_buffer_pool_size is set to 8 GB (on a 8 GB ram server). I did not alter any InnoDB settings and there are actually none in my my.cnf file, so this seems to be some default value?

Thanks: Lars

4

1 回答 1

1

你是对的,即使你杀死了ALTER TABLE,它仍然会继续尝试创建表的新副本,并且只有在完成该步骤后,该操作才会被“杀死”。没有办法中断它,kill -9除了 mysqld 进程。请注意,如果磁盘空间不足,它将产生错误。我认为它会ALTER TABLE在那个时候中止,清理临时表,然后完成。

至于您关于刷新更改的问题,没有命令可以刷新正在完成的工作ALTER TABLE。对于其他类型的更改,如果您set global innodb_fast_shutdown=0然后关闭 mysqld,这将刷新缓冲池中的所有脏页,清除回滚段中的任何垃圾,并合并更改缓冲区中的任何未决索引更改。但这对ALTER TABLE. 我相信结果将是关闭将等到ALTER TABLE完成。

至于你关于缓冲池的问题,如果你不指定另一个值,默认的 innodb_buffer_pool_size是 128MB。您必须在配置文件中将其设置为 8GB。请注意,Ubuntu 支持/etc/mysql/conf.d存放多个配置文件的目录,并且可以在这些配置文件中的任何一个中进行设置。


您可能有一个很大的 ibdata1 文件,没有占用额外的空间。

临时表在 MySQL 完成后会被清理,但在使用时可能会增加 ibdata1 文件的大小。MySQL 不会收缩 ibdata1 文件,但会将分配的空间重新用于以后的数据。

是的,缩小 ibdata1 的唯一方法是转储所有 InnoDB 数据,关闭 mysqld,物理rm化 ibdata1 文件,然后启动 mysqld,然后重新导入转储数据。多年来,这一直是 MySQL 用户的一大不便。

在您导入数据之前,建议您启用innodb_file_per_table,这样您以后就不会遇到这个困难。MySQL 仍然需要一个用于全局 InnoDB 数据的 ibdata1,但它应该保持较小。并且无论何时您删除或更改任何 InnoDB 表(临时或非临时),它都会回收一些磁盘空间。这实际上在 MySQL 5.6 中默认启用。


mysqld 在几个地方查找 my.cnf:

  1. /var/lib/mysql/my.cnf(数据目录)
  2. /usr/my.cnf(基础目录)
  3. /etc/my.cnf

因此,请检查这些位置是否有另一个 my.cnf 具有神秘设置innodb_buffer_pool_size=8G

有关 MySQL 如何找到 my.cnf 的详细信息,请参阅http://dev.mysql.com/doc/refman/5.6/en/option-files.html

于 2013-11-09T22:04:07.393 回答