이름 : web01
리전 : asia-northeast3(서울)
영역 : asia-northeast3-a
머신 유형 : e2-micro(vCPU 2개, 1GB 메모리)
부팅 디스크
액세스 범위 : 모든 Cloud API에 대한 전체 액세스 허용
방화벽 : HTTP 트래픽 허용
보안 > 항목추가 > 공개키 넣기(id_rsa.pub)
사용자 데이터
#!/bin/bash
yum install -y httpd
systemctl enable --now httpd
echo "<h1>WEB01</h1>" > /var/www/html/index.html
$ sudo vi /etc/httpd/conf/httpd.conf
Listen 8080
▶ 적용방법
web01 > 네트워크 태그에 web01 추가
결과
#!/bin/bash
apt update
apt install -y apache2
echo "<h1>WEB02</h1>" > /var/www/html/index.html
▶ 상태확인 생성
이름 : frontend
검토
- 객체 스토리지 (Cloud Storage) ; AWS S3, Azure blob - URL : wget
- 블록 스토리지 (Persistent Disk) ; AWS EBS, Azure Disk - OS, App, root 볼륨
- 파일 스토리지 (File Store) ; AWS EFS, Azure files - NFS 공유폴더, mount, SMB(Server message Block ; samba)
-> gcp.tar를 files안에 업로드
▶ mobaxterm
[r2com@web01 conf]$ sudo yum install -y wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* epel: ftp.iij.ad.jp
* extras: mirror.kakao.com
* updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================
Installing:
wget x86_64 1.14-18.el7_6.1 base 547 k
Transaction Summary
==============================================================================================================================================================================================================
Install 1 Package
Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
wget-1.14-18.el7_6.1.x86_64.rpm | 547 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-18.el7_6.1.x86_64 1/1
Verifying : wget-1.14-18.el7_6.1.x86_64 1/1
Installed:
wget.x86_64 0:1.14-18.el7_6.1
Complete!
▶ GCP
▶ mobaxterm
[r2com@web01 ~]$ sudo wget https://storage.googleapis.com/seo2022/files/gcp.tar
--2022-06-08 08:08:19-- https://storage.googleapis.com/seo2022/files/gcp.tar
Resolving storage.googleapis.com (storage.googleapis.com)... 34.64.4.48, 34.64.4.80, 34.64.4.112, ...
Connecting to storage.googleapis.com (storage.googleapis.com)|34.64.4.48|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 463360 (452K) [application/x-tar]
Saving to: ‘gcp.tar’
100%[====================================================================================================================================================================>] 463,360 --.-K/s in 0.005s
2022-06-08 08:08:19 (89.2 MB/s) - ‘gcp.tar’ saved [463360/463360]
[r2com@web01 ~]$ sudo tar -xvf gcp.tar -C /var/www/html/
assets/
assets/img/
assets/mail/
assets/img/avataaars.svg
assets/img/favicon.ico
assets/img/portfolio/
assets/mail/contact_me.js
assets/mail/contact_me.php
assets/mail/jqBootstrapValidation.js
assets/img/portfolio/cabin.png
assets/img/portfolio/cake.png
assets/img/portfolio/circus.png
assets/img/portfolio/game.png
assets/img/portfolio/safe.png
assets/img/portfolio/submarine.png
css/
css/styles.css
js/
js/scripts.js
index.html
[r2com@web01 ~]$ curl ipconfig.io
34.64.109.63
▶ 스토리지 > 디스크
[r2com@web01 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
└─sda2 8:2 0 19.8G 0 part /
-> 현재는 sdb 없음
xfs -> Ubuntu나 Debian에서 attach 실패할 가능성 높음 (호환성 문제)
ext4가 더 유리함
[r2com@web01 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
└─sda2 8:2 0 19.8G 0 part /
sdb 8:16 0 10G 0 disk
[r2com@web01 ~]$ sudo mkfs -t ext4 /dev/sdb
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[r2com@web01 ~]$ sudo mount /dev/sdb /mnt
[r2com@web01 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 486M 0 486M 0% /dev
tmpfs 494M 0 494M 0% /dev/shm
tmpfs 494M 6.6M 488M 2% /run
tmpfs 494M 0 494M 0% /sys/fs/cgroup
/dev/sda2 20G 2.6G 18G 13% /
/dev/sda1 200M 12M 189M 6% /boot/efi
tmpfs 99M 0 99M 0% /run/user/1000
/dev/sdb 9.8G 37M 9.2G 1% /mnt
-> mnt에 저장하면 sdb에도 저장됨