Vagrant 使用及遇到的問題

最近在MacOS上安裝了vagrant.

準(zhǔn)備工作

下載 VirtualBox 虛擬器 : https://www.virtualbox.org/
下載安裝 Vagrant : http://www.vagrantup.com/
下載使用的 box (這里的 box 指的是系統(tǒng)) : http://www.vagrantbox.es/
在本地建立一個(gè)工作文件夾(/User/tonny/data)

下載鏡像

wget -c https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box

創(chuàng)建工作目錄

mkdir centos7
cd centos7
vagrant init 
vagrant box add centos7 boxpath(.box文件路徑)

修改配置文件

  config.vm.host_name = "centos7"
  config.vm.network "public_network", ip: "192.168.1.188", :bridge => 'en0: Wi-Fi (AirPort)'

  config.vm.provider :virtualbox do |vb|
      vb.customize ["modifyvm", :id, "--memory", "2048"]
  end

啟動(dòng)虛擬機(jī)

vagrant up

錯(cuò)誤處理

遇到public網(wǎng)絡(luò)錯(cuò)誤
Mar 13 14:28:55 centos7 network: Bringing up interface enp0s3:  Error: no device found for connection 'enp0s3'.
Mar 13 14:28:55 centos7 network: [FAILED]
Mar 13 14:28:57 centos7 network: Bringing up interface eth1:  [  OK  ]
Mar 13 14:28:57 centos7 network: Bringing up interface eth2:  Error: no device found for connection 'System eth2'.
Mar 13 14:28:57 centos7 network: [FAILED]
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 network: RTNETLINK answers: File exists
Mar 13 14:28:57 centos7 systemd: network.service: control process exited, code=exited status=1
Mar 13 14:28:57 centos7 systemd: Failed to start LSB: Bring up/down networking.
Mar 13 14:28:57 centos7 systemd: Unit network.service entered failed state.

vagrant ssh
su -
cat /var/log/messages |grep network
1. 找出相應(yīng)的錯(cuò)誤,刪除不必估的ifcfg-XXX配置文件
2. 檢查規(guī)則配置文件中的mac地址

cat /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x10ec:0x8139 (8139too)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:6b:57:88", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b4:89:4f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

重新加載虛擬機(jī)

vagrant reload
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 開發(fā)需要在各種系統(tǒng)上進(jìn)行開發(fā)任務(wù),運(yùn)維則需要在各種系統(tǒng)上學(xué)習(xí)工具使用。因此,虛擬機(jī)恐怕也是 IT 人員最常使用的工...
    李廣慧閱讀 5,686評(píng)論 3 24
  • 1,介紹Vagrant 我們做web開發(fā)的時(shí)候經(jīng)常要安裝各種本地測試環(huán)境,比如apache,php,mysql,r...
    meng_philip123閱讀 2,641評(píng)論 0 12
  • [Vagrant入門一(轉(zhuǎn))]閱讀目錄VirtualBox安裝Vagrant安裝Vagrant配置links 原文...
    漢相蕭何閱讀 1,001評(píng)論 0 0
  • 草在結(jié)它的種子 風(fēng)在搖它的葉子 我們站著,不說話 就十分美好 有門,不用開開 是我們的,就十分美好 在顧城的詩里,...
    知更喵閱讀 694評(píng)論 0 0
  • 今天一到岱山的雙合石壁,看到一根十丈左右的大石柱直立在陽光下,它的側(cè)面十分光滑,迎著池塘的倒影,閃閃亮亮,的確令人...
    好人難遇閱讀 828評(píng)論 0 0

友情鏈接更多精彩內(nèi)容