阿里云mysql空间清理的方法
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei"; text-align: center;'><img title="阿里云mysql空间清理的方法" alt="阿里云mysql空间清理的方法" id="theimg" src="https://zhuji.jb51.net/uploads/img/202305/87e904df2976c5c0132092ec404b1097.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
今天收到阿里云磁盘告警通知,查看了一个100G的空间已达到80G的使用量,如果决定删除2018年1月1日之前的数据,可delete后,再去查看发现磁盘可用空间并没有减少,还飞速的上涨,这可把我急坏了,不一会儿数据库就锁死了。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
敢忙找度娘,原来delete后,磁盘不会减少,还得执行一下<code style='margin: 3px auto 0px; padding: 2px 4px; outline: none; font-style: inherit; font-weight: inherit; background: rgb(249, 242, 244); width: 640px; line-height: 1.5; clear: both; font-size: 12px; border: 1px solid rgb(204, 204, 204); color: rgb(199, 37, 78); border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;'> OPTIMIZE TABLE +表名</code>,以后找到救星了,可执行此命信不成功,原来是空间不足,数据库存补锁不能执行这条指令,一下没了头绪,如是决定先把服务器暂停,就在暂停时奇迹发生了,可用空间有5G多了,这下可以执行<code style='margin: 3px auto 0px; padding: 2px 4px; outline: none; font-style: inherit; font-weight: inherit; background: rgb(249, 242, 244); width: 640px; line-height: 1.5; clear: both; font-size: 12px; border: 1px solid rgb(204, 204, 204); color: rgb(199, 37, 78); border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;'>OPTIMIZE TABLE </code>来优化表了,可执行3分钟后,指令返回错误,一看空间又不足了,又表锁住了。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
最张决定,先导出一个表,转存sql文件,足足导了40分钟才导完,然后删除了这个表,服务器一下可用空间多了50G,于是再执行运行sql文件,将数据还原,足足执行了150分钟。执行完后磁盘使了70G, 再执行 <code style='margin: 3px auto 0px; padding: 2px 4px; outline: none; font-style: inherit; font-weight: inherit; background: rgb(249, 242, 244); width: 640px; line-height: 1.5; clear: both; font-size: 12px; border: 1px solid rgb(204, 204, 204); color: rgb(199, 37, 78); border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;'>OPTIMIZE TABLE +表名</code> ,由于其中一张表太大了,执行了接近40分钟,此间磁盘使用率一度飙到100%,好在还是刚才度过。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
delete 数据后mysql空间并不会减少,要执行<code style='margin: 3px auto 0px; padding: 2px 4px; outline: none; font-style: inherit; font-weight: inherit; background: rgb(249, 242, 244); width: 640px; line-height: 1.5; clear: both; font-size: 12px; border: 1px solid rgb(204, 204, 204); color: rgb(199, 37, 78); border-radius: 0px; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;'>OPTIMIZE TABLE </code>才行,OPTIMIZE TABLE其间会产生大量临时文件,如果原表体量很大,会占用大量的空间,所以执行这条时,一定要在磁盘空间充足时。不然执行其它会引起磁盘不足,锁死数据库,而导致,执行失败</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
<strong>总结</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对服务器之家的支持。</p>
頁:
[1]