๐Ÿ™‚0531 [AWS]

๋ง์ง€ยท2022๋…„ 5์›” 31์ผ
1
post-custom-banner

๐Ÿ“Œ AWS - ROUTE 53

53 ; dns ํฌํŠธ๋ฒˆํ˜ธ
default ๋ณด์•ˆ๊ทธ๋ฃน 2๊ฐœ ์ œ์™ธ ๋ชจ๋‘ ์‚ญ์ œํ•˜๊ณ  ์ง„ํ–‰
ํ˜ธ์ŠคํŒ… ์˜์—ญ ํ•˜๋‚˜๋‹น ํ•œ๋‹ฌ์— 0.5๋‹ฌ๋Ÿฌ . 12์‹œ๊ฐ„ ์•ˆ์— ์‚ญ์ œํ•˜๋ฉด ๋น„์šฉ X.

๐Ÿ“™ ๋„๋ฉ”์ธ ์„ค์ •

โœ”๏ธ 0. route53 - ํ˜ธ์ŠคํŒ… ์˜์—ญ ์ƒ์„ฑ
โœ”๏ธ 1. ๋„๋ฉ”์ธ ์ด๋ฆ„์— ๋„๋ฉ”์ธ ์‚ฝ์ž… - ์šฐ์ธก ๋งจ ํ•˜๋‹จ ํ˜ธ์Šฝ์ด ์˜์—ญ ์ƒ์„ฑ ํด๋ฆญ

โœ”๏ธ 2. NS์œ ํ˜• ๊ฐ’/ํŠธ๋ž˜ํ”ฝ ๋ผ์šฐํŒ… ๋Œ€์ƒ ํ™•์ธ

โœ”๏ธ 2-1. ๋„๋ฉ”์ธ ๋งŒ๋“ค์–ด๋‘” ๊ฐ€๋น„์•„ ์ ‘์†, ๋„๋ฉ”์ธ ์ƒ์„ธ ํŽ˜์ด์ง€ - ๋„ค์ž„์„œ๋ฒ„ ์„ค์ •์—์„œ 1์ฐจ~4์ฐจ ํ˜ธ์ŠคํŠธ๋ช… ์ง€์šฐ๊ณ  AWS๋„ค์ž„์„œ๋ฒ„ ์ •๋ณด ๋์— ์  ์‚ญ์ œ ํ›„ ์‚ฝ์ž…

โœ”๏ธ 2-2. ์†Œ์œ ์ž ์ธ์ฆ ํ›„ ์ ์šฉ

๐Ÿ“™ ์„œ๋ธŒ๋„ท IP์ž๋™ํ• ๋‹น ์„ค์ •

vpc- ์„œ๋ธŒ๋„ท - 'MY-PUBLIC-SUBNET-'ํ•˜๋‚˜์”ฉ ์„ ํƒ - ์ž‘์—… -์„œ๋ธŒ๋„ท ์„ค์ • ํŽธ์ง‘ - ์ž๋™ ํ• ๋‹น IP ์„ค์ • ์ฒดํฌ - ์ €์žฅ

๐Ÿ“™ ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ(WEBSERVER)

โœ”๏ธ๋ช…์‹œ ์•ˆ ๋œ ๋ถ€๋ถ„์€ default
โœ”๏ธ ์ด๋ฆ„ : WEBSERVER
โœ”๏ธ ํ‚คํŽ˜์–ด : aws-key

โœ”๏ธ ๋„คํŠธ์›Œํฌ ์„ค์ •

  • VPC : MY-VPC
  • ์„œ๋ธŒ๋„ท : MY-PUBLIC-SUBNET-2A
  • ํผ๋ธ”๋ฆญ IP์ž๋™ํ• ๋‹น : ํ™œ์„ฑํ™”
  • ๋ฐฉํ™”๋ฒฝ ๋ณด์•ˆ๊ทธ๋ฃน ์„ค์ • (๋ณด์•ˆ๊ทธ๋ฃน ์ƒ์„ฑ)
    • ์ด๋ฆ„ : SG-WEB
    • ๊ทœ์น™์ถ”๊ฐ€ - ssh, ๋ชจ๋“ ICMP-IPv4, HTTP - ์†Œ์Šค์œ ํ˜• : ์œ„์น˜ ๋ฌด๊ด€

