簡體   English   中英

使用Vagrant在沒有VirtualBox的情況下使用KVM / qemu設置VM

[英]Using Vagrant to set up a VM with KVM/qemu without VirtualBox

我開始使用Vagrant並希望將它與KVM / qemu(以及Virtual Machine Manager GUI)一起使用,而不是安裝VirtualBox。 所以我先安裝了Vagrant:

$ vagrant --version
Vagrant 1.9.1

$ vagrant box list
There are no installed boxes! Use `vagrant box add` to add some

根據 這些 帖子 ,我需要vagrant-libvirt才能與KVM一起使用,所以我安裝了下一個:

$ vagrant plugin list
vagrant-libvirt (0.0.37)
vagrant-share (1.1.6, system)

接下來,我提示添加一個CentOS(7)框使用vagrant box add "centos/7"並選擇libvirt 之后,我運行了vagrant init並沒有遇到任何錯誤:

$ vagrant init centos/7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

但是, vagrant up似乎錯了,就像這樣:

$ vagrant up
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.
  • 這是Vagrantfile提供程序部分

     config.vm.provider :libvirt do |domain| domain.driver = "qemu" domain.memory = 512 domain.cpus = 1 end 
  • 我嘗試將其修改為:

     config.vm.provider :libvirt do |domain| domain.driver = "kvm" domain.host = 'localhost' domain.uri = 'qemu:///system' domain.memory = 512 domain.cpus = 1 end 
  • 我也嘗試過vagrant up --provider=kvmvagrant up --provider=qemuvagrant up --provider=libvirt也無濟於事。

有沒有我錯過的一步? 還是需要安裝的另一個包/依賴項?

編輯:使用vagrant添加centos/7 ,它會在運行vagrant box list時顯示。

$ vagrant box list
centos/7 (libvirt, 1611.01)

使用命令啟動vagrant box

vagrant up --provider=kvm

雖然在https://seven.centos.org/2017/08/updated-centos-vagrant-images-available-v1707-01/中已經說過

vagrant-libvirt插件僅與Vagrant 1.5到1.8兼容

您可以使用命令行選項--provider=kvm ,也可以設置VAGRANT_DEFAULT_PROVIDER環境變量:

export VAGRANT_DEFAULT_PROVIDER=kvm  # <-- may be in ~/.profile, /etc/profile, or elsewhere

vagrant up

如果你運行的是Ruby 2.3,那么vagrant-libvirt(0.0.40)與Vagrant 2.0.2是兼容的,至少在Linux Mint 18.3(Ubuntu 16.04)上是這樣。 我在vagrantUp網站上使用debian下載的vagrant並使用它安裝插件沒有任何問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM