VM Manager 설정 확인


이 문서를 사용하여 VM Manager가 올바르게 설정되어 있는지 확인합니다. VM Manager 설정에 대한 자세한 내용은 VM Manager 설정을 참조하세요.

설정을 확인하려면 문제 해결 명령어를 사용하거나 가상 머신(VM) 인스턴스에서 수동 확인을 수행하면 됩니다.

시작하기 전에

  • Windows VM의 경우 PowerShell 3.0 이상을 사용하세요.
  • 아직 인증을 설정하지 않았다면 설정합니다. 인증은 Google Cloud 서비스 및 API에 액세스하기 위해 ID를 확인하는 프로세스입니다. 로컬 개발 환경에서 코드 또는 샘플을 실행하려면 다음과 같이 Compute Engine에 인증하면 됩니다.

    이 페이지의 샘플 사용 방법에 대한 탭을 선택하세요.

    콘솔

    Google Cloud 콘솔을 사용하여 Google Cloud 서비스 및 API에 액세스할 때는 인증을 설정할 필요가 없습니다.

    gcloud

    1. Google Cloud CLI를 설치한 후 다음 명령어를 실행하여 초기화합니다.

      gcloud init
    2. 기본 리전 및 영역을 설정합니다.

문제 해결 명령어 사용

os-config troubleshoot 명령어를 사용하여 설정을 확인합니다. 검사 중 하나라도 실패하면 문제 해결 방법에 대한 피드백이 제공됩니다.

gcloud compute os-config troubleshoot VM_NAME \
   --zone=ZONE

다음을 바꿉니다.

  • VM_NAME: 문제를 해결할 VM 인스턴스의 이름
  • ZONE: 인스턴스가 있는 영역입니다.

Examples

  • 예시 1: VM 인스턴스에 설정 문제가 발생하면 os-config troubleshoot 명령어 출력 표시
  • 예시 2: VM 인스턴스가 올바르게 설정되면 os-config troubleshoot 명령어 출력 표시

예 1

asia-east2-b 영역에서 my-instance-1이라는 VM 인스턴스 문제를 해결하려면 다음을 실행합니다.

gcloud compute os-config troubleshoot my-instance-1 \
    --zone=asia-east2-b

다음과 유사한 결과가 출력됩니다.

OS Config troubleshooter tool is checking if there are issues with the
VM Manager setup for this VM instance.

> Is the OS Config API enabled? Yes
> Is the OS Config agent enabled? Yes
> Is the OS Config agent up to date? No

The version of OS Config agent running on this VM instance is not the
latest version.
See https://cloud.google.com/compute/docs/manage-os/upgrade-vm-manager#update-agent
on how to update the agent.

예시 2

us-west1-b 영역에서 my-instance-2라는 VM 인스턴스 문제를 해결하려면 다음을 실행합니다.

gcloud compute os-config troubleshoot my-instance-2 \
    --zone=us-west1-b

다음과 유사한 결과가 출력됩니다.

OS Config troubleshooter tool is checking if there are issues with the
VM Manager setup for this VM instance.

> Is the OS Config API enabled? Yes
> Is the OS Config agent enabled? Yes
> Is the OS Config agent up to date? Yes
> Is a service account present on the instance? Yes
> Is the OS Config Service account present for this instance? Yes
> Does this instance have a public IP or Private Google Access? Yes
This instance has a public IP.

수동 확인

VM Manager가 올바르게 설정되어 있는지 수동으로 확인하려면 다음 검사를 완료합니다.

VM Manager가 제대로 설정되었지만 여전히 문제가 발생하는 경우 VM Manager 문제 해결을 참조하세요.

OS 구성 API가 사용 설정되어 있는지 확인

Google Cloud 프로젝트에서 API가 사용 설정되었는지 확인합니다.

콘솔

Google Cloud Console에서 OS Config API 페이지로 이동합니다.

OS Config API로 이동

gcloud

gcloud services list --enabled

API가 사용 설정된 경우 다음과 유사한 결과가 출력됩니다.

osconfig.googleapis.com              OS Config API

API가 사용 설정되지 않은 경우 OS 구성 API를 사용 설정합니다.

메타데이터가 사용 설정되어 있는지 확인

Linux

프로젝트 메타데이터의 경우 VM에서 다음 단계를 완료합니다.

  1. 프로젝트 속성 엔드포인트를 쿼리합니다.

    curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/" \
    -H "Metadata-Flavor: Google"
    

    에이전트 메타데이터 값이 설정된 경우 다음과 유사한 결과가 출력됩니다.

    enable-osconfig
    
  2. enable-osconfig 값이 표시되면 엔드포인트를 쿼리합니다.

    curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/enable-osconfig" \
    -H "Metadata-Flavor: Google"

    사용 설정되면 엔드포인트가 TRUE를 반환합니다.

