1.1 vagrant版本过高问题。
vagrant 1.8.7版本存在问题。可以搜索:"vagrant 1.8.7 cant download box"
https://github.com/mitchellh/vagrant/issues/6725 也上有人提到。
1 /opt/vagrant/bin/vagrant -v 2 Vagrant 1.8.7 3 4 vagrant box add centos /Users/user/box/src/centos65-x86_64-20140116.box
5 ==> box: Box file was not detected as metadata. Adding it directly... 6 ==> box: Adding box 'centos' (v0) for provider: 7 box: Unpacking necessary files from: file:///Users/user/box/src/centos65-x86_64-20140116.box 8 An error occurred while downloading the remote file. The error 9 message, if any, is reproduced below. Please fix this error and try 10 again.
而且后面并没有列出具体的原因。要查看原因,即使开启debug。
VAGRANT_LOG=debug vagrant box add --name centos65-x86 /Users/user/box/src/centos65-x86_64-20140116.box --checksum-type sha256 --checksum 84eda9c4f00c86b62509d1007d4f1cf16b86bccb3795659cb56d1ea0007c3adc --provider Virtualbox # ... DEBUG subprocess: stderr: dyld: Library not loaded: @rpath/libcurl.4.dylib Referenced from: /opt/vagrant/embedded/bin/curl Reason: Incompatible library version: curl requires version 9.0.0 or later, but libcurl.4.dylib provides version 7.0.0 DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000 DEBUG subprocess: Exit status: 5 WARN downloader: Downloader exit code: 5 ERROR downloader: Exit code: 5 # ...
其中部分输出如上,提示/opt/vagrant/embedded/bin/curl的版本问题:
curl requires version 9.0.0
解决办法:
网上大多提示1.8.7版本确实有如下问题,建议重新安装1.8.6.
-
重新安装Vagrant 1.8.6
-
使用你系统的curl代替Vagrant curl
sudo ln -nsf /usr/bin/curl /opt/vagrant/embedded/bin/curl
实际上第二步不是必须的。
1.2 vagrant版本过低问题。
vagrant 1.8.1版本存在的问题。这个问题来自与virtulbox的版本配合上面。
1 /opt/vagrant/bin/vagrant -v 2 # Vagrant 1.8.1 3 4 /opt/vagrant/embedded/bin/curl --version 5 # curl 7.45.0 (x86_64-apple-darwin12.6.0) libcurl/7.45.0 OpenSSL/1.0.2d zlib/1.2.8 6 7 ls -trl ~/.vagrant.d/boxes/ 8 # blank 9 10 VAGRANT_LOG=debug vagrant box add --name centos65-x86 /Users/user/box/src/centos65-x86_64-20140116.box 11 # Successfully added box 'centos65-x86' (v0) for 'virtualbox'! 12 13 vagrant box list 14 # centos65-x86 (virtualbox, 0) 15 16 cd /Users/user/box/baseVM/ 17 18 vagrant init centos65-x86 19 # A `Vagrantfile` has been placed in this directory. You are now 20 # ready to `vagrant up` your first virtual environment! Please read 21 # the comments in the Vagrantfile as well as documentation on 22 # `vagrantup.com` for more information on using Vagrant. 23 24 vagrant up 25 # ==> Provider 'virtualbox' not found. We'll automatically install it now... 26 # ==> Downloading VirtualBox 5.0.10...
从上面可见,1.8.1版本并不能识别到
VirtualBox 版本 5.1.10 r112026 (Qt5.6.2)
下面是网上说明;
1.3 vagrant box下载失败
默认的下载地址:http://www.vagrantbox.es/
下载不太稳定,下了好多次都中途失败。提示"失败 - 已被禁止"。原本是要使用CentOS 6.4 x86_64版本的。结果总下载不了。最后使用了这个版本。
https://github.com/2creatives/vagrant-centos/releases
网页上该文件的检验码::
SHA256(centos65-x86_64-20140116.box)= 84eda9c4f00c86b62509d1007d4f1cf16b86bccb3795659cb56d1ea0007c3adc
check it:
1 shasum -a256 centos65-x86_64-20140116.box 2 84eda9c4f00c86b62509d1007d4f1cf16b86bccb3795659cb56d1ea0007c3adc centos65-x86_64-20140116.box 3 4 md5 centos65-x86_64-20140116.box 5 MD5 (centos65-x86_64-20140116.box) = c6518b158f7babd09dcccc30eb3d9333
为了方便大家下载。我在网盘上放了一个文件,大家可以使用上面的信息自行校验,我也没有水平在这个镜像中装后门,呵呵。
-
密码:2fdm
2 源文件
经过几轮折腾。确定了各版本。
-
本机系统:OS X 10.11.3
-
virtualBox: VirtualBox-5.1.10-112026-OSX.dmg
-
vagrant_1.8.6.dmg
-
box: centos65-x86_64-20140116.box
3 安装vb和vagrant
分别手动安装virtualBox和vagrant。安装后
vb下载地址:https://www.virtualbox.org/wiki/Downloads
vagrant地址:https://www.vagrantup.com/downloads.html
vagrant历史版本:https://releases.hashicorp.com/vagrant/
安装后检查:
1 /opt/vagrant/bin/vagrant -v 2 # Vagrant 1.8.6 3 4 /opt/vagrant/embedded/bin/curl --version 5 # curl 7.45.0 (x86_64-apple-darwin13.4.0) libcurl/7.45.0 OpenSSL/1.0.2e zlib/1.2.8 6 7 ls -trl ~/.vagrant.d/boxes/ 8 # blank
1 VAGRANT_LOG=debug vagrant box add --name centos65-x86 /Users/user/box/src/centos65-x86_64-20140116.box 2 # ==> box: Successfully added box 'centos65-x86' (v0) for 'virtualbox'! 3 4 ls ~/.vagrant.d/boxes/centos65-x86/0/virtualbox/ 5 total 586952 6 -rw-r--r-- 1 user staff 25 11 28 13:53 metadata.json 7 -rw------- 1 user staff 12064 11 28 13:53 box.ovf 8 -rw------- 1 user staff 71680 11 28 13:53 box-disk2.vmdk 9 -rw------- 1 user staff 300424192 11 28 13:53 box-disk1.vmdk 10 -rw-r--r-- 1 user staff 505 11 28 13:53 Vagrantfile 11 12 vagrant box list 13 # centos65-x86 (virtualbox, 0) 14 15 cd /Users/user/box/baseVM/ 16 17 vagrant init centos65-x86 18 #A Vagrantfile has been placed in this directory. You are now 19 #ready to vagrant up your first virtual environment! Please read 20 #the comments in the Vagrantfile as well as documentation on 21 #vagrantup.com for more information on using Vagrant. 22 23 ls -l 24 #total 8 25 #-rw-r--r-- 1 user staff 3024 11 28 14:55 Vagrantfile
启动:
1 vagrant up 2 Bringing machine 'default' up with 'virtualbox' provider... 3 ==> default: Importing base box 'centos65-x86'... 4 ==> default: Matching MAC address for NAT networking... 5 ==> default: Setting the name of the VM: baseVM_default_1480320850854_85192 6 ==> default: Clearing any previously set network interfaces... 7 ==> default: Preparing network interfaces based on configuration... 8 default: Adapter 1: nat 9 ==> default: Forwarding ports... 10 default: 22 (guest) => 2222 (host) (adapter 1) 11 ==> default: Booting VM... 12 ==> default: Waiting for machine to boot. This may take a few minutes... 13 default: SSH address: 127.0.0.1:2222 14 default: SSH username: vagrant 15 default: SSH auth method: private key 16 default: 17 default: Vagrant insecure key detected. Vagrant will automatically replace 18 default: this with a newly generated keypair for better security. 19 default: 20 default: Inserting generated public key within guest... 21 default: Removing insecure key from the guest if it's present... 22 default: Key inserted! Disconnecting and reconnecting using new SSH key... 23 ==> default: Machine booted and ready! 24 ==> default: Checking for guest additions in VM... 25 default: The guest additions on this VM do not match the installed version of 26 default: VirtualBox! In most cases this is fine, but in rare cases it can 27 default: prevent things such as shared folders from working properly. If you see 28 default: shared folder errors, please make sure the guest additions within the 29 default: virtual machine match the version of VirtualBox you have installed on 30 default: your host and reload your VM. 31 default: 32 default: Guest Additions Version: 4.3.6 33 default: VirtualBox Version: 5.1 34 ==> default: Mounting shared folders... 35 default: /vagrant => /Users/user/box/baseVM
检查进程
1 ps axu | grep -i virtual 2 # ...
从上面可以看到登陆信息:
-
127.0.0.1:2222
-
default: SSH username: vagrant
-
用户名与密码均是: vagrant
但登陆并不需要输入用户名或机器及端口。
登陆:
1 vagrant ssh 2 [vagrant@vagrant-centos65 ~]$ pwd 3 /home/vagrant 4 5 ls -l /vagrant/ 6 total 4 7 -rw-r--r-- 1 vagrant vagrant 3016 Nov 28 08:13 Vagrantfile
至此成功进入vagrant虚机。
就在写这篇文章时,发现1.9.0已经出来了。可以试下最新版本了,应该修复了1.8.7的问题。