Linux实例磁盘空间满和inode满的问题排查方法
Last updated
2023-01-28 10:42:36
{"value":"> \u5728Linux\u7cfb\u7edf\u7684\u4e91\u670d\u52a1\u5668QVM\u5b9e\u4f8b\u5185\u521b\u5efa\u6587\u4ef6\u65f6\uff0c\u51fa\u73b0\u7c7b\u4f3c\u5982\u4e0b\u7a7a\u95f4\u4e0d\u8db3\u7684\u63d0\u793a\u3002\nNo space left on device \u2026\n\n### \u95ee\u9898\u539f\u56e0\n\n\u5bfc\u81f4\u8be5\u95ee\u9898\u7684\u53ef\u80fd\u539f\u56e0\u5982\u4e0b\u6240\u793a\uff1a\n\n1.\u78c1\u76d8\u5206\u533a\u7a7a\u95f4\u4f7f\u7528\u7387\u8fbe\u5230\u767e\u5206\u4e4b\u767e\u3002\n\n2.\u78c1\u76d8\u5206\u533ainode\u4f7f\u7528\u7387\u8fbe\u5230\u767e\u5206\u4e4b\u767e\u3002\n\n3.\u5b58\u5728\u50f5\u5c38\u6587\u4ef6\u3002\n\n\t\u8bf4\u660e\uff1a\u5df2\u5220\u9664\u6587\u4ef6\u56e0\u53e5\u67c4\u88ab\u5360\u7528\u672a\u91ca\u653e\uff0c\u5bfc\u81f4\u76f8\u5e94\u7a7a\u95f4\u672a\u91ca\u653e\u7684\u6587\u4ef6\u3002\n\n4.\u6302\u8f7d\u70b9\u8986\u76d6\u3002\n\n\t\u8bf4\u660e\uff1a\u5728\u539f\u6709\u6587\u4ef6\u7cfb\u7edf\u7684\u76f8\u5e94\u76ee\u5f55\u4e0b\u5df2\u7ecf\u5b58\u5728\u5927\u91cf\u6587\u4ef6\u3002\u6302\u8f7d\u65b0\u78c1\u76d8\u540e\uff0c\u5bfc\u81f4\u4f7f\u7528df\u547d\u4ee4\u80fd\u7edf\u8ba1\u5230\u76f8\u5173\u7a7a\u95f4\u4f7f\u7528\uff0c\u800c\u4f7f\u7528su\u547d\u4ee4\u7edf\u8ba1\u4e0d\u5230\u3002\n\n### \u89e3\u51b3\u65b9\u6848\n\n\u8981\u89e3\u51b3\u8be5\u95ee\u9898\uff0c\u8bf7\u6839\u636e\u4e0d\u540c\u7684\u95ee\u9898\u539f\u56e0\uff0c\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fdb\u884c\u5904\u7406\uff1a\n\n1.\u00a0\u5206\u533a\u5bb9\u91cf\u6ee1\n\n2.\u00a0inode\u5bb9\u91cf\u6ee1\n\n3.\u00a0\u4fee\u6539inode\u6570\u91cf\n\n4.\u00a0\u50f5\u5c38\u6587\u4ef6\u5206\u6790\u5220\u9664\n\n5.\u00a0\u6302\u8f7d\u70b9\u8986\u76d6\n\n#### \u5206\u533a\u5bb9\u91cf\u6ee1\u7684\u5904\u7406\n\n1.\u767b\u5f55\u670d\u52a1\u5668\uff0c\u4f7f\u7528df -h\u547d\u4ee4\u67e5\u770b\u78c1\u76d8\u4f7f\u7528\u7387\uff0c\u5176\u4e2d\u7684Mounted on\u6307\u6302\u8f7d\u7684\u76ee\u5f55\u3002\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek9%2FLinux%E5%AE%9E%E4%BE%8B%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4%E6%BB%A1%E5%92%8Cinode%E6%BB%A1%E7%9A%84%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5%E6%96%B9%E6%B3%95%2F1.png)\n\n2.\u8fdb\u5165\u6839\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u6307\u4ee4\uff0c\u9010\u7ea7\u67e5\u770b\u54ea\u4e2a\u76ee\u5f55\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u8f83\u5927\uff0c\u8fdb\u5165\u76f8\u5e94\u7684\u76ee\u5f55\uff0c\u76f4\u5230\u627e\u5230\u6700\u7cbe\u786e\u7684\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u3002\n\n\tdu -sh\n\n\u7cfb\u7edf\u663e\u793a\u7c7b\u4f3c\u5982\u4e0b.\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek9%2FLinux%E5%AE%9E%E4%BE%8B%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4%E6%BB%A1%E5%92%8Cinode%E6%BB%A1%E7%9A%84%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5%E6%96%B9%E6%B3%95%2F2.png)\n\n\n3.\u6700\u540e\uff0c\u7ed3\u5408\u4e1a\u52a1\u60c5\u51b5\u7b49\u5224\u65ad\u5bf9\u76f8\u5173\u6587\u4ef6\u6216\u76ee\u5f55\u8fdb\u884c\u5220\u9664\uff0c\u6216\u8005\u8d2d\u4e70\u66f4\u5927\u7684\u6570\u636e\u76d8\u5206\u62c5\u5904\u7406\u3002\n\n#### inode\u5bb9\u91cf\u6ee1\u7684\u5904\u7406\n\u901a\u8fc7\u5982\u4e0b\u64cd\u4f5c\uff0c\u89e3\u51b3inode\u5bb9\u91cf\u6ee1\u7684\u95ee\u9898\u3002\n\n**\u67e5\u8be2inode\u4f7f\u7528\u60c5\u51b5**\n\nLinux\u7684inode\u8282\u70b9\u4e2d\uff0c\u8bb0\u5f55\u4e86\u6587\u4ef6\u7684\u7c7b\u578b\u3001\u5927\u5c0f\u3001\u6743\u9650\u3001\u6240\u6709\u8005\u3001\u6587\u4ef6\u8fde\u63a5\u7684\u6570\u76ee\u3001\u521b\u5efa\u65f6\u95f4\u4e0e\u66f4\u65b0\u65f6\u95f4\u7b49\u91cd\u8981\u7684\u4fe1\u606f\uff0c\u8fd8\u6709\u4e00\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u5185\u5bb9\u5c31\u662f\u6307\u5411\u6570\u636e\u5757\u7684\u6307\u9488\u3002\u4e00\u822c\u60c5\u51b5\u4e0d\u9700\u8981\u7279\u6b8a\u914d\u7f6e\uff0c\u5982\u679c\u5b58\u653e\u6587\u4ef6\u5f88\u591a\uff0c\u5219\u9700\u8981\u914d\u7f6e\u3002\u6709\u65f6\u78c1\u76d8\u7a7a\u95f4\u6709\u5269\u4f59\u4f46\u662f\u4e0d\u80fd\u5b58\u653e\u6587\u4ef6\uff0c\u53ef\u80fd\u662f\u7531\u4e8einode\u8017\u5c3d\u6240\u81f4\u3002\n\n1.\u6267\u884cdf -i\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u8be2inode\u7684\u4f7f\u7528\u60c5\u51b5\u3002 \n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek9%2FLinux%E5%AE%9E%E4%BE%8B%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4%E6%BB%A1%E5%92%8Cinode%E6%BB%A1%E7%9A%84%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5%E6%96%B9%E6%B3%95%2F3.png)\n\n2.\u5982\u679cinode\u4f7f\u7528\u7387\u8fbe\u5230\u6216\u8005\u63a5\u8fd1100%\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u8fdb\u884c\u5904\u7406\uff1a\n\n\uff081\uff09\u6e05\u9664inode\u5360\u7528\u9ad8\u7684\u6587\u4ef6\u6216\u8005\u76ee\u5f55\n\n\uff082\uff09\u4fee\u6539inode\u6570\u91cf\n\n**\u6e05\u9664inode\u5360\u7528\u9ad8\u7684\u6587\u4ef6\u6216\u8005\u76ee\u5f55**\n\n\u5982\u679c\u4e0d\u65b9\u4fbf\u683c\u5f0f\u5316\u78c1\u76d8\u4ee5\u589e\u52a0inode\u6570\u91cf\uff0c\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u6b65\u9aa4\uff0c\u6e05\u7406inode\u5360\u7528\u91cf\u9ad8\u7684\u6587\u4ef6\u6216\u8005\u76ee\u5f55\u3002\n\n1.\u767b\u5f55\u670d\u52a1\u5668\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5206\u6790\u6839\u76ee\u5f55\u4e0b\u7684\u6bcf\u4e2a\u4e8c\u7ea7\u76ee\u5f55\u4e0b\u6709\u591a\u5c11\u4e2a\u6587\u4ef6\u3002\n\n\tfor i in \/; do echo $i; find $i | wc -l; done\n\n\u7cfb\u7edf\u663e\u793a\u7c7b\u4f3c\u5982\u4e0b\u3002 \n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek9%2FLinux%E5%AE%9E%E4%BE%8B%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4%E6%BB%A1%E5%92%8Cinode%E6%BB%A1%E7%9A%84%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5%E6%96%B9%E6%B3%95%2F4.png)\n\n2.\u7136\u540e\uff0c\u9010\u5c42\u8fdb\u5165inode\u5360\u7528\u6700\u9ad8\u7684\u76ee\u5f55\uff0c\u7ee7\u7eed\u6267\u884c\u4e0a\u8ff0\u6307\u4ee4\uff0c\u9010\u6b65\u5b9a\u4f4d\u5360\u7528\u8fc7\u9ad8\u7a7a\u95f4\u7684\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u6700\u540e\u8fdb\u884c\u76f8\u5e94\u6e05\u7406\u3002\n\n#### \u4fee\u6539inode\u6570\u91cf\n\n\u5982\u679c\u4e0d\u5141\u8bb8\u6e05\u7406\u78c1\u76d8\u4e2d\u7684\u6587\u4ef6\uff0c\u6216\u8005\u6e05\u7406\u540einode\u4f7f\u7528\u7387\u4ecd\u7136\u8f83\u9ad8\uff0c\u5219\u9700\u8981\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\uff0c\u589e\u52a0inode\u8282\u70b9\u6570\u91cf\u3002\n\n\u8bf4\u660e\uff1ainode\u7684\u8c03\u6574\u9700\u8981\u91cd\u65b0\u683c\u5f0f\u5316\u78c1\u76d8\uff0c\u8bf7\u786e\u4fdd\u6570\u636e\u5df2\u7ecf\u5f97\u5230\u6709\u6548\u5907\u4efd\u540e\uff0c\u518d\u8fdb\u884c\u4ee5\u4e0b\u64cd\u4f5c\u3002\n\n1.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5378\u8f7d\u7cfb\u7edf\u6587\u4ef6\u3002\n\n\tumount \/home\n\n2.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u91cd\u65b0\u5efa\u7acb\u6587\u4ef6\u7cfb\u7edf\uff0c\u6307\u5b9ainode\u8282\u70b9\u6570\u3002\n\n\tmkfs.ext3 \/dev\/xvdb -N 1638400\n\n\u8bf4\u660e\uff1a\u672c\u6587\u6307\u5b9ainode\u8282\u70b9\u65701638400\uff0c\u73b0\u573a\u5b9e\u9645\u73af\u5883\u8bf7\u4ee5\u5b9e\u9645\u4e3a\u51c6\u3002\n\n3.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4fee\u6539fstab\u6587\u4ef6\u3002\n\n\tvim \/etc\/fstab\n\n4.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770b\u4fee\u6539\u540e\u7684inode\u8282\u70b9\u6570\u3002\n\n\tdumpe2fs -h \/dev\/xvdb | grep node\n\n\u7cfb\u7edf\u663e\u793a\u7c7b\u4f3c\u5982\u4e0b\u3002 \n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek9%2FLinux%E5%AE%9E%E4%BE%8B%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4%E6%BB%A1%E5%92%8Cinode%E6%BB%A1%E7%9A%84%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5%E6%96%B9%E6%B3%95%2F5.png)\n\n#### \u50f5\u5c38\u6587\u4ef6\u5206\u6790\u4e0e\u5220\u9664\n\u5982\u679c\u78c1\u76d8\u548cinode\u90fd\u6ca1\u6709\u95ee\u9898\uff0c\u5219\u9700\u8981\u67e5\u770b\u662f\u5426\u5b58\u5728\u672a\u88ab\u6e05\u9664\u53e5\u67c4\u7684\u50f5\u5c38\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u5b9e\u9645\u4e0a\u5df2\u7ecf\u88ab\u5220\u9664\uff0c\u4f46\u662f\u6709\u670d\u52a1\u7a0b\u5e8f\u5728\u4f7f\u7528\u8fd9\u4e9b\u6587\u4ef6\uff0c\u5bfc\u81f4\u8fd9\u4e9b\u6587\u4ef6\u4e00\u76f4\u88ab\u5360\u7528\uff0c\u65e0\u6cd5\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002\u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u8fc7\u591a\uff0c\u4f1a\u5360\u7528\u5f88\u5927\u7684\u78c1\u76d8\u7a7a\u95f4\u3002\u53c2\u8003\u4ee5\u4e0b\u6b65\u9aa4\u67e5\u770b\u5e76\u5220\u9664\u50f5\u5c38\u6587\u4ef6\u3002\n\n1.\u8fdc\u7a0b\u767b\u5f55\u670d\u52a1\u5668\u3002\n\n2.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5b89\u88c5lsof\u3002\n\n\tyum install lsof\u00a0-y\n\n3.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770b\u50f5\u5c38\u6587\u4ef6\u5360\u7528\u60c5\u51b5\u3002\n\n\tlsof |grep delete | more\n\n\u7cfb\u7edf\u663e\u793a\u7c7b\u4f3c\u5982\u4e0b\u3002 \n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek9%2FLinux%E5%AE%9E%E4%BE%8B%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4%E6%BB%A1%E5%92%8Cinode%E6%BB%A1%E7%9A%84%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5%E6%96%B9%E6%B3%95%2F6.png)\n\n4.\u5982\u679c\u50f5\u5c38\u6587\u4ef6\u8fc7\u591a\uff0c\u4f1a\u5360\u7528\u5f88\u5927\u7684\u78c1\u76d8\u7a7a\u95f4\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u91ca\u653e\u53e5\u67c4\uff0c\u4ee5\u6e05\u9664\u50f5\u5c38\u6587\u4ef6\u3002\n\n\u7a0bl\u00a0\u91cd\u542f\u670d\u52a1\u5668\uff0c\u9a8c\u8bc1\u6548\u679c\u3002\u91cd\u542f\u670d\u52a1\u5668\uff0c\u7cfb\u7edf\u4f1a\u9000\u51fa\u73b0\u6709\u7684\u8fdb\u7a0b\uff0c\u5f00\u673a\u540e\u91cd\u65b0\u52a0\u8f7d\u3002\u8be5\u8fc7\u7a0b\u4f1a\u91ca\u653e\u8c03\u7528\u7684deleted\u6587\u4ef6\u7684\u53e5\u67c4\u3002\n\nl\u00a0\u6839\u636elsof\u547d\u4ee4\u5217\u51fa\u7684pid\u8fdb\u7a0b\u53f7\uff0c\u4f7f\u7528kill\u547d\u4ee4\u6b63\u5e38\u505c\u6b62\u6216\u7ed3\u675f\u5360\u7528\u8fd9\u4e9b\u6587\u4ef6\u7684\u670d\u52a1\u8fdb\u7a0b\u3002\n\n\u8bf4\u660e\uff1a\u5982\u679c\u670d\u52a1\u5668\u6b63\u5728\u8fd0\u884c\u4e1a\u52a1\uff0c\u53ef\u80fd\u4f1a\u5f71\u54cd\u5230\u4e1a\u52a1\uff0c\u8bf7\u614e\u91cd\u64cd\u4f5c\u3002\n\n#### \u6302\u8f7d\u70b9\u8986\u76d6\n\n\u5148\u53d6\u6d88\u78c1\u76d8\u6302\u8f7d\uff0c\u518d\u68c0\u67e5\u539f\u6302\u8f7d\u76ee\u5f55\u4e0b\u7684\u7a7a\u95f4\u5360\u7528\u60c5\u51b5\n"}