首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >持久性磁盘快照计划不工作

持久性磁盘快照计划不工作
EN

Server Fault用户
提问于 2020-08-29 10:04:30
回答 2查看 3.1K关注 0票数 3

我在GCP上创建了一个带有terraform的VM,并与google_compute_disk、google_compute_resource_policy、google_compute_resource_policy资源分别创建了一个持久磁盘,以便将快照计划附加到磁盘上。

这是两天前的事了,还没有创建快照。有没有人遇到过类似的问题?

日程设置为每日一次。

这是我使用的terraform配置

代码语言:javascript
复制
resource "google_compute_disk" "fast_storage" {
  name = "${var.env}-fast-disk"
  type = "pd-ssd"
  size = 50 #GiB
  zone = var.zone
  labels = {
    environment = var.env
    type        = "ssd"

  }
  physical_block_size_bytes = 4096
}


resource "google_compute_resource_policy" "backup_policy" {
  name   = "${var.env}-backup-policy"
  region = var.region
  snapshot_schedule_policy {
    schedule {
      daily_schedule {
        days_in_cycle = 1
        start_time    = "04:00"
      }
    }
    retention_policy {
      max_retention_days    = 5
      on_source_disk_delete = "KEEP_AUTO_SNAPSHOTS"
    }
    snapshot_properties {
      labels = {
        environment = var.env
        type        = "ssd"
      }
      storage_locations = ["eu"]
      guest_flush       = true
    }
  }

}


resource "google_compute_disk_resource_policy_attachment" "backup_policy_attachment" {
  name = google_compute_resource_policy.backup_policy.name
  disk = google_compute_disk.fast_storage.name
  zone = var.zone
}


resource "google_compute_instance" "main" {
  name                      = "${var.env}-main-server"
  machine_type              = "custom-2-4096"
  zone                      = var.zone
  allow_stopping_for_update = true
  desired_status            = "RUNNING"
  deletion_protection       = true
  tags                      = ["${var.env}-main-server"]

  boot_disk {
    auto_delete = false

    mode = "READ_WRITE"
    initialize_params {
      image = "debian-cloud/debian-10"
      type  = "pd-ssd"
      size  = 20
    }
  }

  network_interface {
    network    = var.network_id
    subnetwork = var.subnetwork_id
    network_ip = google_compute_address.main_server_internal.address

    access_config {
      nat_ip = google_compute_address.main_server_external.address
    }
  }
  scheduling {
    on_host_maintenance = "MIGRATE"
    automatic_restart   = true
  }

  lifecycle {
    ignore_changes = [attached_disk]
  }
}


resource "google_compute_attached_disk" "fast_storage" {
  disk        = google_compute_disk.fast_storage.id
  instance    = google_compute_instance.main.id
  device_name = "fast"
  mode        = "READ_WRITE"
}
EN

回答 2

Server Fault用户

回答已采纳

发布于 2020-11-23 04:55:11

设置guest_flush = false (这只适用于Windows,看起来它与gcp是不可协商的。)

检查堆栈驱动程序日志-磁盘

票数 3
EN

Server Fault用户

发布于 2022-08-18 10:14:39

这只适用于Windows,看起来它与gcp是不可协商的

这是not true。请按照创建与持久磁盘快照一致的Linux应用程序一文解释什么是必要的,这基本上是:

  1. 使用[Snapshots]/etc/default/instance_configs.cfg部分添加到enabled = true,并使用sudo systemctl restart google-guest-agent.service重新启动代理。如果还不存在,最后一个命令将创建/etc/google/snapshots目录;
  2. 分别在/etc/google/snapshots/pre.sh/etc/google/snapshots/post.sh上创建预快照脚本和后快照脚本。确保脚本是可执行的到root (这在文档中没有明确说明,但很容易理解);
  3. 创建启用客户刷新的快照(或快照计划)。

刚刚证实它在GCP中起作用了。

您还没有准备好VM实例(S),如前所述,您在创建应用程序的快照时可能会出错,如下所示:

  • 如果没有完成上述操作:Operation type [createSnapshot] failed with message "You can only use guest-flush on disks attached to instances with supported operating systems. Make sure you have the latest image version and agent installed with required services (e.g. VSS for Windows)."
  • 如果没有完成上面的操作:Operation type [createSnapshot] failed with message "Guest Consistent Snapshot failed (Detail: pre_snapshot_script or post_snapshot_script not found). Verify you are running the latest image version and agent. For non-Windows, review settings in /etc/default/instance_configs.cfg on the instance. For more information, see the Guest Consistent Snapshot documentation."或下面的代码,如果脚本没有可执行:Operation type [createSnapshot] failed with message "Guest Consistent Snapshot failed (Detail: unhandled script return code -1). Verify you are running the latest image version and agent. For non-Windows, review settings in /etc/default/instance_configs.cfg on the instance. For more information, see the Guest Consistent Snapshot documentation."

如果快照计划没有生成快照,请检查日志资源管理器中的You can only use guest-flush on disks attached to instances with supported operating systems. Make sure you have the latest image version and agent installed with required services (e.g. VSS for Windows).之类的错误,这些错误可以很容易地通过以下查询找到

代码语言:javascript
复制
severity=ERROR`
resource.type="gce_disk"
protoPayload.methodName="ScheduledSnapshots"

我的意思是你没有像上面解释的那样准备好你的越南船民。

票数 2
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1031951

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档