共计 1044 个字符,预计需要花费 3 分钟才能阅读完成。
装置 Vagrant
装置很简略,去官网下载安装 DMG 文件,双击点开装置即可。下载链接:https://www.vagrantup.com/downloads。
启动 Centos 8
$ mkdir ~/vagrant/centos8
$ cd ~/vagrant/centos8
$ vagrant init centos/8
配置端口导出和共享目录
vim ~/vagrant/centos8/Vagrantfile
增加配置项:
config.vm.network "forwarded_port", guest: 5671, host: 5671
config.vm.synced_folder "/Users/kun/workspace", "/workspace"
查看《残缺配置文件》。
启动
$ vagrant up
如果启动报如下谬误,请看下一节解决方案:
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000 workspace /workspace
The error output from the command was:
mount: /workspace: unknown filesystem type 'vboxsf'.
修复共享目录报错
装置虚拟机依赖:
$ vagrant ssh # 漠视报错,进入虚拟机
$ sudo yum -y install kernel kernel-devel # 装置依赖
$ exit
装置 vagrant 插件:
$ vagrant plugin install vagrant-vbguest
$ vagrant vbguest # 如果报错,先 vagrant reload 一下
$ vagrant reload
$ vagrant ssh
设置 root 明码
进入虚拟机:
$ sudo passwd root
正文完