โœ”๏ธ ๊ณ ๊ธ‰ ์„ธ๋ถ€ ์ •๋ณด

#!/bin/bash
yum install -y httpd
systemctl enable --now httpd

โœ”๏ธ ์ธ์Šคํ„ด์Šค ์‹œ์ž‘ ํด๋ฆญ

๐Ÿ“™ ๋ ˆ์ฝ”๋“œ ์ƒ์„ฑ

โœ”๏ธ 0. Route 53 - ํ˜ธ์ŠคํŒ… ์˜์—ญ - ๋„๋ฉ”์ธ์ฃผ์†Œ ํด๋ฆญ - ๋ ˆ์ฝ”๋“œ ์ƒ์„ฑ
โœ”๏ธ 1. ๋ ˆ์ฝ”๋“œ ์ด๋ฆ„ : blog - ๊ฐ’์— WEBSERVER ํผ๋ธ”๋ฆญ IP ์‚ฝ์ž…

๐Ÿ“™ ์„œ๋ธŒ๋„ท ์ƒ์„ฑ

โœ”๏ธ 0. VPC - ์„œ๋ธŒ๋„ท - ์„œ๋ธŒ๋„ท ์ƒ์„ฑ
โœ”๏ธ 1. VPC : MY-VPC
โœ”๏ธ 1-1. ์ด๋ฆ„ : MY-PRIVATE-SUBNET-2(A,B,C,D)
โœ”๏ธ 1-2. ๊ฐ€์šฉ์˜์—ญ : 2(A,B,C,D)
โœ”๏ธ 1-3. ip CIDR ๋ธ”๋ก : 64.0/20, 80.0/20, 96.0/20, 112.0/20

โœ”๏ธ์ด 4๊ฐœ์˜ ํ”„๋ผ์ด๋น— ์„œ๋ธŒ๋„ท ์ƒ์„ฑ.

๐Ÿ“™ ๋ผ์šฐํŒ…ํ…Œ์ด๋ธ” ์ƒ์„ฑ

โœ”๏ธ 0. VPC - ๋ผ์šฐํŒ… ํ…Œ์ด๋ธ” - ๋ผ์šฐํŒ…ํ…Œ์ด๋ธ” ์ƒ์„ฑ
โœ”๏ธ 1. ์ด๋ฆ„ : MY-PRIVATE-SUBNET-RTB
โœ”๏ธ 1-1. VPC : MY-VPC - ๋ผ์šฐํŒ… ํ…Œ์ด๋ธ” ์ƒ์„ฑ ํด๋ฆญ
โœ”๏ธ 2. ์„œ๋ธŒ๋„ท ์—ฐ๊ฒฐ - ๋ช…์‹œ์  ์„œ๋ธŒ๋„ท ์—ฐ๊ฒฐ - ์„œ๋ธŒ๋„ท ์—ฐ๊ฒฐ ํŽธ์ง‘ - PRIVATE ์„œ๋ธŒ๋„ท๋“ค (4๊ฐœ) ์ฒดํฌ - ์—ฐ๊ฒฐ ์ €์žฅ ํด๋ฆญ

๐Ÿ“™ ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ(DBSERVER)

โœ”๏ธ๋ช…์‹œ ์•ˆ ๋œ ๋ถ€๋ถ„์€ default
โœ”๏ธ ์ด๋ฆ„ : DBSERVER
โœ”๏ธ ์ด๋ฏธ์ง€ : Canonical, Ubuntu, 18.04 LTS, amd64 bionic image build on 2022-04-11
โœ”๏ธ ํ‚คํŽ˜์–ด : aws-key

