DevKim

[์Šคํ”„๋ง with AWS] EC2 ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ, putty ๋กœ ์›๊ฒฉ์ ‘์† ํ›„ ํ•„์ˆ˜ ์„ค์ •๋“ค ๋ณธ๋ฌธ

Spring Boot

[์Šคํ”„๋ง with AWS] EC2 ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ, putty ๋กœ ์›๊ฒฉ์ ‘์† ํ›„ ํ•„์ˆ˜ ์„ค์ •๋“ค

on_doing 2021. 7. 12. 17:44
728x90

๐ŸƒCH.06 AWS EC2๐Ÿƒ


โœ” ๋จผ์ €, AWS์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.

 

24์‹œ๊ฐ„ ์ž‘๋™ํ•˜๋Š” ์„œ๋ฒ„์—๋Š” 3๊ฐ€์ง€ ์„ ํƒ์ด ์žˆ๋‹ค.

ํ•˜๋‚˜๋Š” ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค์ด๊ณ  ๋‚˜๋จธ์ง€ ๋‘˜์€ ํ˜ธ์ŠคํŒ…์„œ๋น„์Šค๋‚˜ PC๋ฅผ 24์‹œ๊ฐ„ ๊ตฌ๋™์‹œํ‚ค๋Š” ์–ด๋งˆ๋ฌด์‹œํ•œ ๋ฐฉ๋ฒ•์ด์žˆ๋‹ค.

 

AWS๋Š” ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค์— ์†ํ•œ๋‹ค.

 

๋‚˜๋จธ์ง€ ๋‘๊ฐœ๊ฐ€ ์ €๋ ดํ•˜์ง€๋งŒ, ๋งŒ์•ฝ ํŠน์ • ์‹œ๊ฐ„์—๋งŒ ํŠธ๋ž˜ํ”ฝ์ด ๋ชฐ๋ฆฐ๋‹ค๋ฉด,

์œ ๋™์ ์œผ๋กœ ์‚ฌ์–‘์„ ๋Š˜๋ฆด ์ˆ˜ ์žˆ๋Š” ํด๋ผ์šฐ๋“œ๊ฐ€ ์œ ๋ฆฌํ•˜๋‹ค.

 

๐Ÿ“Œ ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค

- ์ธํ„ฐ๋„ท(ํด๋ผ์šฐ๋“œ)๋ฅผ ํ†ตํ•ด ์„œ๋ฒ„,์Šคํ† ๋ฆฌ์ง€(ํŒŒ์ผ ์ €์žฅ์†Œ), DB, ๋„คํŠธ์›Œํฌ, ์†Œํ”„ํŠธ์›จ์–ด, ๋ชจ๋‹ˆํ„ฐ๋ง ๋“ฑ์˜ ์ปดํ“จํŒ… ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

- ๋‹จ์ˆœํžˆ ๋ฌผ๋ฆฌ ์žฅ๋น„๋ฅผ ๋Œ€์—ฌํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๊ณ , ๊ทธ ์•ˆ์—์„œ ๋กœ๊ทธ ๊ด€๋ฆฌ, ๋„คํŠธ์›Œํฌ ๊ด€๋ฆฌ ๋“ฑ์„ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ง€์›ํ•˜๊ณ  ์žˆ๋‹ค.

 

๐Ÿ“Œ ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค ํ˜•ํƒœ

1. Infrastructure as a Service(IaaS, ์•„์ด์—์Šค)

- ๊ธฐ์กด ๋ฌผ๋ฆฌ ์žฅ๋น„๋ฅผ ๋ฏธ๋“ค์›จ์–ด์™€ ํ•จ๊ป˜ ๋ฌถ์–ด๋‘” ์ถ”์ƒํ™” ์„œ๋น„์Šค

- ๊ฐ€์ƒ๋จธ์‹ , ์Šคํ† ๋ฆฌ์ง€, ๋„คํŠธ์›Œํฌ, ์šด์˜์ฒด์ œ ๋“ฑ์˜ IT ์ธํ”„๋ผ๋ฅผ ๋Œ€์—ฌํ•ด์ฃผ๋Š” ์„œ๋น„์Šค

- AWS์˜ EC2,S3 ๋“ฑ

 

2. PlatForm as a Service (PaaS, ํŒŒ์Šค)

- IaaS๋ฅผ ํ•œ๋ฒˆ ๋” ์ถ”์ƒํ™”ํ•œ ์„œ๋น„์Šค๋กœ, ๋งŽ์€ ๊ธฐ๋Šฅ์ด ์ž๋™ํ™”๋˜์–ด์žˆ๋‹ค.

 

3. Software as a Service (Saas, ์‚ฌ์Šค)

