最近在MacOS上安装了vagrant.
准备工作
下载 VirtualBox 虚拟器 : https://www.virtualbox.org/
下载安装 Vagrant : http://www.vagrantup.com/
下载使用的 box (这里的 box 指的是系统) : 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
创建工作目录
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网络错误
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. 找出相应的错误,删除不必估的ifcfg-XXX配置文件
2. 检查规则配置文件中的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