一、介绍
成都创新互联公司专注于企业成都全网营销、网站重做改版、加格达奇网站定制设计、自适应品牌网站建设、HTML5、成都做商城网站、集团公司官网建设、成都外贸网站建设公司、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为加格达奇等各大城市提供网站开发制作服务。
Vagrant是一个构建和管理虚拟机(VirtualBox)的工具。
我的环境:Mac + Vagrant + VirtualBox
网盘下载地址:链接: https://pan.baidu.com/s/1LKacXPQcgh3MjgWiIZ0zhQ 密码: n998二、安装
VirtualBox: https://www.virtualbox.org/wiki/Downloads
三、在线创建虚拟机
1.在官网找到自己想要安装的操作系统:https://app.vagrantup.com/boxes/search
2.点进去,执行命令创建并启动虚拟机:https://app.vagrantup.com/centos/boxes/7注意:需要单独创建一个目录,在该目录下执行vagrant命令
,一个目录对应一个虚拟机。vagrant init会创建一个配置文件Vagrantfile三、离线创建虚拟机
1.添加
vagrant box add centOs7 /Users/xianbin.yang/Documents/vagrant/centos-7.0-x86_64.box➜ vagrant vagrant box add centOs7 /Users/xianbin.yang/Documents/vagrant/centos-7.0-x86_64.box==> box: Box file was not detected as metadata. Adding it directly...==> box: Adding box 'centOs7' (v0) for provider: box: Unpacking necessary files from: file:///Users/xianbin.yang/Documents/vagrant/centos-7.0-x86_64.box==> box: Successfully added box 'centOs7' (v0) for 'virtualbox'!
2.初始化
vagrant init centOs7➜ vagrant vagrant init centOs7A `Vagrantfile` has been placed in this directory. You are nowready to `vagrant up` your first virtual environment! Please readthe comments in the Vagrantfile as well as documentation on`vagrantup.com` for more information on using Vagrant.
3.启动
vagrant up五、Vagrantfile常用配置
1.配置固定ip、内存、cpu# -*- mode: ruby -*-# vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centOs7" config.vm.network "private_network", ip: "192.168.33.10" config.vm.provider "virtualbox" do |vb| vb.cpus = 4 vb.memory = "8192" endend
注意:配置后需要vagrant reload
2.配置root用户和ssh免密
vagrant用户登录:vagrant ssh
设置root密码:sudo passwd root
配置ssh免密:ssh-copy-id root@192.168.33.10
ssh登录:ssh root@192.168.33.10
3.关闭防火墙
检查防火墙状态:systemctl status firewalld
关闭防火墙:systemctl stop firewalld
设置开机禁用防火墙:systemctl disable firewalld.service
参考链接:
https://learn.hashicorp.com/tutorials/vagrant/getting-started-index?in=vagrant/getting-started
到此这篇关于vagrant+virtualBox构建虚拟机的文章就介绍到这了,更多相关virtualBox构建虚拟机内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!