- ์†Œํ”„ํŠธ์›จ์–ด ์„œ๋น„์Šค (ex. ๊ตฌ๊ธ€ ๋“œ๋ผ์ด๋ธŒ,dropbox..)

 

๐Ÿ“Œ EC2

EC2๋Š” AWS์—์„œ ์ œ๊ณตํ•˜๋Š” ์„ฑ๋Šฅ,์šฉ๋Ÿ‰ ๋“ฑ์„ ์œ ๋™์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์„œ๋ฒ„์ด๋‹ค.


โœ” ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•ด๋ณด์ž!

 

์•„๋งˆ์กด ๋ฆฌ๋ˆ…์Šค๋ฅผ ์„ ํƒํ•˜๊ณ ,

t2.micro๋ฅผ ์„ ํƒํ•ด์ค€๋‹ค.


์ด๋•Œ t2๋Š” ์š”๊ธˆํƒ€์ž…์„ ์ด์•ผ๊ธฐํ•˜๋ฉฐ, micro๋Š” ์‚ฌ์–‘์„ ๋œปํ•œ๋‹ค๊ณ ํ•œ๋‹ค.

t2,t3..๋“ฑ์„ T ์‹œ๋ฆฌ์ฆˆ๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค.

T์‹œ๋ฆฌ์ฆˆ๋Š” 'ํฌ๋ ˆ๋”ง'์ด๋ผ๋Š” ์ผ์ข…์˜ CPU๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํฌ์ธํŠธ ๊ฐœ๋…์ด ์žˆ๋‹ค๊ณ ํ•œ๋‹ค.

์ธ์Šคํ„ด์Šค ํฌ๊ธฐ์— ๋”ฐ๋ผ ์ •ํ•ด์ง„ ๋น„์œจ๋กœ CPU ํฌ๋ ˆ๋”ง์„ ๊ณ„์† ๋ฐ›๊ฒŒ๋˜๋ฉฐ, ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ๋•Œ๋Š” ํฌ๋ ˆ๋”ง์„ ์ถ•์ ํ•˜๊ณ , ์‚ฌ์šฉํ•  ๋•Œ ์ด ํฌ๋ ˆ๋”ง์„ ์‚ฌ์šฉํ•œ๋‹ค.

 

๋” ๋†’์€ ํŠธ๋ž˜ํ”ฝ์ด ์˜ค๋ฉด ํฌ๋ ˆ๋”ง์„ ์ข€ ๋” ์ ๊ทน์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉด์„œ ํŠธ๋ž˜ํ”ฝ์„ ์ฒ˜๋ฆฌํ•˜๊ฒŒ ๋˜๋Š”๋ฐ,

ํฌ๋ ˆ๋”ง์ด ๋ชจ๋‘ ์‚ฌ์šฉ๋˜๋ฉด ๋”์ด์ƒ EC2๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค๊ณ ํ•œ๋‹ค.

 

์ด๊ฑด CI/CD๋ฅผ ๊ฒฝํ—˜ํ•ด๋ณด๊ธฐ ์œ„ํ•œ ์ž‘์€ ์‹ค์Šต์ด๋‹ˆ, t2๋ฅผ ์‚ฌ์šฉํ•˜์ง€๋งŒ

ํŠธ๋ž˜ํ”ฝ์ด ๋†’์€ ์„œ๋น„์Šค๋“ค์€ T ์‹œ๋ฆฌ์ฆˆ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํฐ์ผ๋‚  ๊ฒƒ ๊ฐ™๋‹ค (๋„ˆ๋ฌด ๋‹น์—ฐํ•œ ์†Œ๋ฆฐ๊ฐ€?ใ…Ž)


โœ” ์›๊ฒฉ ์ ‘์†์„ ์œ„ํ•ด putty๋ฅผ ๋‹ค์šด ๋ฐ›์•„์ฃผ์ž

 

https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

 

Download PuTTY: latest release (0.75)

This page contains download links for the latest released version of PuTTY. Currently this is 0.75, released on 2021-05-08. When new releases come out, this page will update to contain the latest, so this is a good page to bookmark or link to. Alternativel

www.chiark.greenend.org.uk

putty๋Š” pem ํ‚ค๋กœ ์‚ฌ์šฉ์ด ์•ˆ๋ผ์„œ,pem ํ‚ค๋ฅผ ppk ํŒŒ์ผ๋กœ ๋ณ€ํ™˜ํ•ด์ค˜์•ผํ•œ๋‹ค.

puttygen์„ ์‚ฌ์šฉํ•˜์—ฌ ppk ํŒŒ์ผ๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๊ณ ,