โœ”๏ธ ๋„คํŠธ์›Œํฌ ์„ค์ •

  • VPC : MY-VPC
  • ์„œ๋ธŒ๋„ท : MY-PRIVATE-SUBNET-2C
  • ํผ๋ธ”๋ฆญ IP์ž๋™ํ• ๋‹น : ํ™œ์„ฑํ™”
  • ๋ฐฉํ™”๋ฒฝ ๋ณด์•ˆ๊ทธ๋ฃน ์„ค์ • (๋ณด์•ˆ๊ทธ๋ฃน ์ƒ์„ฑ)
    • ์ด๋ฆ„ : SG-DB
    • ๊ทœ์น™์ถ”๊ฐ€ - ssh, ๋ชจ๋“ ICMP-IPv4, MYSQL/Aurora - ์†Œ์Šค์œ ํ˜• : ์œ„์น˜ ๋ฌด๊ด€

โœ”๏ธ ์ธ์Šคํ„ด์Šค ์‹œ์ž‘ ํด๋ฆญ

๐Ÿ“ข ์ฃผ์˜์‚ฌํ•ญ : public IP๋กœ ping ์•ˆ๋‚˜๊ฐ€์•ผ ์ •์ƒ! ํ‰์ƒ์‹œ์—๋Š” DB์„œ๋ฒ„์— public IP ์ค„ ํ•„์š”๋„ ์—†์Šต๋‹ˆ๋‹น. ํ•˜์ง€๋งŒ, WEB์„œ๋ฒ„ CLIํ™˜๊ฒฝ์—์„œ DB์„œ๋ฒ„ PRIVATE IP๋กœ ping ์ณค์„ ๋• ๋‚˜๊ฐ€์•ผ ํ•ฉ๋‹ˆ๋‹น.

๐Ÿ“™ WEB์„œ๋ฒ„ ๊ฒฝ์œ ํ•˜์—ฌ DB์„œ๋ฒ„ CLI ์ ‘์†

  1. mobaxterm SSH๋ธŒ๋ผ์šฐ์ € ํ†ตํ•ด์„œ aws-key.pem WEBSERVER home๊ฒฝ๋กœ์— ํ‚ค ๋„ฃ๊ธฐ.(ํŒŒ์ผ ๋“œ๋ž˜๊ทธ)

  2. key ๊ถŒํ•œ ๋ฐ”๊ฟ”์ฃผ๊ณ , ubuntu(DB์„œ๋ฒ„)๋กœ ์ ‘์†

[ec2-user@ip-10-14-11-201 ~]$ sudo chmod 400 aws-key.pem

[ec2-user@ip-10-14-11-201 ~]$ ssh -i aws-key.pem ubuntu@10.14.97.126

The authenticity of host '10.14.97.126 (10.14.97.126)' can't be established.
ECDSA key fingerprint is SHA256:jLKIKqzUzWcwHriO4zLC64s4jXYi2QBCHG+jwio3q/8.
ECDSA key fingerprint is MD5:fd:59:26:be:d7:a9:7a:79:4e:1c:f2:94:0f:a8:09:a7.
Are you sure you want to continue connecting (yes/no)? yes




๐Ÿš€ DB์„œ๋ฒ„ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ

๐Ÿ“™NAT ๊ฒŒ์ดํŠธ์›จ์ด ์ƒ์„ฑ

โœ”๏ธ 0. vpc - nat๊ฒŒ์ดํŠธ์›Œ์ด -๊ฒŒ์ดํŠธ์›จ์ด ์ƒ์„ฑ ํด๋ฆญ
โœ”๏ธ 1. ์ด๋ฆ„ : MY-NGW
โœ”๏ธ 2. ์„œ๋ธŒ๋„ท : MY-PUBLIC-SUBNET-2A
โœ”๏ธ 3. ํƒ„๋ ฅ์  IPํ• ๋‹น ํด๋ฆญ
โœ”๏ธ 4. NAT๊ฒŒ์ดํŠธ์›จ์ด ์ƒ์„ฑ๋ฒ„ํŠผ ํด๋ฆญ

โœ๏ธํƒ„๋ ฅ์  IP๋Š” 1๊ฐœ์— ํ•œํ•˜์—ฌ ์‚ฌ์šฉ์•ˆํ•˜๊ณ  ๋ณด๊ด€ํ•˜๋ฉด ๊ณผ๊ธˆ๋˜์ง€๋งŒ, ๋ฐ”๋กœ ์—ฐ๊ฒฐํ•ด์„œ ์‚ฌ์šฉํ•˜๋ฉด ๊ณผ๊ธˆ๋˜์ง€ ์•Š์Œ.

๐Ÿ“™ ๋ผ์šฐํŒ… ํ…Œ์ด๋ธ” ์„ค์ •

  1. vpc - ๋ผ์šฐํŒ…ํ…Œ์ด๋ธ” - MY-PRIVATE-SUBNET-RTB ์„ ํƒ - ํ•˜๋‹จ ๋ชฉ๋ก ๋ผ์šฐํŒ… - ๋ผ์šฐํŒ… ํŽธ์ง‘
  2. ๋ผ์šฐํŒ… ์ถ”๊ฐ€ - ๋Œ€์ƒ : 0.0.0.0/0 - ๋Œ€์ƒ : NAT ๊ฒŒ์ดํŠธ์›จ์ด : MY-NGW - ๋ณ€๊ฒฝ์‚ฌํ•ญ ์ €์žฅ

๐Ÿ“™ DB์„œ๋ฒ„์— ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค(MariaDB)์„ค์น˜

$ sudo apt-get update -y
$ sudo apt-get install -y mariadb-server unzip nfs-common
$ sudo mysql_secure_installation
์—”ํ„ฐ, y, ๋น„๋ฐ€๋ฒˆํ˜ธ, ๋‹ค y

$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf

#bind-address            = 127.0.0.1

$ sudo systemctl restart mysql
$ sudo mysql -u root -p
CREATE USER 'wpuser'@'%' IDENTIFIED BY 'wppass';
CREATE DATABASE IF NOT EXISTS wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'%';
quit

๐Ÿ“™WEB์„œ๋ฒ„์— wordpress ์„ค์น˜

# wget https://ko.wordpress.org/wordpress-4.8.2-ko_KR.zip
# sudo yum install -y httpd php php-mysql php-gd php-mbstring wget unzip
# cd /var/www/html
# sudo unzip /home/ec2-user/wordpress-4.8.2-ko_KR.zip
# sudo mv ./wordpress/* .
# sudo chown -R apache:apache /var/www/*
# sudo systemctl restart httpd

โœ”๏ธ ๋„๋ฉ”์ธ์œผ๋กœ ๋ธŒ๋ผ์šฐ์ € ์›น์„œ๋ฒ„ ์ ‘์†, ์‚ฌ์ดํŠธ์—์„œ ์„ค์น˜ ์ง„ํ–‰
โœ”๏ธ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šคํ˜ธ์ŠคํŠธ์— DB์„œ๋ฒ„ ๋‚ด๋ถ€ IP๊ธฐ์ž….

โœ”๏ธ NAT๊ฒŒ์ดํŠธ์›จ์ด ์‚ญ์ œ, ํƒ„๋ ฅ์  IP ๋ฆด๋ฆฌ์Šค
๋ผ์šฐํŒ… ํ…Œ์ด๋ธ” - MY-PRIVATE-SUBNET-RTB - ๋ผ์šฐํŒ… - ๋ผ์šฐํŒ…ํŽธ์ง‘ - ๋Œ€์ƒ 0.0.0.0/0 NATGATEWAT ์‚ญ์ œ - ์ธํ„ฐ๋„ท ๊ฒŒ์ดํŠธ์›จ์ด - ๋ณ€๊ฒฝ์‚ฌํ•ญ ์ €์žฅ ์‹œ DB์„œ๋ฒ„ ping ๋‚˜๊ฐ.
(DB์„œ๋ฒ„ ๋งŒ๋“ค ๋•Œ ํผ๋ธ”๋ฆญ IP ์ž๋™ํ• ๋‹น ๋ฐ›์•˜๊ธฐ ๋•Œ๋ฌธ์—)

