Google Cloud Compute Engine 영구 디스크 스냅샷 일정이 작동하지 않습니다.

Google Cloud Compute Engine 영구 디스크 스냅샷 일정이 작동하지 않습니다.

GCP에서 terraform을 사용하여 VM을 만들었고 google_compute_disk, google_compute_resource_policy, google_compute_disk_resource_policy_attachment 리소스와 별도로 영구 디스크도 만들어 스냅샷 일정을 디스크에 연결했습니다.

이틀 전의 일이며 스냅샷이 생성되지 않았습니다.
비슷한 문제를 겪은 사람이 있나요?

일정은 매일로 설정됩니다.

이것은 내가 사용한 Terraform 구성입니다.


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"
}

답변1

Set guest_flush = false(이것은 Windows에서만 작동하며 gcp와 협상할 수 없는 것처럼 보입니다.

Stackdriver 로그 확인 - 디스크

답변2

이것은 Windows에서만 작동하며 gcp에서는 협상할 수 없는 것처럼 보입니다.

이것은사실이 아니다. 기사를 따라주세요Linux 애플리케이션 일관성 영구 디스크 스냅샷 만들기필요한 것이 무엇인지 설명되어 있으며 기본적으로 다음과 같습니다.

  1. [Snapshots]섹션을 추가 하고 를 사용하여 에이전트를 다시 시작합니다 . 마지막 명령은 디렉토리가 아직 존재하지 않는 경우 디렉토리를 생성합니다./etc/default/instance_configs.cfgenabled = truesudo systemctl restart google-guest-agent.service/etc/google/snapshots
  2. 만들다미리그리고우편스냅샷 스크립트 /etc/google/snapshots/pre.sh/etc/google/snapshots/post.sh . 스크립트가 다음과 같은지 확인하세요.실행 가능루트(문서에 명시적으로 명시되어 있지는 않지만 알아내기 쉽습니다) 그리고
  3. 게스트 플러시가 활성화된 스냅샷(또는 스냅샷 일정)을 생성합니다.

방금 GCP에서 작동하는지 확인했습니다.

위에서 설명한 대로 VM 인스턴스를 준비하지 않은 경우 아래와 같이 애플리케이션 일치 스냅샷을 생성하려고 하면 오류가 발생합니다.

  • 위 1.이 완료되지 않은 경우: 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).";
  • 2. 위의 작업이 수행되지 않은 경우: 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).로그 탐색기에서와 같은 오류를 확인하세요. 오류는 다음과 같은 쿼리로 쉽게 찾을 수 있습니다.

severity=ERROR`
resource.type="gce_disk"
protoPayload.methodName="ScheduledSnapshots"

위에서 설명한 것처럼 VM을 준비하지 않았다는 뜻입니다.

관련 정보