๋‹ค์‹œ ๋“ฑ๋กํ•ด์„œ ์ ‘์†ํ•ด์ฃผ๋ฉด ์ •์ƒ์ ์œผ๋กœ ๋–ด๋‹ค..!

 

โœ” ์ด์ œ, ๊ธฐ๋ณธ์ ์œผ๋กœ ์„ค์ •ํ•ด์•ผํ•  ๊ฒƒ๋“ค์„ ์„ค์ •ํ•ด๋ณด์ž

 

๐Ÿ“Œ Java 8 ์„ค์น˜

sudo yum install -y java-1.8.0-openjdk-devel.x86_64

Java ๋‹ค๋ฅธ ๋ฒ„์ „์ด ์„ค์น˜๋˜์–ด์žˆ๋‚˜ ํ™•์ธํ•˜๊ณ  ์‚ฌ์šฉํ•  Java ๋ฒ„์ „์„ ์„ ํƒ (1,2 ์ค‘ ์ˆซ์ž ์ž…๋ ฅ)

sudo /usr/sbin/alternatives --config java

๋งˆ์ง€๋ง‰์œผ๋กœ ๋ฒ„์ „ ํ™•์ธ

java -version

๐Ÿ“Œ ํƒ€์ž„์กด ๋ณ€๊ฒฝ

๊ธฐ๋ณธ ํƒ€์ž„์กด์ธ UTC๋ฅผ ํ•œ๊ตญ์‹œ๊ฐ„ KST๋กœ ๋ณ€๊ฒฝํ•ด๋ณด์ž

 

๊ธฐ์กด localtime ์ง€์›Œ์ฃผ๊ณ 

sudo rm /etc/localtime

์„œ์šธ์‹œ๊ฐ„์œผ๋กœ ์„ค์ •

sudo ln -s /usr/share/zoneinfo/Asiz/Seoul /etc/localtime

์ž˜ ์ ์šฉ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ

date

๐Ÿ“Œ Hostname ๋ณ€๊ฒฝ

 

์‹ค๋ฌด์—์„œ๋Š” ์ˆ˜์‹ญ๋Œ€์˜ ์„œ๋ฒ„๊ฐ€ ์ž‘๋™๋˜๋Š”๋ฐ, IP๋งŒ์œผ๋กœ ์–ด๋–ค ์„œ๋ฒ„๊ฐ€ ์–ด๋–ค ์—ญํ• ์„ ํ•˜๋Š”์ง€ ์•Œ ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฅผ ๊ตฌ๋ถ„ํ•˜๊ธฐ ์œ„ํ•ด ํ˜ธ์ŠคํŠธ ๋„ค์ž„์„ ํ•„์ˆ˜๋กœ ๋“ฑ๋กํ•ด์•ผํ•œ๋‹ค๊ณ ํ•œ๋‹ค.


โœ” HOSTNAME์„ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•œ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ํ™œ์šฉํ•ด๋ณด์ž

 

https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/set-hostname.html

 

Amazon Linux ์ธ์Šคํ„ด์Šค์—์„œ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„ ๋ณ€๊ฒฝ - Amazon Elastic Compute Cloud

Amazon Linux ์ธ์Šคํ„ด์Šค์—์„œ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„ ๋ณ€๊ฒฝ ์ธ์Šคํ„ด์Šค๋ฅผ ์‹œ์ž‘ํ•˜๋ฉด ์ธ์Šคํ„ด์Šค์— ํ˜ธ์ŠคํŠธ ์ด๋ฆ„(๋‚ด๋ถ€ ํ”„๋ผ์ด๋น— IPv4 ์ฃผ์†Œ)์ด ์ง€์ •๋ฉ๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์ธ Amazon EC2 ํ”„๋ผ์ด๋น— DNS ์ด๋ฆ„์€ ip-12-34-56-78.us-west-2.compute.i

docs.aws.amazon.com

 

๐Ÿ“Œ1.  preserve_hostname์ด true์ธ์ง€ ํ™•์ธํ•˜๊ธฐ

sudo vi /etc/cloud/cloud.cfg

ํ•ด๋‹น ์„ค์ •์ด ๋‚˜์—ด๋˜์–ด์žˆ์ง€ ์•Š์œผ๋ฉด ์•„๋ž˜๋ฅผ ๋งจ ๋์— ์ถ”๊ฐ€ํ•ด์ค˜์•ผํ•œ๋‹ค.

preserve_hostname: true

ssh๋กœ ์ ‘์†ํ•˜์—ฌ ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜๊ธฐ ์œ„ํ•ด์„  vi ๋ช…๋ น์–ด๋ฅผ ์•Œ์•„์•ผํ•˜๋Š”๋ฐ,

