今天打算配置一個(gè)Vagrant+Virtualbox運(yùn)行環(huán)境渺鹦,然而各種坑
1.下載Virtualbox
地址:https://www.virtualbox.org/wiki/Downloads
我安裝的是widows版本的
安裝好后直接運(yùn)行
1.下載Vagrant
地址:https://www.vagrantup.com/downloads.html
同樣是windows版本
安裝好后就開始入坑了
坑1 vagrant運(yùn)行
由于第一使用vagrant 之前看的教程也都是直接接輸入vagrant命令了归斤,所以以為入口就是vagrant.exe
然后就是點(diǎn)擊vagrant.exe后各種閃退联喘,閃退到懷疑人生。一波搜索载庭,查到結(jié)果
vagrant正確的打開方式是通過cmd
輸入
vagrant --help
可以看到vagrant支持的命令
輸入
vagrant -v
查看版本號(hào)
坑2 windows命令
由于長期的使用linux服務(wù)器滾瓜爛熟了linux命令看彼,回到windows就是傻眼了廊佩,我的vagrant安裝在E盤,于是我想跳轉(zhuǎn)到E盤我的安裝目錄下去創(chuàng)建文件夾
于是我這樣做
然后沒有任何反應(yīng)
然后還有什么ll
這里說下正確的命令
1.進(jìn)入目錄直接輸入盤 如: E: 然后回車
2.查看目錄下現(xiàn)有文件 dir 命令
3.創(chuàng)建新的文件夾 方法1 md +文件夾名 方法2 mkdir + 文件夾名稱
4.進(jìn)入目錄中的文件夾 cd 文件夾名
至于如果需要用到其他的命令就自己百度了我就不多說了
成功進(jìn)入vagrant目錄創(chuàng)建了新的文件夾vagrantCentos7后進(jìn)入第三坑
坑3 vagrant up
進(jìn)入目錄后
執(zhí)行 vagrant init centos/7
翻譯一下
這樣是正常的靖榕,可以看到目錄下就有一個(gè)Vagrantfile了标锄,然后執(zhí)行vagrant up
然后就出現(xiàn)了一堆錯(cuò)誤提示
No usable default provider could be found for your system.
Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.
The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.
If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
vagrant up --provider=PROVIDER
, which should give you a more specific
error message for that particular provider.
又是一波各種查文檔,得到答案是版本的問題茁计,但是沒有明確指出vagrant2.2.6可搭配virtualbox哪些版本
在一個(gè)https://blog.csdn.net/daxiang52/article/details/103518589
里得到了答案
vagrant2.2.6還沒有支持到virtualbox6.1
然后將6.1版的配置在里面料皇,方法如下
1.找到vagrant目錄結(jié)構(gòu)的下的如下文件我安裝在E盤
E:\Vagrant\embedded\gems\2.2.6\gems\vagrant-2.2.6\plugins\providers\virtualbox\plugin.rb
在這個(gè)文件里增加6.1版本
require "vagrant"
module VagrantPlugins
module ProviderVirtualBox
class Plugin < Vagrant.plugin("2")
name "VirtualBox provider"
description <<-EOF
The VirtualBox provider allows Vagrant to manage and control
VirtualBox-based virtual machines.
EOF
provider(:virtualbox, priority: 6) do
require File.expand_path("../provider", __FILE__)
Provider
end
config(:virtualbox, :provider) do
require File.expand_path("../config", __FILE__)
Config
end
synced_folder(:virtualbox) do
require File.expand_path("../synced_folder", __FILE__)
SyncedFolder
end
provider_capability(:virtualbox, :forwarded_ports) do
require_relative "cap"
Cap
end
provider_capability(:virtualbox, :nic_mac_addresses) do
require_relative "cap"
Cap
end
provider_capability(:virtualbox, :public_address) do
require_relative "cap/public_address"
Cap::PublicAddress
end
provider_capability(:virtualbox, :snapshot_list) do
require_relative "cap"
Cap
end
end
autoload :Action, File.expand_path("../action", __FILE__)
# Drop some autoloads in here to optimize the performance of loading
# our drivers only when they are needed.
module Driver
autoload :Meta, File.expand_path("../driver/meta", __FILE__)
autoload :Version_4_0, File.expand_path("../driver/version_4_0", __FILE__)
autoload :Version_4_1, File.expand_path("../driver/version_4_1", __FILE__)
autoload :Version_4_2, File.expand_path("../driver/version_4_2", __FILE__)
autoload :Version_4_3, File.expand_path("../driver/version_4_3", __FILE__)
autoload :Version_5_0, File.expand_path("../driver/version_5_0", __FILE__)
autoload :Version_5_1, File.expand_path("../driver/version_5_1", __FILE__)
autoload :Version_5_2, File.expand_path("../driver/version_5_2", __FILE__)
autoload :Version_6_0, File.expand_path("../driver/version_6_0", __FILE__)
autoload :Version_6_1, File.expand_path("../driver/version_6_1", __FILE__)
end
module Model
autoload :ForwardedPort, File.expand_path("../model/forwarded_port", __FILE__)
end
module Util
autoload :CompileForwardedPorts, File.expand_path("../util/compile_forwarded_ports", __FILE__)
end
end
end
增加了一行
autoload :Version_6_1, File.expand_path("../driver/version_6_1", __FILE__)
2.找到同一目錄下的文件
E:\Vagrant\embedded\gems\2.2.6\gems\ vagrant2.2.6\plugins\providers\virtualbox\driver\meta.rb
增加
"6.1" => Version_6_1,
3.當(dāng)前目錄下新建version_6_1.rb文件,文件內(nèi)容如下:
內(nèi)容
require File.expand_path("../version_6_0", __FILE__)
module VagrantPlugins
module ProviderVirtualBox
module Driver
# Driver for VirtualBox 6.1.x
class Version_6_1 < Version_6_0
def initialize(uuid)
super
@logger = Log4r::Logger.new("vagrant::provider::virtualbox_6_1")
end
end
end
end
end
然后從新打開cmd在剛剛創(chuàng)建的目錄行運(yùn)行vagrant up 就好了
完星压!