โœ”๏ธ ์ตœ์ข…์ ์œผ๋กœ๋Š”, ๋ผ์šฐํŒ…ํ…Œ์ด๋ธ”์—์„œ 0.0.0.0/0 ๋ผ์šฐํŒ… ์‚ญ์ œ.

๐Ÿ“Œ DB์„œ๋ฒ„ ๋ณด์•ˆ๊ทธ๋ฃน

SG-WEB์—์„œ ์ถœ๋ฐœํ•˜๋Š” ํŠธ๋ž˜ํ”ฝ๋“ค๋งŒ DB์„œ๋ฒ„์— ์ ‘๊ทผ ๊ฐ€๋Šฅ.

โœ”๏ธec2 -๋ณด์•ˆ๊ทธ๋ฃน -sg-db - ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ - ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ ํŽธ์ง‘ - ์›๋ž˜ ์žˆ๋˜ MYSQL ๊ทœ์น™ ์‚ญ์ œ - ๊ทœ์น™ ์ถ”๊ฐ€ -์œ ํ˜• : MYSQL/Aurora - ์†Œ์Šค์œ ํ˜• : ์‚ฌ์šฉ์ž ์ง€์ • - ์†Œ์Šค : SG-WEB -๊ทœ์น™ ์ €์žฅ


โœ๏ธsecurity group ๋‹ค ์˜คํ”ˆํ•ด๋„ acl์—์„œ ๋ง‰ํ˜€์žˆ์œผ๋ฉด ์ฐจ๋‹จ๋จ.
โœ๏ธACL ์€ ์„œ๋ธŒ๋„ท ์ „์ฒด๋ฅผ ์ปจํŠธ๋กค ๊ฐ€๋Šฅ.
โœ๏ธ๋ณด์•ˆ๊ธฐ๋Šฅ์— ์ฐจ๋‹จ ๊ธฐ๋Šฅ ์—†์œผ๋‹ˆ (ํ—ˆ์šฉ ๊ธฐ๋Šฅ๋งŒ ์žˆ์Œ.)
ACL ์ฐจ๋‹จ๊ธฐ๋Šฅ ์ด์šฉํ•˜์ž. (ํŠน์ • IP์ฐจ๋‹จ ๊ฐ€๋Šฅ)

๐Ÿ“Œ AWS - ๋„คํŠธ์›Œํฌ ACL

โœ”๏ธ vpc- ๋ณด์•ˆ - ๋„คํŠธ์›Œํฌ ACL
โœ”๏ธ 8๊ฐœ ์„œ๋ธŒ๋„ท ๊ฐ–๊ณ ์žˆ๋Š” ACL์— ์ด๋ฆ„ MY-NACL, 4๊ฐœ(default)์— ์ด๋ฆ„ DEF-NACL.
โœ”๏ธ MY-NACL - ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ - ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ ํŽธ์ง‘(all-allow์ƒํƒœ)

โœ”๏ธ์ƒˆ ๊ทœ์น™ ์ถ”๊ฐ€ - ๊ทœ์น™๋ฒˆํ˜ธ : 100๋ณด๋‹ค ์ž‘์€์ˆ˜ - ์œ ํ˜• : HTTP - ์†Œ์Šค : ์ฐจ๋‹จํ•  IP - ํ—ˆ์šฉ/๊ฑฐ๋ถ€ : ๊ฑฐ๋ถ€

โœ”๏ธ ๋ฐฉ๊ธˆ ์ƒ์„ฑํ•œ ๊ทœ์น™ ์‚ญ์ œํ•˜๊ณ  ๋งˆ๋ฌด๋ฆฌ.

