最近在MacOS上安裝了vagrant.
準(zhǔn)備工作
下載 VirtualBox 虛擬器 : https://www.virtualbox.org/
下載安裝 Vagrant : http://www.vagrantup.com/
下載使用的 box (這里的 box 指的是系統(tǒng)) : http://www.vagrantbox.es/
在本地建立一個工作文件夾(/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
啟動虛擬機
vagrant up
錯誤處理
遇到public網(wǎng)絡(luò)錯誤
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)的錯誤,刪除不必估的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"
重新加載虛擬機
vagrant reload