Virtual environment/Google Cloud Platform

가상머신 만들기

D4tai1 2018. 4. 26.

 

명령어 확인 : https://cloud.google.com/sdk/gcloud

 

 

1) $ gcloud auth list

= PROJECT_ID에 설정되어 있는 것 확인

 

google369434_student@qwiklabs-gcp-d5a796316a20c809:~$ gcloud auth list

Credentialed Accounts
ACTIVE ACCOUNT
* google369434_student@qwiklabs.net
To set the active account, run:
 $ gcloud config set account `ACCOUNT`

 

2) $ gcloud config list project

=

google369434_student@qwiklabs-gcp-d5a796316a20c809:~$ gcloud config list project
[core]
project = qwiklabs-gcp-d5a796316a20c809
Your active configuration is: [cloudshell-23226] 

 

3) $ gcloud config set project <PROJECT_ID>

= gcloud 지원이 설정되어 있지 않을 경우 설정

google369434_student@qwiklabs-gcp-d5a796316a20c809:~$ gcloud config set project qwiklabs-gcp-d5a796316a20c809
Updated property [core/project]. 

 

NGINX Web Server Install

 

4) $ sudo su -

= SSH를 통해 접속한 다음 sudo로 root Access 권한을 얻기

 

5) $ apt-get update

= root 권한으로 OS를 업데이트

root@gcelab:~# apt-get update

....... 

Get:29 http://deb.debian.org jessie-backports/main amd64 2018-04-22-2033.30.pdiff [1,505 B]         
Get:30 http://deb.debian.org jessie-backports/main 2018-04-20-2023.55.pdiff [44 B] 

Fetched 1,560 kB in 3s (416 kB/s)                    
Reading package lists... Done 

 

6) $ apt-get install nginx -y

= NGINX 설치

root@gcelab:~# apt-get install nginx -y
Reading package lists... Done
Building dependency tree

 

... ...

Processing triggers for sgml-base (1.26+nmu4) ...
Processing triggers for systemd (215-17+deb8u7) ...
Processing triggers for sgml-base (1.26+nmu4) ... 

 

7) $ ps auwx | grep nginx

= NGINX가 실행 중인지 확인

root@gcelab:~# ps auwx | grep nginx
root      2739  0.0  0.0  91192  3012 ?        Ss   11:04   0:00 nginx: master process /usr/sbin/nginx -g daemon on
; master_process on;
www-data  2740  0.0  0.0  91556  3600 ?        S    11:04   0:00 nginx: worker process                          
www-data  2741  0.0  0.0  91556  3600 ?        S    11:04   0:00 nginx: worker process                          
www-data  2742  0.0  0.0  91556  3600 ?        S    11:04   0:00 nginx: worker process                          
www-data  2743  0.0  0.0  91556  3600 ?        S    11:04   0:00 nginx: worker process                          
root      2818  0.0  0.0  12728  2180 pts/0    S+   11:09   0:00 grep nginx

 

8) 설치한 Web Server 확인

= 마우스로 새 인스턴스(가상머신) 만들기

 

9) $ gcloud compute instances create gcelab2 --zone us-central1-c

= gcloud shell을 사용하여 새 인스턴스(가상머신) 만들기

= 정보 Debian8(Jessie)이미지, 머신유형(n1-standard-1) 등 확인가능

 

google369493_student@qwiklabs-gcp-5fda8dbf4ab97038:~$ gcloud compute instances create geclab2 --zone us-central1-c
Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-5fda8dbf4ab97038/zones/us-central1-c/instances/geclab2].
NAME     ZONE           MACHINE_TYPE   PREEMPTIBLE         INTERNAL_IP    EXTERNAL_IP     STATUS
geclab2  us-central1-c  n1-standard-1               10.128.0.4   35.224.67.194  RUNNING

 

10) $ gcloud compute instances create --help

= 모든 기본값을 확인하기위한 명령어

 

11) $ gcloud config set compute/zone ...

$ gcloud config set compute/region ...

= 항상 같은지역/영역에서 작업하려면 매번 --zone 플래그를 추가하고 싶지 않다면,

gcloud가 사용하는 기본지역 및 영역을 설정

 

12) $ gcloud compute ssh gcelab2 --zone us-central1-c

= gcloud를 통해 인스턴스에 SSH로 접속

 

google369543_student@qwiklabs-gcp-00425ddef28c797a:~$ gcloud compute ssh gcelab2 --zone us-central1-c
WARNING: The public SSH key file for gcloud does not exist.
WARNING: The private SSH key file for gcloud does not exist.
WARNING: You do not have an SSH key for gcloud.
WARNING: SSH keygen will be executed to generate a key.
This tool needs to create the directory
[/home/google369543_student/.ssh] before being able to generate SSH
keys.
Do you want to continue (Y/n)?  Y

 

Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again: 

[암호를 비워두려면 Enter 로 암호섹션 건너띄기]

 

13) $ exit

= 원격 셸 종료. SSH 연결 해제

'Virtual environment > Google Cloud Platform' 카테고리의 다른 글

도커  (0) 2018.04.27
BigQuery: Qwik Start - Web User Interface  (0) 2018.04.27
Kubernetes Node  (0) 2018.04.26
클라우드 런처로 서비스 제공  (0) 2018.04.26

댓글