欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vagrant+virtualBox構建虛擬機的方法

 更新時間:2021年02月07日 10:43:59   作者:xianbin.yang  
這篇文章主要介紹了vagrant+virtualBox構建虛擬機,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

一、介紹

Vagrant是一個構建和管理虛擬機(VirtualBox)的工具。

我的環(huán)境:Mac + Vagrant + VirtualBox

網(wǎng)盤下載地址:鏈接: https://pan.baidu.com/s/1LKacXPQcgh3MjgWiIZ0zhQ 密碼: n998

二、安裝

VirtualBox: https://www.virtualbox.org/wiki/Downloads
Vagrant: http://downloads.vagrantup.co

三、在線創(chuàng)建虛擬機

1.在官網(wǎng)找到自己想要安裝的操作系統(tǒng):https://app.vagrantup.com/boxes/search

2.點進去,執(zhí)行命令創(chuàng)建并啟動虛擬機:https://app.vagrantup.com/centos/boxes/7

注意:需要單獨創(chuàng)建一個目錄,在該目錄下執(zhí)行vagrant命令,一個目錄對應一個虛擬機。vagrant init會創(chuàng)建一個配置文件Vagrantfile

三、離線創(chuàng)建虛擬機

1.添加

vagrant box add centOs7 /Users/xianbin.yang/Documents/vagrant/centos-7.0-x86_64.box

➜ vagrant vagrant box add centOs7 /Users/xianbin.yang/Documents/vagrant/centos-7.0-x86_64.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'centOs7' (v0) for provider:
  box: Unpacking necessary files from: file:///Users/xianbin.yang/Documents/vagrant/centos-7.0-x86_64.box
==> box: Successfully added box 'centOs7' (v0) for 'virtualbox'!

2.初始化

vagrant init centOs7

➜ vagrant vagrant init centOs7
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.

3.啟動

vagrant up

➜ vagrant vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centOs7'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: vagrant_default_1612583375721_1893
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
  default: Adapter 1: nat
==> default: Forwarding ports...
  default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
  default: SSH address: 127.0.0.1:2222
  default: SSH username: vagrant
  default: SSH auth method: private key
  default:
  default: Vagrant insecure key detected. Vagrant will automatically replace
  default: this with a newly generated keypair for better security.
  default:
  default: Inserting generated public key within guest...
  default: Removing insecure key from the guest if it's present...
  default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
  default: The guest additions on this VM do not match the installed version of
  default: VirtualBox! In most cases this is fine, but in rare cases it can
  default: prevent things such as shared folders from working properly. If you see
  default: shared folder errors, please make sure the guest additions within the
  default: virtual machine match the version of VirtualBox you have installed on
  default: your host and reload your VM.
  default:
  default: Guest Additions Version: 4.3.28
  default: VirtualBox Version: 6.1
==> default: Mounting shared folders...
  default: /vagrant => /Users/xianbin.yang/Documents/vagrant

四、常用命令

命令 作用
vagrant box add 添加box的操作
vagrant init 初始化box的操作,會生成vagrant的配置文件Vagrantfile
vagrant up 啟動本地環(huán)境
vagrant ssh 通過 ssh 登錄本地環(huán)境所在虛擬機
vagrant halt 關閉本地環(huán)境
vagrant suspend 暫停本地環(huán)境
vagrant resume 恢復本地環(huán)境
vagrant reload 修改了 Vagrantfile 后,使之生效(相當于先 halt,再 up)
vagrant destroy 徹底移除本地環(huán)境
vagrant box list 顯示當前已經(jīng)添加的box列表
vagrant box remove 刪除相應的box
vagrant status 獲取當前虛擬機的狀態(tài)


五、Vagrantfile常用配置

1.配置固定ip、內(nèi)存、cpu

# -*- mode: ruby -*-
# vi: set ft=ruby :
 
Vagrant.configure("2") do |config|
 config.vm.box = "centOs7"
 config.vm.network "private_network", ip: "192.168.33.10"
 config.vm.provider "virtualbox" do |vb|
   vb.cpus = 4
   vb.memory = "8192"
 end
