流浪者在一段时间后冻结
vagrant freezes after a while
使用 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
我读了一篇博客 post,它建议删除 config.ssh.insert_key = false
作为解决方案,但这不起作用。
有什么想法吗?
编辑
没有输出。它按预期工作了大约 15 分钟,然后整个框冻结并停止响应(对 shell 输入没有响应,也没有 vagrant ssh
)。
好的,我想我找到了问题。
我已经更改了这一行:
v.cpus = 2
至
v.cpus = 1
而且我一整天都没有挂断电话。
使用 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
我读了一篇博客 post,它建议删除 config.ssh.insert_key = false
作为解决方案,但这不起作用。
有什么想法吗?
编辑
没有输出。它按预期工作了大约 15 分钟,然后整个框冻结并停止响应(对 shell 输入没有响应,也没有 vagrant ssh
)。
好的,我想我找到了问题。
我已经更改了这一行:
v.cpus = 2
至
v.cpus = 1
而且我一整天都没有挂断电话。