๐Ÿ“ข ์ฃผ์˜์‚ฌํ•ญ : 100๋ฒˆ ๊ทœ์น™๋ฒˆํ˜ธ ์ ˆ๋Œ€ ์‚ญ์ œํ•˜๋ฉด ์•ˆ๋จ!! ๊ฑฐ๋ถ€ ๊ทœ์น™์„ ์‚ญ์ œํ•  ์ˆ˜ ์—†์–ด์„œ ๋ชจ๋‘ ์‚ญ์ œ๋จ.
๐Ÿ“ข ์ฃผ์˜์‚ฌํ•ญ : ์‹ค์Šต ํ›„ ๋ง‰์•„๋‘์—ˆ๋˜๊ฑฐ ์‚ญ์ œ

๐Ÿ“Œ AWS - ๋ฐ์ดํŠธ๋ฒ ์ด์Šค ์„œ๋น„์Šค(RDS)

์™„์ „๊ด€๋ฆฌํ˜• ์„œ๋น„์Šค ์ž๋™ ๋ฐฑ์—…, ์ž๋™ ๊ณ ๊ฐ€์šฉ์„ฑ, ์ž๋™ ์กฐ์ •

โœ”๏ธwordpress๊ฒŒ์‹œ๊ธ€์— ๋Œ“๊ธ€ ์ž‘์„ฑ

๐Ÿ“™ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜

โœ”๏ธDB์„œ๋ฒ„ MariaDB ๋ฒ„์ „ ํ™•์ธ

ubuntu@ip-10-14-97-126:~$ mariadb --version

mariadb  Ver 15.1 Distrib 10.1.48-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

โœ”๏ธ RDS - ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ƒ์„ฑ - ํ‘œ์ค€์ƒ์„ฑ - MariaDB - ๋ฒ„์ „ : 10.2.39 (DB์„œ๋ฒ„์— ์„ค์น˜ํ•œ MariaDB๋ฒ„์ „๊ณผ ๊ฐ€์žฅ ์œ ์‚ฌํ•œ ๋ฒ„์ „ ์„ ํƒ)

โœ”๏ธ ํ”„๋ฆฌํ‹ฐ์–ด - ์‹๋ณ„์ž ๊ทธ๋Œ€๋กœ, ๋งˆ์Šคํ„ฐ ์‚ฌ์šฉ์ž ์ด๋ฆ„ ๊ทธ๋Œ€๋กœ(๋ฐ”๊ฟ”๋„ ๋จ) - ์•”ํ˜ธ ์ž…๋ ฅ

โœ”๏ธ ์ธ์Šคํ„ด์Šค ๊ตฌ์„ฑ - db.t2.micro

โœ”๏ธ ์Šคํ† ๋ฆฌ์ง€ - ๊ทธ๋Œ€๋กœ

โœ”๏ธ ๊ฐ€์šฉ์„ฑ ๋ฐ ๋‚ด๊ตฌ์„ฑ -๊ทธ๋Œ€๋กœ

โœ”๏ธ ์—ฐ๊ฒฐ -IPv4 - VPC : MY-VPC -

โœ”๏ธ ์„œ๋ธŒ๋„ท ๊ทธ๋ฃน ์ƒ์„ฑ - ํผ๋ธ”๋ฆญ ์•ก์„ธ์Šค : ์•„๋‹ˆ์š” (์™ธ๋ถ€์—์„œ ์ง์ ‘ ์ง„์ž… ๋ถˆ๊ฐ€ bastion host ๊ฑฐ์ณ์„œ ๊ฐ€์•ผํ•จ.) - ๋ณด์•ˆ๊ทธ๋ฃน : SG-DB (default ์‚ญ์ œ) ๊ฐ€์šฉ์˜์—ญ : 2b

โœ”๏ธ ์ถ”๊ฐ€ ๊ตฌ์„ฑ ๊ทธ๋Œ€๋กœ - ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ƒ์„ฑ

