mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
commit
8ccc18a839
@ -1,140 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Installing and running Vagrant using qemu-kvm)
|
||||
[#]: via: (https://fedoramagazine.org/vagrant-qemukvm-fedora-devops-sysadmin/)
|
||||
[#]: author: (Andy Mott https://fedoramagazine.org/author/amott/)
|
||||
|
||||
Installing and running Vagrant using qemu-kvm
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Vagrant is a brilliant tool, used by DevOps professionals, coders, sysadmins and regular geeks to stand up repeatable infrastructure for development and testing. From their website:
|
||||
|
||||
> Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the “works on my machine” excuse a relic of the past.
|
||||
>
|
||||
> If you are already familiar with the basics of Vagrant, the documentation provides a better reference build for all available features and internals.
|
||||
>
|
||||
> Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.
|
||||
>
|
||||
> <https://www.vagrantup.com/intro>
|
||||
|
||||
This guide will walk through the steps necessary to get Vagrant working on a Fedora-based machine.
|
||||
|
||||
I started with a minimal install of Fedora Server as this reduces the memory footprint of the host OS, but if you already have a working Fedora machine, either Server or Workstation, then this should still work.
|
||||
|
||||
### Check the machine supports virtualisation:
|
||||
|
||||
```
|
||||
$ sudo lscpu | grep Virtualization
|
||||
Virtualization: VT-x
|
||||
Virtualization type: full
|
||||
```
|
||||
|
||||
### Install qemu-kvm:
|
||||
|
||||
```
|
||||
sudo dnf install qemu-kvm libvirt libguestfs-tools virt-install rsync
|
||||
```
|
||||
|
||||
### Enable and start the libvirt daemon:
|
||||
|
||||
```
|
||||
sudo systemctl enable --now libvirtd
|
||||
```
|
||||
|
||||
### Install Vagrant:
|
||||
|
||||
```
|
||||
sudo dnf install vagrant
|
||||
```
|
||||
|
||||
### Install the Vagrant libvirtd plugin:
|
||||
|
||||
```
|
||||
sudo vagrant plugin install vagrant-libvirt
|
||||
```
|
||||
|
||||
### Add a box
|
||||
|
||||
```
|
||||
vagrant box add fedora/32-cloud-base --provider=libvirt
|
||||
```
|
||||
|
||||
### Create a minimal Vagrantfile to test
|
||||
|
||||
```
|
||||
$ mkdir vagrant-test
|
||||
$ cd vagrant-test
|
||||
$ vi VagrantfileVagrant.configure("2") do |config|
|
||||
config.vm.box = "fedora/32-cloud-base"
|
||||
end
|
||||
```
|
||||
|
||||
**Note the capitalisation of the file name and in the file itself.**
|
||||
|
||||
### Check the file:
|
||||
|
||||
```
|
||||
vagrant statusCurrent machine states:
|
||||
|
||||
default not created (libvirt)
|
||||
|
||||
The Libvirt domain is not created. Run 'vagrant up' to create it.
|
||||
```
|
||||
|
||||
### Start the box:
|
||||
|
||||
```
|
||||
vagrant up
|
||||
```
|
||||
|
||||
### Connect to your new machine:
|
||||
|
||||
```
|
||||
vagrant ssh
|
||||
```
|
||||
|
||||
That’s it – you now have Vagrant working on your Fedora machine.
|
||||
|
||||
To stop the machine, use _vagrant halt_. This simply halts the machine but leaves the VM and disk in place.
|
||||
To shut it down and delete it use _vagrant destroy_. This will remove the whole machine and any changes you’ve made in it.
|
||||
|
||||
### Next steps
|
||||
|
||||
You don’t need to download boxes before issuing the _vagrant up_ command – you can specify the box and the provider in the Vagrantfile directly and Vagrant will download it if it’s not already there. Below is an example which also sets the amount memory and number of CPUs:
|
||||
|
||||
```
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "fedora/32-cloud-base"
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpus = 1
|
||||
libvirt.memory = 1024
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
For more information on using Vagrant, creating your own machines and using different boxes, see the official documentation at <https://www.vagrantup.com/docs>
|
||||
|
||||
There is a huge repository of boxes ready to download and use, and the official location for these is Vagrant Cloud – <https://app.vagrantup.com/boxes/search>. Some are basic operating systems and some offer complete functionality such as databases, web servers etc.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/vagrant-qemukvm-fedora-devops-sysadmin/
|
||||
|
||||
作者:[Andy Mott][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/amott/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2020/09/vagrant-beginner-howto-816x346.png
|
@ -0,0 +1,140 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Installing and running Vagrant using qemu-kvm)
|
||||
[#]: via: (https://fedoramagazine.org/vagrant-qemukvm-fedora-devops-sysadmin/)
|
||||
[#]: author: (Andy Mott https://fedoramagazine.org/author/amott/)
|
||||
|
||||
使用 qemu-kvm 安装和运行 Vagrant
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Vagrant 是一个出色的工具,被 DevOps 专业人员、程序员、系统管理员和普通极客来使用它来建立可复制的基础架构来进行开发和测试。来自它们的网站:
|
||||
|
||||
> Vagrant 是用于在单工作流程中构建和管理虚拟机环境的工具。凭借简单易用的工作流程和对自动化的关注,Vagrant 降低了开发环境的设置时间,提高了生产效率,并使”在我的机器上工作“的借口成为过去。
|
||||
>
|
||||
> 如果你已经熟悉 Vagrant 的基础知识,那么文档为所有的功能和内部结构提供了更好的参考。
|
||||
>
|
||||
> Vagrant 提供了易于配置、可复制、可移植的工作环境,它建立在行业标准技术之上,并由一个统一的工作流程控制,帮助你和你的团队最大限度地提高生产力和灵活性。
|
||||
>
|
||||
> <https://www.vagrantup.com/intro>
|
||||
|
||||
本指南将通过必要的步骤,让 Vagrant 在基于 Fedora 的机器上工作。
|
||||
|
||||
我从最小化安装 Fedora Server 开始,因为这样可以减少主机操作系统的内存占用,但如果你已经有一台可以使用的 Fedora 机器,无论是服务器还是工作站,那么也没问题。
|
||||
|
||||
### 检查机器是否支持虚拟化:
|
||||
|
||||
```
|
||||
$ sudo lscpu | grep Virtualization
|
||||
Virtualization: VT-x
|
||||
Virtualization type: full
|
||||
```
|
||||
|
||||
### 安装 qemu-kvm:
|
||||
|
||||
```
|
||||
sudo dnf install qemu-kvm libvirt libguestfs-tools virt-install rsync
|
||||
```
|
||||
|
||||
### 启用并启动 libvirt 守护进程:
|
||||
|
||||
```
|
||||
sudo systemctl enable --now libvirtd
|
||||
```
|
||||
|
||||
### 安装 Vagrant:
|
||||
|
||||
```
|
||||
sudo dnf install vagrant
|
||||
```
|
||||
|
||||
### 安装 Vagrant libvirtd 插件:
|
||||
|
||||
```
|
||||
sudo vagrant plugin install vagrant-libvirt
|
||||
```
|
||||
|
||||
### 添加一个 box
|
||||
|
||||
```
|
||||
vagrant box add fedora/32-cloud-base --provider=libvirt
|
||||
```
|
||||
|
||||
### 创建一个最小的 Vagrantfile 来测试:
|
||||
|
||||
```
|
||||
$ mkdir vagrant-test
|
||||
$ cd vagrant-test
|
||||
$ vi VagrantfileVagrant.configure("2") do |config|
|
||||
config.vm.box = "fedora/32-cloud-base"
|
||||
end
|
||||
```
|
||||
|
||||
**注意文件名和文件内容的大写。**
|
||||
|
||||
### 检查文件:
|
||||
|
||||
```
|
||||
vagrant statusCurrent machine states:
|
||||
|
||||
default not created (libvirt)
|
||||
|
||||
The Libvirt domain is not created. Run 'vagrant up' to create it.
|
||||
```
|
||||
|
||||
### 启动 box:
|
||||
|
||||
```
|
||||
vagrant up
|
||||
```
|
||||
|
||||
### 连接到你的新机器:
|
||||
|
||||
```
|
||||
vagrant ssh
|
||||
```
|
||||
|
||||
完成了。现在你的 Fedora 机器上有 Vagrant 在工作。
|
||||
|
||||
要停止机器,请使用 _vagrant halt_。这只是简单地停止机器,但保留虚拟机和磁盘。
|
||||
要关闭并删除它,请使用 _vagrant destroy_。这将删除整个机器和你在其中所做的任何更改。
|
||||
|
||||
### 接下来的步骤
|
||||
|
||||
在运行 _vagrant up_ 命令之前,你不需要下载 box。你可以直接在 Vagrantfile 中指定 box 和提供者,如果还没有的话,Vagrant 会下载它。下面是一个例子,它还设置了内存量和 CPU 数量:
|
||||
|
||||
```
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "fedora/32-cloud-base"
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.cpus = 1
|
||||
libvirt.memory = 1024
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
关于使用 Vagrant、创建你自己的机器和使用不同 box 的更多信息,请参见官方文档 <https://www.vagrantup.com/docs>。
|
||||
|
||||
有一个庞大的仓库,你可以随时下载使用这些 box,它们的的官方仓库是 Vagrant Cloud - <https://app.vagrantup.com/boxes/search>。这里有些是基本的操作系统,有些提供完整的功能,如数据库、网络服务器等。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/vagrant-qemukvm-fedora-devops-sysadmin/
|
||||
|
||||
作者:[Andy Mott][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/amott/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2020/09/vagrant-beginner-howto-816x346.png
|
Loading…
Reference in New Issue
Block a user