使用vagrant管理虚拟机导致内存占满,docker的mysql、redis自动启动失败。

博客讲述了在Docker运行MySQL时遇到Restarting状态并报错'No space left on device'的问题。通过`docker logs`定位到错误原因,发现是磁盘空间不足。博主使用`du -sh * | sort -nr | tail`命令找到占用空间最多的目录,发现是vagrant导致的。解决方案是修改Vagrantfile,改变同步文件夹为自定义的较小的vagrantCache目录,避免默认挂载占用过多空间。重新加载Vagrant后问题解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

定位过程:

1.docker ps

mysql的状态变为Restarting (1) 34 seconds ago

2.docker logs 容器id

2021-06-14T11:41:26.576567Z 0 [ERROR] InnoDB: Write to file ./ibtmp1failed at offset 7340032, 1048576 bytes should have been written, only 65536 were written. Operating system error number 28. Check that your OS and file system support files of this size. Check also that the disk is not full or a disk quota exceeded.
2021-06-14T11:41:26.576589Z 0 [ERROR] InnoDB: Error number 28 means 'No space left on device'
2021-06-14T11:41:26.576595Z 0 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
2021-06-14T11:41:26.576603Z 0 [ERROR] InnoDB: Could not set the file size of './ibtmp1'. Probably out of disk space
2021-06-14T11:41:26.576608Z 0 [ERROR] InnoDB: Unable to create the shared innodb_temporary
2021-06-14T11:41:26.576618Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2021-06-14T11:41:27.137686Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2021-06-14T11:41:27.137731Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2021-06-14T11:41:27.137736Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2021-06-14T11:41:27.137742Z 0 [ERROR] Failed to initialize builtin plugins.
2021-06-14T11:41:27.137745Z 0 [ERROR] Aborting

3.发现内存不足之后,cd /到根目录,du -sh *,后来发现

du -s * | sort -nr | tail

这个命令好用

,发现vagrant占用36G,一路找下去,发现到application data目录无线循环,百度~~~,发现一位大佬的博文,问题顺利解决

积累三个命令

du -s * | sort -nr | head 选出排在前面的10个,

du -s * | sort -nr | tail 选出排在后面的10个。

du -s /usr/*  |sort -nr | head

5.大佬实现思路,我们ls,ll等会发现很多和我们c盘目录、文件一样。vagrant提供了将本机目录挂载到虚拟机目录下的功能,默认是将vagrant配置文件所在目录挂载到虚拟机/vagrant目录下。

这个默认绑定挂载真心讨厌,

在和Vagrantfile同级目录(C:\Users\lenovo\)创建一个自己的文件夹,我的(vagrantCache),

然后打开目录到C:\Users\lenovo\.vagrant.d\boxes\centos-VAGRANTSLASH-7\2004.01\virtualbox,修改Vagrantfile文件

config.vm.synced_folder ".", "/vagrant", type: "rsync"

修改为

config.vm.synced_folder "./vagrantCache", "/vagrant", type: "rsync"

6.vagrant reload,

4.参考的大佬博文地址:https://blog.csdn.net/weixin_39553156/article/details/114045181?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-2.control

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不积跬步无以至千里-陕西西安

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值