๐Ÿ“™ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ง„์ž…

โœ”๏ธ ๋ชฉ๋ก์—์„œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ด๋ฆ„ ํด๋ฆญ - ์—”๋“œํฌ์ธํŠธ ์ฃผ์†Œ ํ™•์ธ

โœ”๏ธ ๋ณด์•ˆ๊ทธ๋ฃธ - SG-DB -์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ ํŽธ์ง‘ -MYSQL ์‚ญ์ œ์œ„์น˜๋ฌด๊ด€ (Anywhere-IPv4)๋กœ ๋‹ค์‹œ ์ถ”๊ฐ€

โœ”๏ธ ์—”๋“œํฌ์ธํŠธ ์ฃผ์†Œ ํ™•์ธํ•˜์—ฌ ๋ช…๋ น์–ด ์ž…๋ ฅํ•ด์„œ DB์„œ๋ฒ„์—์„œ MYSQL ์ง„์ž…

ubuntu@ip-10-14-97-126:~$ mysql -h database-1.crfklihww3gw.ap-northeast-2.rds.amazonaws.com -u admin -p


Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 10.2.39-MariaDB-log Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
CREATE USER 'wpuser'@'%' IDENTIFIED BY 'wppass';
CREATE DATABASE IF NOT EXISTS wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'%';
ubuntu@ip-10-14-97-126:~$ sudo mysqldump -uwpuser -pwppass wordpress > wordpress.sql

ubuntu@ip-10-14-97-126:~$ sudo mysql -h database-1.crfklihww3gw.ap-northeast-2.rds.amazonaws.com -uwpuser -pwppass wordpress < wordpress.sql
mysqldump -u[์‚ฌ์šฉ์ž์•„์ด๋””] -p[ํŒจ์Šค์›Œ๋“œ] ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ช… ํ…Œ์ด๋ธ”๋ช… > ๊ฒฝ๋กœ ๋ฐ ์ €์žฅ๋  ํŒŒ์ผ๋ช….sql //๋ฐฑ์—…
sudo mysqldump -uwpuser -pwppass wordpress > wordpress.sql

mysql -h [์—”๋“œํฌ์ธํŠธ ์ฃผ์†Œ] -u[์‚ฌ์šฉ์ž์•„์ด๋””] -p[ํŒจ์Šค์›Œ๋“œ] ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ช… < ๊ฒฝ๋กœ ๋ฐ ๋คํ”„ ํŒŒ์ผ๋ช….sql //์•„๊นŒ ๋ฐฑ์—…ํ•œ ํŒŒ์ผ ๋‹ค์‹œ ๋„ฃ๊ธฐ
sudo mysql -h database-1.crfklihww3gw.ap-northeast-2.rds.amazonaws.com -uwpuser -pwppass wordpress < wordpress.sql

โœ”๏ธ ์›น์„œ๋ฒ„ ์›Œ๋“œํ”„๋ ˆ์Šค ๋Š๊ธฐ

[ec2-user@ip-10-14-11-201 ~]$ cd /var/www/html
[ec2-user@ip-10-14-11-201 html]$ ls
index.php        wp-blog-header.php    wp-includes        wp-signup.php
license.txt      wp-comments-post.php  wp-links-opml.php  wp-trackback.php
readme.html      wp-config.php         wp-load.php        xmlrpc.php
wordpress        wp-config-sample.php  wp-login.php
wp-activate.php  wp-content            wp-mail.php
wp-admin         wp-cron.php           wp-settings.php
[ec2-user@ip-10-14-11-201 html]$ sudo mv wp-config.php wp-config.php.bak
[ec2-user@ip-10-14-11-201 html]$ ls
index.php        wp-blog-header.php    wp-includes        wp-signup.php
license.txt      wp-comments-post.php  wp-links-opml.php  wp-trackback.php
readme.html      wp-config.php.bak     wp-load.php        xmlrpc.php
wordpress        wp-config-sample.php  wp-login.php
wp-activate.php  wp-content            wp-mail.php
wp-admin         wp-cron.php           wp-settings.php
[ec2-user@ip-10-14-11-201 html]$

