我有一个Ubuntu 14.04 Vagrant。大多数情况下,它似乎都很好,但是每隔几天我就会遇到麻烦。当Vagrant试图将ssh放入机器时,它将得到一个
Warning: Remote connection disconnect. Retrying...每隔几秒钟就会打印一次,直到我看到一个错误,说它超时了,等待机器启动。我发现了这个问题,它建议用以下方式引导gui:
config.vm.provider :virtualbox do |vb|
vb.gui = true
end看看是什么阻碍了VM的发展。看起来VM在调用url_helper.py时被卡住了
url_helper.py[WARNING]: Calling 'http://169.254.168.254/2009-04-04/meta/instance-id'
failed [101/120s]:request error [(<urllib3.connectionpool.HTTPConnectionPool object
at 0x7ff2d6691450>, 'Connection to 169.254.168.254 timed out.
(connect timeout=50.0)')]
url_helper.py[WARNING]: Calling 'http://169.254.168.254/2009-04-04/meta/instance-id'
failed [119/120s]:request error [(<urllib3.connectionpool.HTTPConnectionPool object
at 0x7ff2d6682f50>, 'Connection to 169.254.168.254 timed out.
(connect timeout=50.0)')]
DataSourceEc2.py[CRITICAL]: Giving up on md from
['http://169.254.168.254/2009-04-04/meta/instance-id'] after 120s这会继续被打印出来,直到瓦格兰特失败为止:
<machine name>: Warning: Remote connection disconnect. Retrying...
<machine name>: Warning: Remote connection disconnect. Retrying...
<machine name>: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that Vagrant was
unable to communicate with the guest machine within the configured
("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that Vagrant had
when attempting to connect to the machine. These errors are usually good hints
as to what may be wrong.
If you're using a custom box, make sure that networking is properly working and
you're able to connect to the machine. It is a common problem that networking
isn't setup properly in these boxes. Verify that authentication configurations
are also setup properly, as well.
If the box appears to be booting properly, you may want to increase the timeout
("config.vm.boot_timeout") value.但不久之后,登录屏幕上就会继续。此时,我可以登录或ssh登录,但有些事情是不正确的。即。共享文件夹没有挂载。我唯一能找到的解决办法就是摧毁和修复机器:
vagrant destroy -f && vagrant up这可能需要一段时间,这取决于机器的配置。
以前有没有人遇到过这个问题?对如何解决这个问题有什么建议吗?
这是我现在的Vagrantfile:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "trusty64"
config.vm.box_url = "/media/resources/Development/Vagrant/Boxes/trusty64.box"
config.vm.define "name" do |name|
name.vm.hostname = "name"
name.vm.network :private_network, ip: "192.168.45.12"
name.vm.network :forwarded_port, guest: 7070, host: 7070
name.vm.network :forwarded_port, guest: 7443, host: 7443
name.vm.provider :virtualbox do |vb|
vb.name = "name"
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "provisioning/playbook.yml"
ansible.sudo = true
ansible.verbose = "v"
ansible.extra_vars = "@provisioning/user_vars.yml"
end
end顺便说一句,上面链接的问题的另一个答案(通过vboxmanage将enter键发送到虚拟机没有工作,因为我对这个问题的提问者有不同的问题)。
UPDATE:按照@ElfElix的建议,我查看了/etc/网络/接口,并看到了以下内容:
#VAGRANT-BEGIN
#The contents below are automatically generated by Vagrant. Do not modify
auto eth1
iface eth1 inet static
address 192.168.45.11
netmask 255.255.255.0
#VAGRANT-END虽然,在/etc/network/interfaces.d/eth0.cfg中是:
# The primary network interface
auto eth0
iface eth0 inet dhcp我试图删除这个文件以禁用DHCP,但这只会使它变得更糟。vagrant up不仅失败了,因为它无法连接,而且在等待了一段时间之后,我也无法进入。
还有人有其他的想法吗?
UPDATE :虚拟机似乎只会在创建和提供机器的初始vagrant up之后才会启动。停机后,由于遇到上述错误,它将不再正确地出现。
发布于 2014-09-26 17:57:48
如果机器ip是由DHCP设置的,请尝试将其设置为静态并手动设置。它每隔几天就这么做一次,原因是DHCP必须检查ip并重新分配它。
虚拟机、服务器、ftp服务器等应该始终具有用于远程连接的静态IP。正如xlembouras所说,“169.254.x.x范围的IP用于网络问题的特殊场合”,所以我收集的是DHCP服务器为它分配了一个无效IP(或旧IP)。因此,您必须使它是静态的,并在机器上手动设置IP、(子网)掩码和网关。这可以通过在ubuntu服务器(或*buntu机器)上执行以下操作(来自终端)来完成:(注意:如果您愿意,可以使用sudo而不是su。注意:如果您愿意,可以使用VIM )。
sudo su
cd /
cd etc/network
vi interfaces默认情况下,应该设置DHCP (即使它不在文本中)。如果你看到一行写着
"iface eth0 inet dhcp"用静态替换"dhcp“,然后继续在它下面设置IP和其他东西。
示例(做而不是使用这个逐字,因为它是一个例子):
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254现在通过以下方式重启网络配置
/etc/init.d/networking restart如果你想要一个详细的指南,我可以省去搜索它的麻烦,在Linux上将DHCP IP更改为静态IP
https://stackoverflow.com/questions/26052604
复制相似问题