<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>虚拟机 on Leanku 的博客</title><link>https://www.leanku.com/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/</link><description>Recent content in 虚拟机 on Leanku 的博客</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Tue, 01 Aug 2023 11:46:01 +0800</lastBuildDate><atom:link href="https://www.leanku.com/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/index.xml" rel="self" type="application/rss+xml"/><item><title>VirtualBox+Vagrant使用</title><link>https://www.leanku.com/post/devops/virtualbox-vagrant%E4%BD%BF%E7%94%A8/</link><pubDate>Tue, 01 Aug 2023 11:46:01 +0800</pubDate><guid>https://www.leanku.com/post/devops/virtualbox-vagrant%E4%BD%BF%E7%94%A8/</guid><description>&lt;h1 id="virtualboxvagrant使用"&gt;VirtualBox+Vagrant使用&lt;/h1&gt;&#10;&lt;h2 id="一-介绍"&gt;一、 介绍&lt;/h2&gt;&#10;&lt;h3 id="1-virtualbox简介"&gt;1. VirtualBox简介&lt;/h3&gt;&#10;&lt;p&gt;VirtualBox是一个开源的 虚拟机管理软件，由 Oracle 开发。它的核心功能是允许你在一台物理机上运行多个虚拟机，每个虚拟机都可以装不同的操作系统。&lt;/p&gt;&#10;&lt;h4 id="特点"&gt;特点：&lt;/h4&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;跨平台&lt;/strong&gt;：支持 Windows、Linux、macOS 主机上安装。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;支持多种客操作系统&lt;/strong&gt;：常见的 Linux 发行版（CentOS、Ubuntu）、Windows Server、BSD 等。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;虚拟化功能&lt;/strong&gt;：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;配置虚拟 CPU、内存、磁盘、网卡等。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;支持桥接网络、NAT、仅主机网络等多种网络模式。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;GUI + CLI 管理&lt;/strong&gt;：既可以用图形界面管理虚拟机，也可以用命令行 &lt;code&gt;VBoxManage&lt;/code&gt; 控制。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;适合个人和开发使用&lt;/strong&gt;：开源免费，功能较全。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h3 id="2-vagrant简介"&gt;2. Vagrant简介&lt;/h3&gt;&#10;&lt;p&gt;Vagrant 是一个虚拟机 自动化管理工具，它本身不提供虚拟化功能，而是调用 VirtualBox、VMware、Hyper-V、Docker 等“虚拟化提供者”（provider）来创建和管理虚拟机。&lt;/p&gt;&#10;&lt;h4 id="特点-1"&gt;特点：&lt;/h4&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;开发环境自动化&lt;/strong&gt;：&lt;br&gt;&#10;通过 &lt;code&gt;Vagrantfile&lt;/code&gt; 描述一台（或多台）虚拟机的配置，比如操作系统镜像、CPU/内存、网络、共享目录等。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;跨平台一致性&lt;/strong&gt;：&lt;br&gt;&#10;不同开发者只要用相同的 &lt;code&gt;Vagrantfile&lt;/code&gt;，就能快速得到一模一样的开发环境，避免“在我机器上没问题”。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;支持多种 Provider&lt;/strong&gt;：&lt;br&gt;&#10;默认支持 VirtualBox，也可以配合 VMware、Hyper-V、Libvirt、Docker。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;Provisioning（自动化配置）&lt;/strong&gt;：&lt;br&gt;&#10;可以在虚拟机启动时自动执行脚本（Shell、Ansible、Puppet、Chef）来安装软件和配置环境。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;strong&gt;命令行简单&lt;/strong&gt;：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;vagrant init&lt;/code&gt; → 生成配置文件&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;vagrant up&lt;/code&gt; → 启动虚拟机&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;vagrant ssh&lt;/code&gt; → 进入虚拟机&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;vagrant halt&lt;/code&gt; → 关闭虚拟机&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;vagrant destroy&lt;/code&gt; → 删除虚拟机&lt;/p&gt;</description></item></channel></rss>