fedora29 安装virtualBox 和vagrant

fedora29 安装virtualBox 和vagrant

趁着五一假期,打算入手docker,可是又怕把自己电脑搞坏了,因此便想着搭个virtualBox和Vagrant,装个虚拟机,可是Vagrant在下载box的时候可谓是非常慢...

主机环境为fedora29,VirtualBox是直接从官网下载的,链接在这,然后在命令行里面直接安装,Vagrant也是在官网下载的,不过我选的是Centos对应的Vagrant,然后也是在命令行直接安装的

# 安装 VirtualBox
sudo rpm -i VirtualBox-6.0-6.0.6_130049_fedora29-1.x86_64.rpm
# 安装 Vagrant
sudo rpm -i vagrant_2.2.4_x86_64.rpm

安装以上就可以直接安装虚拟机了,这里我们以安装centos/7为例子

# 新建一个名字为centos7的文件夹
mkdir centos7
cd centos7
# 初始化一个Vagrantfile
vagrant init cantos/7
#这时候文件夹里面会出现一个Vagrantfile文件
#然后开始创建虚拟机
vagrant up --provider virtualbox
##然后是漫长的等待....
###速度相当慢,甚至还会出错

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
[admin@t3600-501-npu-edu centos7]$ vim Vagrantfile 
[admin@t3600-501-npu-edu centos7]$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'centos/7' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'centos/7'
    default: URL: https://vagrantcloud.com/centos/7
==> default: Adding box 'centos/7' (v1902.01) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1902.01/providers/virtualbox.box
    default: Download redirected to host: cloud.centos.org
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104

然后我想到一个办法,先使用下载器下载box文件,链接就在上面( https://vagrantcloud.com/centos/boxes/7/versions/1902.01/providers/virtualbox.box)然后再安装他,其实也很简单

下载后,把box文件放在你新建的文件夹里,然后:

# 往vagrant box中添加该box,并改名为centos/7
vagrant box add centos/7 ./virtualbox.box 
# 查看一下
vagrant box list

#然后就可以安装了
vagrant init centos/7

#这时候会提示你之前已经生成了Vagrantfile文件,删掉就好了
rm -f Vagrantfile
#然后
vagrant init centos/7
# 一会儿就好了


#然后就可以进入镜像了
vagrant up --provider virtualbox

vagrant ssh
# 以上
$ vagrant up --provider virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default: 
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Rsyncing folder: /home/admin/workspace/centos7/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
$ vagrant ssh
Last login: Wed May  1 09:35:55 2019 from 10.0.2.2
[vagrant@localhost ~]$ 
$ 

至于下载工具,推荐XDM或者AXEL,都是多线程下zai工具

 


设置网络连接方式-桥接(参考链接

         如果不是用于生产环境的话,可以直接用‘host-only’模式

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tailor_long

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值