본문 바로가기

Biusiness Insight/Computer Science

[구글 클라우드 플랫폼] 가상 머신 만들기

반응형

 

구글 클라우드 플랫폼(Google Cloud Platform, GCP) 가상 머신 만들기

 

Google Cloud Shell 활용 기본

 

1. GCP Console 우측 상단 툴바에서 "Cloud Shell 열기" 버튼 클릭

 

2. 사용중인 계정 목록 확인

gcloud auth list

출력 예시 :

Credentialed accounts : 

- <myaccount>@<mydomain>.com (active)

           Credentialed Accounts
ACTIVE  ACCOUNT
*       student-00-f277cc1c8483@qwiklabs.net

To set the active account, run:
    $ gcloud config set account `ACCOUNT`

 

3. 프로젝트 ID 목록 확인

gcloud config list project

출력 예시 :

[core]

project = <project_ID>

[core]
project = qwiklabs-gcp-00-5344faae0668

Your active configuration is: [cloudshell-31578]

 

4. 기타 gcloud 명령어

Google Cloud gcloud 개요 : gloud 명령어 도구 (Cloud SDK 문서)

https://cloud.google.com/sdk/gcloud

 

 

리전(Region)과 영역(Zone)의 이해

 

https://cloud.google.com/compute/docs/regions-zones/

- 리전(Region) : 리소스를 실행할 수 있는 특정 지리적 위치

- 영역(zone) : 각 리전에는 1개 이상의 영역이 있음 (예: asai-northeast3 리전은, asia-northeast3-a, asia-northeast3-b, asia-northeast3-c 영역이 있는 서울 리전을 나타냄)

- asia-northeast3 (대한민구 서울) 리전

  . 영역 : asia-northeast3-a, asia-northeast3-b, asia-northeast3-c 

  . 사용 가능한 CPU 플랫폼 : intel Xeon(Skylake) 플랫폼(기본 플랫폼)

  . 기능 : Skylake 플랫폼을 사용할 때 최대 96개의 vCPU가 있는 N1 머신 유형, 로컬 SSD, 단독 테넌트 노드

- GPU 사용 가능한 리전/영역 : asia-east1-a, asia-east1-b, asia-northeast1-a, asia-south1-b, asia-southeast1-b, austrailia-southeast1-a, austrailia-southeast1-b, europe-west1-b, europe-west1-d, eurpoe-west4-a, eurpoe-west4-b, eurpoe-west4-c, northamerica-northeast1-a, northamerica-northeast1-c, southamerica-east1-c, us-central1-a, us-central1-b, us-central1-c, us-central1-f, us-east1-b, us-east1-c, us-east1-d, us-east4-a, us-east4-b, us-east4-c, us-west1-a, us-west1-b, us-west2-b, us-west2-c

리전

영역

위치

asia-east1

a, b, c

타이완 창후아 카운티

asia-east2

a, b, c

홍콩

asia-northeast1

a, b, c

일본 도쿄

asia-northeast2

a, b, c

일본 오사카

asia-northeast3

a, b, c

대한민국 서울

asia-south1

a, b, c

인도 뭄바이

asia-southeast1

a, b, c

싱가포르 주롱웨스트

australia-southeast1

a, b, c

오스트레일리아 시드니

europe-north1

a, b, c

핀란드 하미나

europe-west1

b, c, d

벨기에 상기슬랑

europe-west2

a, b, c

영국 잉글랜드 런던

europe-west3

a, b, c

독일 프랑크푸르트

europe-west4

a, b, c

네덜란드 엠스하벤

europe-west6

a, b, c

스위스 취리히

northamerica-northeast1

a, b, c

캐나다 퀘벡 몬트리올

southamerica-east1

a, b, c

브라질, 오사스쿠(상파울루)

us-central1

a, b, c, f

미국 아이오와주 카운슬블러프즈

us-east1

b, c, d

미국 사우스캐롤라이나주 몽크스 코너

us-east4

a, b, c

미국 북부 버지니아주 애쉬번

us-west1

a, b, c

미국 오리건주 댈러스

us-west2

a, b, c

미국 캘리포니아주 로스앤젤레스

 

 

Cloud Console에서 새로운 인스턴스 만들기

 

1. GCP Consloe 좌측 상단의 탐색 메뉴 > Compute Engine > VM인스턴스 선택 후, [만들기, Create] 클릭

GCP Consloe 에서 새로운 인스턴스 생성

 

2. 인스턴스 생성을 위한 매개변수

필드

추가정보

이름

gcelab

 

리전

us-central1(아이오와)

또는

asia-south1(뭄바이)

리전 및 영역 문서에서 리전에 관해 자세히 알아보세요.

영역

us-central1-c

또는

asia-south1-c

참고: 나중에 필요하므로 선택한 영역을 기억해 둡니다.

리전 및 영역 문서에서 영역에 관해 자세히 알아보세요.

머신 유형

vCPU 2개

(n1-standard-2)입니다.

2-CPU, 7.5GB RAM 인스턴스입니다.

마이크로 인스턴스부터 32코어/208GB RAM 인스턴스까지 다양한 머신 유형이 있습니다. 머신 유형 문서에서 자세히 알아보세요.

참고: 새로운 프로젝트에는 기본 리소스 할당량이 있어 CPU 코어 수가 제한될 수 있습니다. 이 실습 외부 프로젝트에서 작업할 때 더 요청할 수 있습니다.

부팅 디스크

새로운 10GB 표준 영구 디스크

OS 이미지: Debian GNU/Linux 9(stretch)

Debian, Ubuntu, CoreOS는 물론 Red Hat Enterprise Linux 및 Windows Server와 같은 프리미엄 이미지를 포함한 다양한 이미지를 선택할 수 있습니다. 자세한 내용은 운영체제 문서를 참조하세요.

방화벽

HTTP 트래픽을 선택합니다.

나중에 설치하게 될 웹 서버에 액세스할 수 있도록 이 옵션을 선택하세요.

참고: 이렇게 하면 포트 80에서 HTTP 트래픽을 허용하기 위한 방화벽 규칙이 자동으로 만들어집니다.

 

인스턴스(Instance) 생성을 위한 매겨변수 참조

 

 

3. 인스턴스 생성 확인 및 SSH 연결

인스턴스 SSH 실행

 

4. NGINX 웹 서버 설치

SSH연결 후, sudo를 사용하여 root 권한 획득

sudo su -

 

root 권한으로 OS 업데이트

apt-get update

 

NGINX 설치 및 실행 확인

apt-get install nginx -y

ps auwx | grep nginx

출력 예시 : 

 

http://EXTERNAL_IP/ 를 접속하여 웹페이지 확인

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

 

5. gcloud로 새 인스턴스 만들기

Cloud Shell에서 gcloud 를 사용하여 새 가상머신 인스턴스 생성하거나 [YOUR_ZONE]에서 제공된 영역 중 하나로 대체 

gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone [your_zone]

 

기본값 확인

gcloud compute instances create --help

 

gcloud에서 사용할 기본 리전과 영역 설정 명령어

gcloud config set compute/zone ...

gcloud config set compute/region ...

 

gcloud를 사용하여 SSH를 통해 인스턴스 연결

gcloud compute ssh gcelab2 --zone [YOUR_ZONE]

 

연결 후에는 원격 쉘에서 종료하여 SSH연결을 끊는다.

exit
반응형