使用Vagrant Boxes来搜索你想要的环境

版权声明:本文为Buddy Yuan原创文章,未经允许不得转载。原文地址:使用VAGRANT BOXES来搜索你想要的环境
 
自从有了Vagrant之后,安装各类环境我一直都采用它,昨天突然想安装一个PostgreSQL。现在开源的产品特别多,要是一个一个的去安装操作系统,安装软件,是非常耗时的,还好Vagrant能很好的帮助我们解决这类问题。但是我们如何寻找已经配置好的环境呢?我们可以通过官方网站的Vagrant Boxes来找。

进入到Boxes之后,我们可以搜索,比如我想安装pg11,我就搜到了一个在debain环境下安装的pg11.

当然这里要和你的虚拟机搭配,比如我搜索的这个就是VirtualBox环境。点到虚拟机里面,然后就看到下面两条命令,执行一下,就可以把环境拖下来搭建好。

执行命令就可以搭建了。

C:\Users\Administrator>cd /d G:\VM DATA\vagrant-debain
G:\VM DATA\vagrant-debain>vagrant init jurafejfar/debian-9.5-pg11
G:\VM DATA\vagrant-debain>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'jurafejfar/debian-9.5-pg11' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'jurafejfar/debian-9.5-pg11'
    default: URL: https://vagrantcloud.com/jurafejfar/debian-9.5-pg11
==> default: Adding box 'jurafejfar/debian-9.5-pg11' (v2018-10-17) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/jurafejfar/boxes/debian-9.5-pg11/versions/2018-10-17/providers/virtualbox.box
==> default: Box download is resuming from prior download progress
    default: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
    default: Progress: 100% (Rate: 1000k/s, Estimated time remaining: --:--:--)
==> default: Successfully added box 'jurafejfar/debian-9.5-pg11' (v2018-10-17) for 'virtualbox'!
==> default: Importing base box 'jurafejfar/debian-9.5-pg11'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'jurafejfar/debian-9.5-pg11' is up to date...
==> default: Setting the name of the VM: vagrant-debain_default_1539794274257_97733
==> 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:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 5.2.20
    default: VirtualBox Version: 5.1
==> default: Mounting shared folders...
    default: /vagrant => G:/VM DATA/vagrant-debain

然后配置下网络,在Vagrantfile文件中添加“config.vm.network “private_network”, ip: “192.168.56.90””就可以通过CRT进行连接了。

以后再也不同折腾各种环境了!

分享到: 更多

Post a Comment

Your email is never published nor shared. Required fields are marked *