【问题标题】:Terraform vSphere Slow BootTerraform vSphere 慢启动
【发布时间】:2017-08-24 15:46:44
【问题描述】:

这是我第一次尝试使用 terraform 创建 vSphere VM。 VM 确实成功创建,但需要 7 分钟才能完成。以下是我采取的步骤。

  • 手动上传 Ubuntu 16.04 ova。
  • 手动将图像转换为模板。
  • 通过 GUI 从模板手动创建 VM。它需要 虚拟机启动大约需要 20 秒。
  • 使用指向模板的 terraform 创建 VM。这需要 7 分钟。

使用 terraform,VM 启动顺序与手动创建的 VM 相同,然后在以下消息处挂起大约 6 分半钟。

[   12.109016] blk_update_request: I/O error, dev fd0, sector 0

手动和 terraform VM 创建的错误消息重复大约 6 次。但是在手动创建期间,它几乎立即移至登录提示。在 terraform 创建期间,它会在此消息处挂起大约 6 分半钟,然后进入登录提示。知道为什么它在 terraform 创建期间挂起吗?

intance.tf

resource "vsphere_virtual_machine" "hellovm" {
  name = "hellovm2"
  vcpu = 1
  memory = 1024
  datacenter = "Lab09-Datacenter01"

  network_interface {
    label = "Lab09-NetA"
  }

  disk {
    template = "${var.vmtemp}"
    type = "thin"
    datastore = "${var.vmdatastore}"
  }
}

terraform 应用标准输出

Macbook12:concoursebootstrap steve$ terraform apply
vsphere_folder.concourse-base: Refreshing state... (ID: Lab09-Datacenter01/VirtualMachines)
 vsphere_virtual_machine.hellovm: Refreshing state... (ID: hellovm)
vsphere_virtual_machine.hellovm: Creating...
  datacenter:                             "" => "Lab09-Datacenter01"
  detach_unknown_disks_on_delete:         "" => "false"
  disk.#:                                 "" => "1"
  disk.3867083049.bootable:               "" => ""
  disk.3867083049.controller_type:        "" => "scsi"
  disk.3867083049.datastore:              "" => "nfs-lab09-vol1"
  disk.3867083049.iops:                   "" => ""
  disk.3867083049.keep_on_remove:         "" => ""
  disk.3867083049.key:                    "" => "<computed>"
  disk.3867083049.name:                   "" => ""
  disk.3867083049.size:                   "" => ""
  disk.3867083049.template:               "" => "ubuntu-16.04-server-cloudimg-amd64"
  disk.3867083049.type:                   "" => "thin"
  disk.3867083049.uuid:                   "" => "<computed>"
  disk.3867083049.vmdk:                   "" => ""
  domain:                                 "" => "vsphere.local"
  enable_disk_uuid:                       "" => "false"
  linked_clone:                           "" => "false"
  memory:                                 "" => "1024"
  memory_reservation:                     "" => "0"
  moid:                                   "" => "<computed>"
  name:                                   "" => "hellovm"
  network_interface.#:                    "" => "1"
  network_interface.0.ip_address:         "" => "<computed>"
  network_interface.0.ipv4_address:       "" => "<computed>"
  network_interface.0.ipv4_gateway:       "" => "<computed>"
  network_interface.0.ipv4_prefix_length: "" => "<computed>"
  network_interface.0.ipv6_address:       "" => "<computed>"
  network_interface.0.ipv6_gateway:       "" => "<computed>"
  network_interface.0.ipv6_prefix_length: "" => "<computed>"
  network_interface.0.label:              "" => "Lab09-NetA"
  network_interface.0.mac_address:        "" => "<computed>"
  network_interface.0.subnet_mask:        "" => "<computed>"
  skip_customization:                     "" => "false"
  time_zone:                              "" => "Etc/UTC"
  uuid:                                   "" => "<computed>"
  vcpu:                                   "" => "1"
vsphere_virtual_machine.hellovm: Still creating... (10s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (20s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (30s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (40s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (50s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (1m0s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (1m10s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (1m20s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (1m30s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (1m40s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (1m50s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (2m0s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (2m10s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (2m20s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (2m30s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (2m40s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (2m50s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (3m0s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (3m10s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (3m20s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (3m30s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (3m40s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (3m50s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (4m0s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (4m10s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (4m20s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (4m30s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (4m40s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (4m50s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (5m0s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (5m10s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (5m20s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (5m30s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (5m40s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (5m50s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (6m0s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (6m10s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (6m20s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (6m30s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (6m40s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (6m50s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (7m0s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (7m10s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (7m20s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (7m30s elapsed)
vsphere_virtual_machine.hellovm: Still creating... (7m40s elapsed)
vsphere_virtual_machine.hellovm: Creation complete (ID: hellovm)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

ubuntu dmesg

虚拟机创建后的 terraform 跟踪输出,等待启动

地形输出的其余部分。几分钟的重复日志然后是以下

【问题讨论】:

    标签: ubuntu terraform vsphere


    【解决方案1】:

    很抱歉,您在使用 vSphere 提供商时遇到问题!

    从我在日志中看到的内容和通过查看您的配置来看,这可能是因为虚拟机在启动时不一定具有 IP 地址。 Terraform vSphere 提供程序当前等待所有接口具有网络连接(通过 VMware 工具报告),然后再继续读取虚拟机的状态。在创建 VM 时也是如此,因此这很可能是您的问题的原因(尤其是从日志中显示 waiting for interfaces to appear 消息后的长时间等待来看)。

    查看您的配置,我发现 TF 代码中没有分配 ipv4_address,这意味着 Terraform 将发送一个 VM 自定义规范,告诉接口使用 DHCP。如果您的网络上没有 DHCP,这可能是问题的一部分。

    我的建议:

    • 如果您正在使用的网络上没有 DHCP,请使用 ipv4_address 和相关选项为虚拟机分配一个 IP 地址,然后再次尝试申请。您还可以在相关网络上安装 DHCP,以避免在 TF 代码中分配 IP 地址。
    • 确保 VM 已安装 VMware 工具。您也可以在 Ubuntu 上安装 open-vm-tools 软件包。
    • 最后,如果您仍然遇到问题,您可以检查 VM 的自定义日志 - 这些可以在操作系统上的 /var/log/vmware-imc/toolsDeployPkg.log 上找到。 More info on Linux customization

    如果这能为您解决问题,请告诉我!

    【讨论】:

    • 感谢您的建议。我会试一试并发布结果。
    • 您好 vancluever,我们尝试将 IP 分配更改为静态值以尝试删除该部分,但部署时间没有任何变化。查看 toolsDeployPkg.log 中的日志后,没有与操作关联的时间戳,因此很难在输出中看到原因。对于内核启动过程和登录提示的显示之间发生了什么,您还有其他建议吗
    • @ptsw 很抱歉在这个问题上无线电沉默!我只想提一下,我们今天发布了插件的 0.3.0 版本,它显着改变了自定义和网络服务员的行为,所以你可能想试一试!此外,如果这些更改都没有为您解决问题,您可能希望完全跳过服务员,现在可以通过将新的 wait_for_guest_net 选项设置为 false 来实现。告诉我进展如何!
    • 感谢您的信息。我们通过使用不同的图像解决了这个问题。似乎有一些特定于我们使用的图像导致它挂起。我们从未确定根本原因。 @ecoles 调试了一段时间。他可能有什么要补充的。
    猜你喜欢
    • 2020-10-17
    • 2021-11-13
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 2016-03-18
    • 2020-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多