1. 网卡配置
默认使用dhcp
config.vm.network :public_network
或者使用指定IP
config.vm.network :public_network, ip: "192.168.56.102", virtualbox__hostonly: "vboxnet0"
virtualbox__hostonly: "vboxnet0"
virtualbox__intnet: "private"
2. 安装指定插件
- Plugin source
- Alibaba - https://mirrors.aliyun.com/rubygems/
- tsing - https://mirrors.tuna.tsinghua.edu.cn/rubygems/
e.g
vagrant plugin install --plugin-clean-sources --plugin-source https://mirrors.tuna.tsinghua.edu.cn/rubygems/ vagrant-reload
vagrant plugin install --plugin-clean-sources --plugin-source https://mirrors.tuna.tsinghua.edu.cn/rubygems/ vagrant-disksize
3. 添加指定vbox
- 正常情况下,通过vagrantfile去安装box是直接从hub.vagrant.com拉去,但是很慢,如果你自己有自定的image地址,可以直接将其下载到本地,然后通过手工将其导入系统
vagrant add box changeyourname “d:\dd\ddd.vbox”
4. 修改vagrant指定地址
默认vagant文件存储在C:\users\xxx,很容易导致磁盘饱满,可以通过
setx VAGRANT_HOME="d:\.vagrant_box"
5. 常用的Oracle lInux vbox
- https://yum.oracle.com/boxes/
Create a working directory for your development project and from within that directory, issue the following commands, subsituting the url for one of the following, depending on the release of Oracle Linux you want:
Oracle Linux 9: https://oracle.github.io/vagrant-projects/boxes/oraclelinux/9.json
Oracle Linux 9 with Btrfs root filesystem: https://oracle.github.io/vagrant-projects/boxes/oraclelinux/9-btrfs.json
Oracle Linux 8: https://oracle.github.io/vagrant-projects/boxes/oraclelinux/8.json
Oracle Linux 8 with Btrfs root filesystem: https://oracle.github.io/vagrant-projects/boxes/oraclelinux/8-btrfs.json
Oracle Linux 7: https://oracle.github.io/vagrant-projects/boxes/oraclelinux/7.json
Oracle Linux 7 with Btrfs root filesystem: https://oracle.github.io/vagrant-projects/boxes/oraclelinux/7-btrfs.json
$ vagrant init oraclelinux/{release} <box json url>
$ vagrant up
$ vagrant ssh
For example:
$ vagrant init oraclelinux/8 https://oracle.github.io/vagrant-projects/boxes/oraclelinux/8.json
---> 此时会新建一个Vagrantfile文件,打开里边的配置,会发现https://oracle.github.io/vagrant-projects/boxes/oraclelinux/8.json
然后,可以直接在浏览器打开,能发现 里边调用的 vbox的地址,如
{
"description": "Oracle Linux 8",
"short_description": "Oracle Linux 8",
"name": "oraclelinux/8",
"versions": [
{
"version": "8.9.511",
"status": "active",
"release_date": "24-Nov-2023",
"description_html": "<ul>\n<li>Releasing 8.9.511</li>\n</ul>\n",
"description_markdown": "* Releasing 8.9.511",
"providers": [{
"name": "virtualbox",
"url": "https://yum.oracle.com/boxes/oraclelinux/ol8/OL8U9_x86_64-vagrant-virtualbox-b511.box",
"checksum": "5ecefbf80a286904dcc6b2f922a8415dfd7210631b75fdef3b18d4730734c018",
"checksum_type": "sha256",
"size": 783460392,
"kernel": "5.15.0-200.131.27.el8uek.x86_64"
}]
},
$ vagrant up
--> 如果这里失败,可以尝试用上面的地址 按如下操作解决
>vagrant box add oraclelinux/8 https://yum.oracle.com/boxes/oraclelinux/ol8/OL8U9_x86_64-vagrant-virtualbox-b511.box
$ vagrant ssh
-------------
To launch an Oracle Linux 8 box with Btfs root filesystem :
$ vagrant init oraclelinux/8-btrfs https://oracle.github.io/vagrant-projects/boxes/oraclelinux/8-btrfs.json
$ vagrant up
$ vagrant ssh
Updating an Oracle Linux box
To check whether an of your installed boxes have available updates:
$ vagrant box outdated --global
To update an Vagrant box to the latest available version:
$ vagrant box update --box oraclelinux/9
-- vagrantfile 调用方法
define.vm.box = "oraclelinux/8"
define.vm.box_url = "https://oracle.github.io/vagrant-projects/boxes/oraclelinux/8.json"