메타데이터가 사용 설정되지 않은 경우 OS 구성 메타데이터를 사용 설정합니다.

Windows

프로젝트 메타데이터의 경우 VM에서 관리자 권한으로 PowerShell 터미널을 열고 다음 명령어를 실행합니다.

  1. 프로젝트 속성 엔드포인트를 쿼리합니다.

    $value = (Invoke-RestMethod `
             -Headers @{'Metadata-Flavor' = 'Google'} `
             -Uri "http://metadata.google.internal/computeMetadata/v1/project/attributes/")
    $value
    

    에이전트 메타데이터 값이 설정된 경우 다음과 유사한 결과가 출력됩니다.

    enable-osconfig
    
  2. enable-osconfig 값이 표시되면 엔드포인트를 쿼리합니다.

    $value = (Invoke-RestMethod `
             -Headers @{'Metadata-Flavor' = 'Google'} `
             -Uri "http://metadata.google.internal/computeMetadata/v1/project/attributes/enable-osconfig")
    $value
    

    사용 설정되면 엔드포인트가 TRUE를 반환합니다.

메타데이터가 사용 설정되지 않은 경우 OS 구성 메타데이터를 사용 설정합니다.

OS 구성 에이전트가 설치되어 실행 중인지 확인

Linux

Linux VM에 에이전트가 설치되어 있는지 여부를 확인하려면 다음 명령어를 실행하세요.

sudo systemctl status google-osconfig-agent

에이전트가 설치되어 실행 중이면 출력은 다음과 유사합니다.

google-osconfig-agent.service - Google OSConfig Agent
Loaded: loaded (/lib/systemd/system/google-osconfig-agent.service; enabled; vendor preset:
Active: active (running) since Wed 2020-01-15 00:14:22 UTC; 6min ago
Main PID: 369 (google_osconfig)
 Tasks: 8 (limit: 4374)
Memory: 102.7M
CGroup: /system.slice/google-osconfig-agent.service
        └─369 /usr/bin/google_osconfig_agent

에이전트가 설치되지 않은 경우 OS 구성 에이전트를 설치합니다.

Windows

Windows VM에 에이전트가 설치되어 있는지 여부를 확인하려면 다음 명령어를 실행하세요.

PowerShell Get-Service google_osconfig_agent

에이전트가 설치되어 실행 중이면 출력은 다음과 유사합니다.

Status   Name               DisplayName
------   ----               -----------
Running  google_osconfig... Google OSConfig Agent

에이전트가 설치되지 않은 경우 OS 구성 에이전트를 설치합니다.

서비스 계정이 사용 설정되어 있는지 확인

서비스 계정 요구사항에 대한 상세 설명은 설정 개요를 참조하세요.

Linux

VM에서 다음을 실행합니다.

curl "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/" \
-H "Metadata-Flavor: Google"

출력에는 최소한 기본 서비스 계정이 포함되어야 합니다.

default/

Windows

VM에서 관리자 권한으로 PowerShell 터미널을 열고 다음 명령어를 실행합니다.

$value = (Invoke-RestMethod `
         -Headers @{'Metadata-Flavor' = 'Google'} `
         -Uri "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/")
$value

출력에는 최소한 기본 서비스 계정이 포함되어야 합니다.

default/

VM이 OS 구성 API와 통신할 수 있는지 확인

VM이 OS Config API와 통신할 수 있는지 확인하려면 Linux 또는 Windows VM에서 다음 명령어를 실행합니다.

ping osconfig.googleapis.com

OS Config API의 핑을 중지하려면 Control + C를 누릅니다.

VM이 비공개 VPC 네트워크 내에서 실행 중이고 공개 인터넷에 액세스할 수 없는 경우 비공개 Google 액세스를 사용 설정했는지 확인합니다.

비공개 Google 액세스를 사용 설정한 후 VM이 OS 구성 API와 통신할 수 있는지 확인합니다.

Linux

VM에서 다음을 실행합니다.

 curl --ssl 'https://osconfig.googleapis.com/$discovery/rest' | head

VM이 OS Config API와 통신할 수 있으면 명령어 결과는 다음과 비슷합니다.

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0{
"discoveryVersion": "v1",
"baseUrl": "https://osconfig.googleapis.com/",
"ownerName": "Google",
"version": "v1beta",
"schemas": {
  "GooSettings": {
    "description": "Googet patching is performed by running `googet update`.",
    "properties": {},
    "id": "GooSettings",
100  9569    0  9569    0     0   198k      0 --:--:-- --:--:-- --:--:--  198k

Windows

VM에서 관리자 권한으로 PowerShell 터미널을 열고 다음을 실행합니다.

 Invoke-RestMethod  -Headers @{'Metadata-Flavor' = 'Google'}
 -Uri 'https://osconfig.googleapis.com/$discovery/rest'

다음 단계