断点续传安装安装Vagrant版本SQL Server2014

需求

在服务器版本的CentOS7.5下需要安装一个Window版本的Sql Server 2014,但由于virtualbox.box过大(14G),由于网络环境,直接用vagrant总是不能一次下载成功,而且vagrant没有断点续传的功能,导致vagrant总是要重新下载。

解决方法

通过实践发现vagrant是用virtualbox.box镜像文件作为虚拟机的模板,只要把virtualbox.box下载,再导致vagrant中就可以成功启动虚拟机了。所以就想到用wget断点续传下载好virtualbox.box,再手工加载到vagrant中,最后启动虚拟机即可。

处理过程

gusztavvargadr-w16s-sql14d的SQL Server

主要信息点

下载virtualbox.box

先得到virtualbox.box下载地址,通过vagrant up输出virtualbox.box下载地址

[root@htwy gusztavvargadr-w16s-sql14d]# vagrant init gusztavvargadr/w16s-sql14d
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.
[root@htwy gusztavvargadr-w16s-sql14d]# ll -a
total 4
drwxr-xr-x 2 root root   25 Sep 29 22:07 .
drwxr-xr-x 4 root root   31 Sep 29 22:07 ..
-rw-r--r-- 1 root root 3033 Sep 29 22:07 Vagrantfile
[root@htwy gusztavvargadr-w16s-sql14d]# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'gusztavvargadr/w16s-sql14d' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'gusztavvargadr/w16s-sql14d'
    default: URL: https://vagrantcloud.com/gusztavvargadr/w16s-sql14d
==> default: Adding box 'gusztavvargadr/w16s-sql14d' (v1808.0.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/gusztavvargadr/boxes/w16s-sql14d/versions/1808.0.0/providers/virtualbox.box
    default: Progress: 0% (Rate: 0/s, Estimated time remaining: --:--:--)

断点续传下载virtualbox.box

[root@htwy gusztavvargadr-w16s-sql14d]# wget -c -t 0 https://vagrantcloud.com/gusztavvargadr/boxes/w16s-sql14d/versions/1808.0.0/providers/virtualbox.box

导入virtualbox.box

等一段时间的下载,终于全部下载好virtualbox.box。要做的事就要把virtualbox.box导入进去

主要有几点

  1. 配置metadata.json,描述virtualbox.box信息
    name: vagrant box的app名
    version: X.Y.Z格式就行,最好跟app中描述的一致,Vagrantfile中不指定版本也是能运行的。
    name: virtualbox
    url: virtualbox.box的路径名
{
  "name": "gusztavvargadr/w16s-sql14d",
  "versions": 
  [ 
     { 
        "version": "1808.0.0",
        "providers": [
           {
             "name": "virtualbox",
             "url": "/data/work/vagrant/gusztavvargadr-w16s-sql14d/virtualbox.box"
           }
         ]
     }
  ]
}
  1. 导入virtualbox.box
    vagrant box add metadata.json

  2. 查看box
    vagrant box list

  3. 操作过程

[root@htwy gusztavvargadr-w16s-sql14d]# vagrant box list

[root@htwy gusztavvargadr-w16s-sql14d]# vim metadata.json 
[root@htwy gusztavvargadr-w16s-sql14d]# cat metadata.json 
{
  "name": "gusztavvargadr/w16s-sql14d",
  "versions": 
  [ 
     { 
        "version": "1808.0.0",
        "providers": [
           {
             "name": "virtualbox",
             "url": "/data/work/vagrant/gusztavvargadr-w16s-sql14d/virtualbox.box"
           }
         ]
     }
  ]
}
[root@htwy gusztavvargadr-w16s-sql14d]# vagrant box add metadata.json 
==> box: Loading metadata for box 'metadata.json'
    box: URL: file:///data/work/vagrant/gusztavvargadr-w16s-sql14d/metadata.json
==> box: Adding box 'gusztavvargadr/w16s-sql14d' (v1808.0.0) for provider: virtualbox
    box: Downloading: /data/work/vagrant/gusztavvargadr-w16s-sql14d/virtualbox.box
==> box: Successfully added box 'gusztavvargadr/w16s-sql14d' (v1808.0.0) for 'virtualbox'!
[root@htwy gusztavvargadr-w16s-sql14d]# vagrant box list
gusztavvargadr/w16s-sql14d  (virtualbox, 1808.0.0)
[root@htwy gusztavvargadr-w16s-sql14d]# 

运行虚拟机vagrant up

主要是 配置bridged 的网卡

[root@htwy gusztavvargadr-w16s-sql14d]# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'gusztavvargadr/w16s-sql14d'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'gusztavvargadr/w16s-sql14d' is up to date...
==> default: Setting the name of the VM: gusztavvargadr-w16s-sql14d_default_1538207071718_26664
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) em2
2) veth54c02fd
3) veth1b66282
4) vetha876862
5) vethd2c03a1
6) br-d729b10fd4b1
7) veth5eeef01
8) veth387d2ee
9) vethaca6e79
10) vethb3a1158
11) veth25b70f9
12) veth6777525
13) vethb85a56c
14) veth825f6b9
15) veth9435727
16) vethc3c57bc
17) vethab3b1d4
18) veth2794315
19) veth729ceab
20) vethf902bd3
21) vpn_default
22) vethcec6382
23) veth2ab7119
24) vethdcaf93c
25) veth393b4b1
26) veth34ee587
27) em3
28) em1
29) em4
30) vethc1e38f7
31) veth82a4c65
32) docker0
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
    default: Which interface should the network bridge to? 1
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 3389 (guest) => 33389 (host) (adapter 1)
    default: 5985 (guest) => 55985 (host) (adapter 1)
    default: 5986 (guest) => 55986 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 127.0.0.1:55985
    default: WinRM username: vagrant
    default: WinRM execution_time_limit: PT2H
    default: WinRM transport: negotiate
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /data/work/vagrant/gusztavvargadr-w16s-sql14d

