我有一台装有 Ubuntu 12.04、Virtualbox 4.3 和 Vagrant 1.5.1 的服务器。我正尝试使用这个机器http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box然而没有成功。当我运行“vagrant up”时,我收到此消息:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos-64-x64-vbox4210'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: rafael_default_1396403974194_51967
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. 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.
这是我的 Vagrant 文件
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "centos-64-x64-vbox4210"
config.vm.boot_timeout = 600
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
# config.vm.box_url = "http://domain.com/path/to/above.box"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision "chef_client" do |chef|
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
# chef.validation_key_path = "ORGNAME-validator.pem"
# end
#
# If you're using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = "ORGNAME-validator"
end
我的服务器没有图形界面,我该如何修复?谢谢。
答案1
第一次尝试:看什么流浪者私钥在你的机器配置中
$ vagrant ssh-config
例子:
$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/konst/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
第二,要做到: 更改文件内容不安全的私钥使用你自己系统的内容私钥
答案2
启动阶段的 SSH 连接超时可能由多种原因造成,例如:
- 系统等待用户交互(例如共享分区尚未准备好),
sshd
配置错误,- 防火墙配置错误(如果不是本地的),
- 你的私钥不匹配,
config.vm.boot_timeout
时间段太短(你的时间段没问题),- 确保 BIOS 中启用了虚拟化功能。
要调试该问题,请按如下方式运行:
VAGRANT_LOG=debug vagrant up
如果没有明显的异常,请尝试通过vagrant ssh
以下方式从另一个终端连接它:
vagrant ssh-config > vagrant-ssh; ssh -F vagrant-ssh default
如果 SSH 仍然失败,请使用以下命令重新运行图形用户界面(例如config.gui = true
)。
如果不是,请检查正在运行的进程(例如:)vagrant ssh -c 'pstree -a'
或验证您的sshd_config
。
如果它是一次性 VM,您可以随时重复destroy
使用它up
。还请考虑升级您的 Vagrant 和 Virtualbox。
答案3
尝试在防火墙上打开端口 22。
使用 Oracle VM VirtualBox Manager 直接启动 VM 或
将其添加到您的 Vagrantfile
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
然后运行“vagrant up”
使用默认 vagrant 凭据登录
user: vagrant
pass: vagrant
添加防火墙规则
sudo ufw allow 22
答案4
您需要启用 GUI。删除文件中以下几行的注释Vagrant
:
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
您需要关闭机器并重新启动:
vagrant halt
vagrant up