์ˆ˜์ •ํ•˜๋ ค๋ฉด i ๋ˆ„๋ฅด๊ณ  ๋ทฐ ๋ชจ๋“œ๋กœ ๋„˜์–ด๊ฐ€๋ ค๋ฉด esc๋ฅผ ๋ˆ„๋ฅด๋ฉด๋œ๋‹ค.

:w       //์ €์žฅ
:q       //๊ทธ๋ƒฅ ์ข…๋ฃŒ
:wq       // ํŒŒ์ผ ์ €์žฅ ํ›„ ์ข…๋ฃŒ
:w test.txt // ์ƒˆ ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ ํŒŒ์ผ๋ช…์ด ์—†๋Š” ๊ฒฝ์šฐ test.txt๋กœ ์ €์žฅ
:q!       // ์ €์žฅํ•˜์ง€ ์•Š๊ณ  ์ข…๋ฃŒ. ๋ฌผ์–ด๋ณด์ง€ ์•Š๊ณ  ์ข…๋ฃŒ๋˜๋ฏ€๋กœ ์กฐ์‹ฌ.
dd       //ํ•œ ์ค„ ์ง€์šฐ๊ธฐ
p       //๋ถ™์—ฌ๋„ฃ๊ธฐ

๐Ÿ“Œ 2. hostnamectl ๋ช…๋ น์œผ๋กœ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„์„ ์„ค์ •

sudo hostnamectl set-hostname ์›ํ•˜๋Š” ํ˜ธ์ŠคํŠธ๋ช…

๐Ÿ“Œ 3. /stc/sysconfig/network ํŒŒ์ผ์„ ์—ด์–ด์„œ ์ •๊ทœํ™”๋œ ๋„๋ฉ”์ธ ์ด๋ฆ„์„ ๋ฐ˜์˜

sudo vim /etc/sysconfig/network

๐Ÿ“Œ 4. vi๋ช…๋ น์–ด ์‚ฌ์šฉํ•˜์—ฌ hostname ์ž…๋ ฅ

HOSTNAME= ์›ํ•˜๋Š” hostname

๐Ÿ“Œ 5. rebot ํ›„์— ํ™•์ธํ•ด๋ณด๋‹ˆ ์ •์ƒ์ ์œผ๋กœ hostname์ด ๋ณ€๊ฒฝ๋๋‹ค!!

sudo rebot


+) ํ˜ธ์ŠคํŠธ ์ฃผ์†Œ๋ฅผ ์ฐพ์„ ๋•Œ ๊ฐ€์žฅ ๋จผ์ € ๊ฒ€์ƒ‰ํ•ด๋ณด๋Š” /etc/hosts์— ๋ณ€๊ฒฝํ•œ hostname์„ ๋“ฑ๋กํ•ด์•ผํ•œ๋‹ค.

 

*hostname์ด /etc/hosts ์— ๋“ฑ๋ก๋˜์ง€ ์•Š์•„ ๋ฐœ์ƒํ•œ ์žฅ์• *

https://techblog.woowahan.com/2517/

 

๋นŒ๋ง ์‹œ์Šคํ…œ ์žฅ์• , ์ด๋Ÿฌ์ง€ ๋ง๋ž€ Maria~ | ์šฐ์•„ํ•œํ˜•์ œ๋“ค ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ

{{item.name}} ์šฐ์•„ํ•œ 6์‹œ ์•ˆ๋…•ํ•˜์„ธ์š”! ์šฐ์•„ํ•œํ˜•์ œ๋“ค์—์„œ ๋นŒ๋ง/์ •์‚ฐ ์‹œ์Šคํ…œ ๊ฐœ๋ฐœ์„ ๋งก๊ณ  ์žˆ๋Š” ์ด์ฃผํ˜„์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์ €๋Š” ์ง€๋‚œ 7์›” ์ž…์‚ฌํ•œ ์ด๋ž˜๋กœ ๋ฐฐ๋ฏผ์—์„œ ์ง„ํ–‰ํ•˜๋Š” ๋‹ค์–‘ํ•œ ์ด๋ฒคํŠธ์— ๋Œ€์‘ํ•˜๋ฉฐ ์งง์ง€

techblog.woowahan.com

1. /etc/hosts ํŒŒ์ผ์„ ์—ด์–ด๋ณด์ž

sudo vim /etc/hosts

์ถ”๊ฐ€!

์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ could not resolve host ~๊ฐ€ ์•ˆ๋‚˜์˜ค๋ฉด ๋œ๊ฑฐ๋‹ค.

curl ํ˜ธ์ŠคํŠธ ์ด๋ฆ„

 

728x90
Comments