Vagrantfile

参考:WinRM Settings

Vagrantfile要进行一定的修改,主要区别点

[root@htwy gusztavvargadr-w16s-sql14d]# diff Vagrantfile Vagrantfile.old 
16,18d15
<   config.vm.guest = :windows
<   config.vm.communicator = "winrm"  
43c40
<   config.vm.network "public_network", ip: "192.168.31.103"
---
>   # config.vm.network "public_network"
  1. 对于操作系统为Window的虚拟机,指定下面两个配置项:
    config.vm.guest = :windows
    config.vm.communicator = "winrm"

  2. 配置局域网的IP地址,供其他用户访问使用
    config.vm.network "public_network", ip: "192.168.31.103"

[root@htwy gusztavvargadr-w16s-sql14d]# cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "gusztavvargadr/w16s-sql14d"
 
 #windows系统要指定下面两个配置项
  config.vm.guest = :windows
  config.vm.communicator = "winrm"  

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  config.vm.network "public_network", ip: "192.168.31.103"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

访问数据库

测试访问信息:


image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,482评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,377评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,762评论 0 342
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,273评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,289评论 5 373
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,046评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,351评论 3 400
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,988评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,476评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,948评论 2 324
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,064评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,712评论 4 323
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,261评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,264评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,486评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,511评论 2 354
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,802评论 2 345

推荐阅读更多精彩内容

  • 1. Vagrant 的介绍 虚拟开发环境 平常我们经常会遇到这样的问题:在开发机上面开发完毕程序,放到正式环境之...
    斐波那契额阅读 1,812评论 1 12
  • 一、Vagrant 介绍 Vagrant 是一个软件,可以自动化虚拟机的安装和配置流程,用来管理虚拟机,如 Vir...
    zpei0411阅读 3,901评论 0 7
  • 最近服务器老是宕机,学习的时候很多环境有需要集群,忍无可忍的情况下终于决定自己装一波虚拟机宫学习使用。本人系统为D...
    行书以鉴阅读 1,915评论 0 1
  • 什么是Vagrant简单来说,Vagrant 就是一个虚拟机的集成管理器。 我们用它可以快速创建虚拟机,可以快速部...
    嗝喯唲阅读 643评论 0 0
  • 1,介绍Vagrant 我们做web开发的时候经常要安装各种本地测试环境,比如apache,php,mysql,r...
    meng_philip123阅读 2,506评论 0 12