问题描述
使用Vagrant进行开发,VM使用一段时间后会冻结。我必须重新装箱才能再次使用它。该文件非常简单明了:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.Box = "ubuntu/xenial32"
config.vm.network "forwarded_port",guest: 80,host: 8080
config.vm.network :private_network,ip: "192.168.68.8"
config.vm.provider "virtualBox" do |v|
v.memory = 8192
v.cpus = 2
end
config.vm.synced_folder "./","/var/www/html",owner: "www-data",group: "www-data"
config.ssh.insert_key = false
config.vm.provision :shell,path: "config/vagrant/bootstrap.sh"
end
和config / vagrant / bootstrap.sh看起来像:
#!/usr/bin/env bash
# Variables
dbnAME=dbname
DBUSER=dbuser
DBPASSWD=dbpassword
apt-get -y install software-properties-common
add-apt-repository -y ppa:ondrej/PHP
apt-get update
apt-get update
debconf-set-selections <<< "MysqL-server MysqL-server/root_password password $DBPASSWD"
debconf-set-selections <<< "MysqL-server MysqL-server/root_password_again password $DBPASSWD"
apt-get -y install MysqL-server
sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/MysqL/MysqL.conf.d/MysqLd.cnf
MysqL -uroot -p$DBPASSWD -e "CREATE DATABASE $dbnAME"
MysqL -uroot -p$DBPASSWD -e "grant all privileges on $dbnAME.* to '$DBUSER'@'%' identified by '$DBPASSWD'"
MysqL -uroot -p$DBPASSWD -e "flush privileges"
sudo apt-get -y install apache2 PHP7.4 PHP7.4-MysqL PHP7.4-mbstring PHP7.4-dom PHP7.4-sqlite PHP7.4-zip PHP7.4-curl PHP7.4-intl
sudo apt-get -y install curl composer zip unzip
sudo PHPenmod pdo_MysqL
sudo service apache2 restart
sudo service MysqL restart
我读了一篇博客文章,建议删除config.ssh.insert_key = false
作为解决方案,但这不起作用。
有什么想法吗?
编辑
没有输出。它会按预期工作约15分钟,然后整个盒子冻结并停止响应(对shell输入无响应,也没有vagrant ssh
)。
解决方法
好的,我想我找到了问题。
我已经更改了这一行:
v.cpus = 2
到
v.cpus = 1
我整天都没有挂断电话。