โœ”๏ธ RDS์— ์ด๊ด€ํ•ด๋‘์—ˆ๋˜ ๊ฑธ๋กœ ๋‹ค์‹œ ์—ฐ๊ฒฐํ•˜๊ธฐ

โœ”๏ธ ๋‹ค์‹œ ์›น๋ธŒ๋ผ์šฐ์ €์—์„œ ๋„๋ฉ”์ธ ์ž…๋ ฅํ•ด์„œ ์›น์‚ฌ์ดํŠธ ์ ‘์†.
โœ”๏ธ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ˜ธ์ŠคํŠธ ์—”๋“œํฌ์ธํŠธ ์ฃผ์†Œ๋กœ ์„ค์น˜ํ•˜๊ธฐ.

โœ”๏ธ ๋ฐ์ดํ„ฐ ํ™•์ธ

๐Ÿ“™โœ”๏ธโœ๏ธ๐Ÿ“ขโญ๏ธ๐Ÿ“Œ

๐Ÿ“Œ ๊ธฐํƒ€

โญ๏ธ Multi AZ, Cross region

โœ”๏ธ Multi AZ : ๋‹ค๋ฅธ ๊ฐ€์šฉ์˜์—ญ์— ์„œ๋ฒ„ ๋‘๊ณ  ๋กœ๋“œ๋ฐธ๋Ÿฐ์Šค

โœ”๏ธ Cross region : ๋‹ค๋ฅธ๋ฆฌ์ „์— ์„œ๋ฒ„ ๋‘๊ณ  ๋กœ๋“œ ๋ฐธ๋Ÿฐ์Šค (route53์ด์šฉ )GSLB

โญ๏ธ ์›น์„œ๋ฒ„์™€ ํƒ„๋ ฅ์  IP

โœ”๏ธ ์ž๋™์œผ๋กœ ํ• ๋‹น๋ฐ›์€ ํผ๋ธ”๋ฆญ IP๋Š” ์ธ์Šคํ„ด์Šค๋ฅผ ์ค‘์ง€ํ–ˆ๋‹ค๊ฐ€ ๋‹ค์‹œ ์‹œ์ž‘ํ•˜๋ฉด ์ƒˆ๋กœ ํ• ๋‹น๋จ (IP๊ฐ€ ๋ฐ”๋€œ.) -> DNS ์—ฐ๊ฒฐ๋ฌธ์ œ ์ƒ๊น€.
โœ”๏ธ ๋•Œ๋ฌธ์— ์›น์„œ๋ฒ„ ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ํƒ„๋ ฅ์  IP๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ•จ.

โญ๏ธ ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ์‚ญ์ œ ์‹œ ์ตœ์ข… ์Šค๋ƒ…์ƒท ์ƒ์„ฑ ์—ฌ๋ถ€๋ฅผ ์ฒดํฌํ•ด์•ผ ๊ณผ๊ธˆ ์•ˆ ๋จ.

๋งŒ์•ฝ ๋ชจ๋ฅด๊ณ  ์Šค๋ƒ…์ƒท ์ƒ์„ฑํ–ˆ๋”๋ผ๋„ RDS ์Šค๋ƒ…์ƒท ํƒญ- ์ˆ˜๋™์—์„œ ์Šค๋ƒ…์ƒท ์ง€์›Œ์ฃผ๋ฉด ๋จ (์‹œ์Šคํ…œ, ํผ๋ธ”๋ฆญ ๋“ฑ์€ ์‹ ๊ฒฝ X)

profile
๊พธ์ค€ํžˆ, ์ฐจ๊ทผ์ฐจ๊ทผ
post-custom-banner

1๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2022๋…„ 6์›” 1์ผ

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ํ•ญ์ƒ ์ž˜๋ณด๊ณ ์žˆ์Šต๋‹ˆ๋‹ค!

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