关于vagrant 虚拟环境配置

相信许多新手和我一样在第一次接触Vagrant的时候,配置环境出现很多问题,我来为大家讲讲如何配置vagrant环境并说一下其中常有的几个问题。

相应软件下载

1.vagrant
vagrant官网
windows 64 位下载即可
virtual box
virtual box 官网
在这里插入图片描述
建议virtual box 不要下载最新的版本,5.1即可,楼主用的5.1.24
3,box 下载
box就是在vagrant中封装好的操作系统
官方box
根据自己的需要下载即可

vagrant 环境配置

1.windows+R ,键入cmd打开命令行窗口
在这里插入图片描述
2.键入vagrant box add [list] [box路径]
list 为自己所取的名字,box路径为自己下载的box文件所存储的路径
在这里插入图片描述
3.初始化文件 vagrant init [list]
list 为之前取得名字
首先cd 进入到自己想存储的文件夹中
在这里插入图片描述
在键入 vagrant init [list],会在该文件夹下生成vagrantfile 文件

在这里插入图片描述
3.启动虚拟机 vagrant up
在这里插入图片描述注意一定要在之前的文件夹下打开,
如果成功启动会有提示
注意这里常见的几个问题,
A.错误提示如果有UTF-8字样,即为文件路径下有中文,需要全改为英文,特别注意用户名也为英文,如果用户名为汉字请自行网上百度,有点麻烦,建议新建用户名,注意用户名注销时,用户下的文件会不见,请注意保存,存在其他盘中。
B.如果网络超时

PS D:\工作文件\vagrant\nazf.net_home> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos7.0_nazf'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: nazfnet_home_default_1427381920843_31923
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2200 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
    default: Warning: Connection timeout. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value

进入你的BIOS,然后将virtualization(CPU虚拟化)设置为enable即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值