vagrant 1.8.6 安装过程及总结遇到的坑

本文发布时间: 2019-Mar-22
下面先总结遇到的问题,这些问题如果你也遇到,可能需要搜索很多次才能找到原因。如果想看安装过程,可以先直接跳到后面第二部分部分。1 问题汇总: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 try10 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.0DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000DEBUG subprocess: Exit status: 5 WARN downloader: Downloader exit code: 5ERROR 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 curlsudo 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.box11 # Successfully added box 'centos65-x86' (v0) for 'virtualbox'!12 ?13 vagrant box list14 # centos65-x86 (virtualbox, 0)15 ?16 cd /Users/user/box/baseVM/17 ?18 vagrant init centos65-x8619 # A `Vagrantfile` has been placed in this directory. You are now20 # ready to `vagrant up` your first virtual environment! Please read21 # the comments in the Vagrantfile as well as documentation on22 # `vagrantup.com` for more information on using Vagrant.23 ?24 vagrant up25 # ==> 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)下面是网上说明;http://stackoverflow.com/questions/38378418/vagrant-virtualbox-provider-virtualbox-not-found-well-automatically-instalVagrant 1.8.4 and older are not compatible with the VirtualBox 5.1.x. Vagrant 1.8.5 has been released already and it supports the VirtualBox 5.1.x. 因此为了配合最新的vb。需要使用vagrant 1.8.5 ~ 1.8.6版本。1.3 vagrant box下载失败默认的下载地址:http://www.vagrantbox.es/下载不太稳定,下了好多次都中途失败。提示'失败 - 已被禁止'。原本是要使用CentOS 6.4 x86_64版本的。结果总下载不了。最后使用了这个版本。https://github.com/2creatives/vagrant-centos/releasescentos65-x86_64-20140116.box网页上该文件的检验码::SHA256(centos65-x86_64-20140116.box)= 84eda9c4f00c86b62509d1007d4f1cf16b86bccb3795659cb56d1ea0007c3adccheck it:1 shasum -a256 centos65-x86_64-20140116.box2 84eda9c4f00c86b62509d1007d4f1cf16b86bccb3795659cb56d1ea0007c3adc centos65-x86_64-20140116.box3 ?4 md5 centos65-x86_64-20140116.box5 MD5 (centos65-x86_64-20140116.box) = c6518b158f7babd09dcccc30eb3d9333为了方便大家下载。我在网盘上放了一个文件,大家可以使用上面的信息自行校验,我也没有水平在这个镜像中装后门,呵呵。链接:https://pan.baidu.com/s/1qY8Nvsw密码:2fdm2 源文件经过几轮折腾。确定了各版本。本机系统:OS X 10.11.3virtualBox: VirtualBox-5.1.10-112026-OSX.dmgvagrant_1.8.6.dmgbox: centos65-x86_64-20140116.box3 安装vb和vagrant分别手动安装virtualBox和vagrant。安装后vb下载地址:https://www.virtualbox.org/wiki/Downloadsvagrant地址:https://www.vagrantup.com/downloads.htmlvagrant历史版本:https://releases.hashicorp.com/vagrant/vagrant box:http://www.vagrantbox.es/安装后检查:1 /opt/vagrant/bin/vagrant -v2 # Vagrant 1.8.63 ?4 /opt/vagrant/embedded/bin/curl --version5 # curl 7.45.0 (x86_64-apple-darwin13.4.0) libcurl/7.45.0 OpenSSL/1.0.2e zlib/1.2.86 ?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.vmdk10 -rw-r--r-- 1 user staff 505 11 28 13:53 Vagrantfile11 ?12 vagrant box list13 # centos65-x86 (virtualbox, 0)14 ?15 cd /Users/user/box/baseVM/16 ?17 vagrant init centos65-x8618 #A Vagrantfile has been placed in this directory. You are now19 #ready to vagrant up your first virtual environment! Please read20 #the comments in the Vagrantfile as well as documentation on21 #vagrantup.com for more information on using Vagrant.22 ?23 ls -l24 #total 825 #-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:222214 default: SSH username: vagrant15 default: SSH auth method: private key16 default:17 default: Vagrant insecure key detected. Vagrant will automatically replace18 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 of26 default: VirtualBox! In most cases this is fine, but in rare cases it can27 default: prevent things such as shared folders from working properly. If you see28 default: shared folder errors, please make sure the guest additions within the29 default: virtual machine match the version of VirtualBox you have installed on30 default: your host and reload your VM.31 default:32 default: Guest Additions Version: 4.3.633 default: VirtualBox Version: 5.134 ==> default: Mounting shared folders...35 default: /vagrant => /Users/user/box/baseVM检查进程1 ps axu | grep -i virtual2 # ...从上面可以看到登陆信息:127.0.0.1:2222default: SSH username: vagrant用户名与密码均是: vagrant但登陆并不需要输入用户名或机器及端口。登陆:1 vagrant ssh?2 [vagrant@vagrant-centos65 ~]$ pwd3 /home/vagrant4 ?5 ls -l /vagrant/6 total 47 -rw-r--r-- 1 vagrant vagrant 3016 Nov 28 08:13 Vagrantfile至此成功进入vagrant虚机。就在写这篇文章时,发现1.9.0已经出来了。可以试下最新版本了,应该修复了1.8.7的问题。


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:08pm
栏目列表