end

注意:配置后需要vagrant reload

2.配置root用戶和ssh免密

vagrant用戶登錄:vagrant ssh

設置root密碼:sudo passwd root

配置ssh免密:ssh-copy-id root@192.168.33.10

ssh登錄:ssh root@192.168.33.10

3.關閉防火墻

檢查防火墻狀態(tài):systemctl status firewalld
關閉防火墻:systemctl stop firewalld
設置開機禁用防火墻:systemctl disable firewalld.service

參考鏈接:

https://learn.hashicorp.com/tutorials/vagrant/getting-started-index?in=vagrant/getting-started

到此這篇關于vagrant+virtualBox構建虛擬機的文章就介紹到這了,更多相關virtualBox構建虛擬機內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • VirtualBox啟用嵌套VT-x/AMD-V的問題

    VirtualBox啟用嵌套VT-x/AMD-V的問題

    這篇文章主要介紹了VirtualBox啟用嵌套VT-x/AMD-V,首先在Windows上安裝好virtualbox,為了能在virtualbox上創(chuàng)建嵌套的虛擬機,需要開啟CPU的虛擬化功能,具體安裝過程參考下本文
    2022-01-01
  • ubuntu 下VirtualBox 如何實現(xiàn)共享設置

    ubuntu 下VirtualBox 如何實現(xiàn)共享設置

    這篇文章主要介紹了ubuntu 下VirtualBox 如何實現(xiàn)共享設置的相關資料,這里對實現(xiàn)共享設置做了詳解,具有參考價值,需要的朋友可以參考下
    2016-11-11
  • virtualbox下osx系統(tǒng)盤擴容方法

    virtualbox下osx系統(tǒng)盤擴容方法

    這篇文章主要為大家詳細介紹了virtualbox下osx系統(tǒng)盤擴容方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • VirtualBox安裝CentOS7虛擬機以及增強工具(圖文)

    VirtualBox安裝CentOS7虛擬機以及增強工具(圖文)

    這篇文章主要介紹了VirtualBox安裝CentOS7虛擬機以及增強工具,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2020-03-03
  • 關于VirtualBox安裝Kali的教程圖解

    關于VirtualBox安裝Kali的教程圖解

    這篇文章主要介紹了VirtualBox安裝Kali的圖文教程,大家需要根據(jù)操作系統(tǒng)選擇版本,本文以Windows為例,通過圖文并茂的形式給大家介紹的非常詳細,需要的朋友可以參考下
    2022-05-05
  • Virtualbox?NAT網(wǎng)絡配置方法

    Virtualbox?NAT網(wǎng)絡配置方法

    這篇文章主要介紹了Virtualbox?NAT網(wǎng)絡配置,配置NAT網(wǎng)絡很簡單,配置好之后,需要配置端口映射,將虛擬機中的服務映射出來,可以在局域網(wǎng)中測試并使用,具體操作步驟跟隨小編一起看看吧
    2022-03-03
  • VirtualBox中最小化安裝Centos8.1虛擬機的教程詳解

    VirtualBox中最小化安裝Centos8.1虛擬機的教程詳解

    這篇文章主要介紹了VirtualBox中最小化安裝Centos8.1虛擬機的方法,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-05-05
  • VirtualBox簡體中文版下載安裝(圖解教程)

    VirtualBox簡體中文版下載安裝(圖解教程)

    本文介紹了VirtualBox簡體中文版下載安裝(圖解教程),具有一定的價值,有需要的可以參考一下。
    2016-10-10
  • virtualBox虛擬機安裝增強功能后開機超慢問題解決方案

    virtualBox虛擬機安裝增強功能后開機超慢問題解決方案

    virtualBox虛擬機安裝增強功能后開機超慢問題解決方案,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-06-06
  • 解決Xshell連不上virtualBox虛擬機的解決方法

    解決Xshell連不上virtualBox虛擬機的解決方法

    本文主要介紹了解決Xshell連不上virtualBox虛擬機的解決方法,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-11-11

最新評論