简体   繁体   English

MySQL:mysqlcheck 占用太多磁盘空间来执行操作

[英]MySQL: mysqlcheck taking too much disk space to perform operations

Every saturday at 8am I've the following sh script which makes a maintenance on all my databases.每个星期六早上 8 点我都有以下sh脚本,它对我的​​所有数据库进行维护。 I run a mysqlcheck with --check , --optimize and --analyze .我跑mysqlcheck使用--check--optimize--analyze

This is the script:这是脚本:

# check: checks table for integrity errors
mysqlcheck -u root -h mydbendpoint.com -p'mypass' --check --all-databases

# optimize: reorganizes physical storage of table and index data
mysqlcheck -u root -h mydbendpoint.com -p'mypass' --optimize --all-databases

# analyze: rebuild and optimize the performance of indexes
mysqlcheck -u root -h -h mydbendpoint.com -p'mypass' --analyze --all-databases

The thing is that when this .sh is running it takes a lot of disk space.问题是当这个.sh运行时,它需要大量的磁盘空间。 Here's a screenshot of my Amazon RDS free disk space:这是我的 Amazon RDS 可用磁盘空间的屏幕截图:

在此处输入图片说明

Which of the three comands is taking so much disk space to make those mysqlchecks ?三个命令中的哪一个占用了如此多的磁盘空间来进行mysqlchecks --check , --optimize or --analyze ? --check--optimize--analyze Or the three of them?还是他们三个?

I can't find anything about this on the official documentation .我在官方文档上找不到任何关于此的信息

Thanks in advance.提前致谢。

It's the --optimize which uses all that space.这是--optimize使用所有空间。 It basically rebuilds all your tables to regain unused space (data that was deleted), if you've configured your server with innodb_file_per_table如果您已使用innodb_file_per_table配置服务器,它基本上会重建所有表以重新获得未使用的空间(已删除的数据)

This is rarely necessary, you can skip that.这很少需要,您可以跳过它。

That said, you really do this on all your databases ?也就是说,您真的在所有数据库这样做了吗? This should also not be necessary.这也不应该是必要的。 I only have one database where I do a weekly check, and the purpose of this host is solely to verify that my backups work.我只有一个数据库,我每周检查一次,这个主机的目的只是为了验证我的备份是否有效。 Once a week a backup is restored on this host, then the mysqlcheck verifies that all tables work.每周在该主机上恢复一次备份,然后 mysqlcheck 验证所有表是否正常工作。 And that's it.就是这样。 My boss would fire me, if I would do this on servers in production :)如果我在生产中的服务器上这样做,我的老板会解雇我:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM