1. EC2 Instasnce Storage Section
1-1 .What's an EBS Volume?
- An EBS (Elastic Block Store) Volume is a network drive you can attach to your instances while they run
- It allows your instances to persist data, even after their termination
- - EBS ๋ณผ๋ฅจ์ ์ฌ์ฉํ๋ฉด ์ธ์คํด์ค๊ฐ ์ข ๋ฃ๋ ํ์๋ ๋ฐ์ดํฐ๋ฅผ ์ง์ํ ์ ์๋ค. ์ธ์คํด์ค๋ฅผ ์ฌ์์ฑํ๊ณ ์ด์ EBS๋ณผ๋ฅจ์ ๋ง์ดํธํ๋ฉด ๋ฐ์ดํฐ๋ฅผ ๋ค์ ๋ฐ์ ์ ์๋ค.
- They can only be mounted to one instance at a time (at the CCP level)
- - But some can be multi-mounted(at the Associate level)
- They are bound to a specific availability zone
- Analogy: Think of them as a "network USB stick"
- Free tier: 30GB of free EBS storage of type General Purpose (SSD) or Magnetic per month - gp2 or gp3 volume
1-2. EBS Volume Features
โถ It's a network drive (i.e. not a physical drive)
- It uses the network to communicate the instance, which means there might be a bit of latency(์ง์ฐ)
- It can be detached from an EC2 instance and attached to another one quickly
โถ It's locked to an Availability Zone (AZ) โญ
- An EBS Volume is us-east-1A cannot be attached to us-east-1B
- To move a volume across, you first need to snapshot it
โถ Have a provisioned capacity (size in GBs, and IOPS)
- You get billed for all the provisioned capacity
- You can increase the capacity of the drive over time
1-3. EBS Volume - Example
๊ฐ์ AZ (US-EAST-1A) ๋ด์ ์์ ๋
- ํ๋์ Instance์ 2๊ฐ์ EBS Volumes ์ฐ๊ฒฐ ํ๋ ๊ฒ ๊ฐ๋ฅ โ
- ๋ ๊ฐ์ Instance์ 1๊ฐ์ EBS Volume ์ฐ๊ฒฐ ํ๋ ๊ฒ ๋ถ๊ฐ๋ฅ โ
๋ณ๋์ AZ (US-EAST-1B) ์์ EBS Volume ์ ์ฐ๊ฒฐํ๋ ค๋ฉด?
- ๋ณ๋์ EBS Volume ์์ฑํด์ผ ํจ
- EBS Volume์ ์์ฑํ ํ ์ฐ๊ฒฐํ์ง ์๊ณ ๊ทธ๋๋ก ๋๋ ๊ฒ๋ ๊ฐ๋ฅ โ
โญ 1-4. EBS - Deleted on Termination attribute (์ข ๋ฃ์ ์ญ์ ๊ธฐ๋ฅ) - ์ํ์ ๋์ด
โถ Controls the EBS behaviour when an EC2 instance terminates
- By default, the root EBS volume is deleted (attribute enabled)
- By default, any other attached EBS volume is not deleted (attributed disabled)
โถ This can be controlled by the AWS console / AWS CLI
โถ Use case: preserve root volume when instance is terminated
- ๋ฃจํธ EBS๋ณผ๋ฅจ์ ์ธ์คํด์ค ์ข ๋ฃ์ ํจ๊ป EBS Volume์ด ์ญ์ ๋๋๋ก ์ด๊ธฐ ์ค์ ์ด ๋์ด ์๋ค.
- EBS Root Volume ๋ฐ ๋ค๋ฅธ ๋ชจ๋ ์ ํ์ Volume์ ์ฌ์ฌ์ฉํ๊ณ ์ ํ๋ฉด(Ex. Host OS ์ฅ์ ...) Instance๋ฅผ Launchํ ๋, ํด๋น Delete on Termination ์์ฑ์ ์ฒดํฌํด์ (False)ํด์ผ ํ๋ค.
- ๋ง์ฝ, ์ด๋ฏธ ์คํ์ค์ธ Instance(Live Service Instance)์ ๋ถ์ฐฉ๋ EBS Volume์ Delete on Termination ์์ฑ์์์ ํ๊ณ ์ ํ๋ฉด AWS CLI๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค.
2. EBS Volume ์ค์ต
2-1. Instance์ ์ฐ๊ฒฐ๋ EBS Volume ํ์ธํ๊ธฐ
AWS ์ฝ์ ๋ก๊ทธ์ธ → EC2 ๋์๋ณด๋๋ก ์ด๋ → Instance → Instance ์ด๋ฆ ํด๋ฆญ- Storage ํญ → Block devices
→ EBS Volume ID ํด๋ฆญ ๐
2-2. Instance ์ ์ฐ๊ฒฐํ ๋ ๋ฒ์งธ EBS ๋ณผ๋ฅจ ์์ฑํ๊ธฐ
๐ AWS ์ฝ์ ๋ก๊ทธ์ธ → EC2 ๋์๋ณด๋๋ก ์ด๋ → Volumes → Create volume → Type, Size(GiB), AZ์ค์
→ ์์ฑ ๋ฒํผ
โญ์ด๋ AZ(Availability Zone)์ ๋ฐ๋์ ์ฐ๊ฒฐํ ์ธ์คํด์ค์ ์ง์ ํ AZ๋ ๋์ผํ ์์น๋ก ์ง์ ํด์ผ ํ๋ค.
๋ง์ฝ ๋ค๋ฅธ AZ์ EBS Volume์ ์์ฑํ๊ฒ ๋๋ฉด ์์ฑ ํ, Attach Volume ์ ์๋ ํ ๋ Instance ๋ชฉ๋ก์ ์ธ์คํด์ค ์์ด๋๊ฐ ๋จ์ง ์๋๋ค.
โถ Instance์ AZ(๊ฐ์ฉ ์์ญ) ํ์ธํ๋ ๋ฒ
๐ AWS ์ฝ์ ๋ก๊ทธ์ธ → EC2 ๋์๋ณด๋๋ก ์ด๋ → Instance → Instance ์ด๋ฆ ํด๋ฆญ → Networking ํญ → Scroll down
→ Availability Zone ์์ ํ์ธ ๊ฐ๋ฅ
2-3. Instance์ ๋ ๋ฒ์งธ EBS ๋ณผ๋ฅจ ์ฐ๊ฒฐํ๊ธฐ
๐ AWS ์ฝ์ ๋ก๊ทธ์ธ → EC2 ๋์๋ณด๋๋ก ์ด๋ → Volumes → Volume ID ํด๋ฆญ → Actions → Attach volume
→ ์ฐ๊ฒฐํ Instance ์ ํ ํ๊ณ ์ด๋ฆ ์ง์ (/deb/sdf ๋ฑ )→ ์ฐ๊ฒฐ ๋ฒํผ
2-4. ๋ณผ๋ฅจ์ด 2๊ฐ ์ฐ๊ฒฐ๋ Instance๋ฅผ ์ข ๋ฃํ๋ฉด ์ผ์ด๋๋ ์ผ
My Second Instance์ ์ฐ๊ฒฐ๋ 2๊ฐ์ EBS ๋ณผ๋ฅจ ์ค 8GiB ๋ ์ธ์คํด์ค๋ฅผ ์์ฑํ๋ฉด์ ๊ธฐ๋ณธ์ ์ผ๋ก ์์ฑ๋ Root ๋ณผ๋ฅจ์ด๋ค. ๊ทธ๋ฆฌ๊ณ 2GiB๋ ์๋์ผ๋ก ์์ฑํด์ ์ฐ๊ฒฐํ ๊ฒ์ด๋ค. ์ด ๋ ๋ง์ฝ์ ์ธ์คํด์ค๋ฅผ ์ข ๋ฃํ๋ฉด ์ด๋ป๊ฒ ๋ ๊น?
์์์ ์ ๋ฆฌํ ๊ฒ์ฒ๋ผ 8GiB ์ง๋ฆฌ ๊ธฐ๋ณธ ๋ณผ๋ฅจ์๋ '์ข ๋ฃ ์ ์ญ์ (Delete on Termination)'๋ผ๋ ์์ฑ์ด ๋ํดํธ๋ก ๋ค์ด์๋ค. ์ด๊ฑธ ์ด๋์ ํ์ธํ๋ค? Instance์ Storage ํญ์์ Block devices ์์ญ์ผ๋ก ๊ฐ์ ์คํฌ๋กค์ ์ค๋ฅธ์ชฝ ๋๊น์ง ๋ฐ์ด์ ํ์ธ ๊ฐ๋ฅํ๋ค.
์ด์ ์ธ์คํด์ค๋ฅผ Terminate (delete) instance ๋ก ์ญ์ ํด ๋ณด์.
์ธ์คํด์ค๋ฅผ ์ข ๋ฃํ ํ ๋ค์ Volumes๋ก ๋์๊ฐ ์ดํด ๋ณด๋ฉด My Second Instance ์ ๋ฃจํธ ๋ณผ๋ฅจ์ธ vol-0c2e82ba2aa08bcae๋ ์ธ์คํด์ค์ ํจ๊ป ์ญ์ ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค. ๋ค๋ง, ์๋์ผ๋ก ์์ฑํ 2GiB์ง๋ฆฌ EBS ๋ณผ๋ฅจ์ ์ฐ๊ฒฐ๋ ์ธ์คํด์ค๋ฅผ ์ญ์ ํด๋ ๊ทธ๋๋ก ๋จ์ ์๋ ๊ฒ์ ํ์ธํ ์ ์๋ค. โผ
โ ๋ง์ฝ์ ์ธ์คํด์ค๋ฅผ ์์ฑํ ๋, ์ข ๋ฃ์ ๋ฃจํธ EBS ๋ณผ๋ฅจ์ด ์ ์ง๋๋ ๊ฒ์ ๋ํดํธ๋ก ์ค์ ํ๊ณ ์ถ๋ค๋ฉด ?
Launch Instance → Configure Storage → Advanced (๊ณ ๊ธ ์ต์ ) → Delete on termination ์ No ๋ก ๋ณ๊ฒฝํ๊ณ ์ธ์คํด์ค ์์ฑํ๊ธฐ
3. EBS Snapshots
3-1. What's EBS Snapshots?
- Make a backup (snapshot) of your EBS volume at a point in time
- Not necessary to detach volume to do snapshot, but recommended
- Can copy snapshots across AZ or Region
- EBS ์ค๋ ์ท์ EBS ๋ณผ๋ฅจ์ ํ AZ์์ ๋ค๋ฅธ AZ๋ก ์ ์กํ๋ ๊ธฐ๋ฅ์ด๋ค.
3-2. EBS Snapshots Features
โถ EBS Snapchot Archive (์ค๋ ์ท ์์นด์ด๋ธ)
- Move a Snapshot to an "archive tier" that is 75% cheaper
- Takes within 24 to 72 hours for restoring the archive
โถ Recycle Bin for EBS Snapshots (์ค๋ ์ท ํด์งํต)
- Setup rules to retain deleted snapshots so you can recover them after an accidental deletion
- Specify retention (from 1 day to 1 year)
- EBS ์ค๋ ์ท์ ์ญ์ ํ๋ ๊ฒฝ์ฐ ์๊ตฌ ์ญ์ ํ๋ ๋์ ์ ํด์งํต์ ๋ฃ์ ์ ์๋ค.
- ๊ทธ๋์ ์ค์๋ก ์ญ์ ํ๋ ๊ฒฝ์ฐ์ ํด์งํต์์ ๋ณต์๊ฐ๋ฅ ํ๋ค.
- ํด์งํต ๋ณด๊ด ๊ธฐ๊ฐ์ 1์ผ์์ 1๋ ๊น์ง๋ก ์ง์ ๊ฐ๋ฅ
โถ Fast Snapshot Restore (FSR, ๋น ๋ฅธ ์ค๋ ์ท ๋ณต์)
- Force full initialization of snapshot to have no latency on the first use ($$$)
- ์ค๋ ์ท์ ์์ ์ด๊ธฐํํด์ ์ฒซ ์ฌ์ฉ์์์ ์ง์ฐ์๊ฐ์ ์์ ๋ ๊ธฐ๋ฅ
- ์ค๋ ์ท์ด ์์ฃผ ํฌ๊ณ EBS ๋ณผ๋ฅจ ๋๋ EC2 ์ธ์คํด์ค๋ฅผ ๋น ๋ฅด๊ฒ ์ด๊ธฐํํ ๋ ํ์ํ๋ค
- ํ์ง๋ง ๋น์ฉ์ด ์ ๋ง ๋ง์ด ๋ ๋ค.
4. EBS Snapshots ์ค์ต
4-1. ์ค๋ ์ท ์์ฑํ๊ธฐ
EC2 ์ฝ์ → Volumes → ์ํ๋ ๋ณผ๋ฅจ ์ ํ → Actions → Create Snapshot → ์ค๋ ์ท ์ค์ ์๋ฃ ๐
4-2. ์ค๋ ์ท์ ๋ค๋ฅธ ๋ฆฌ์ ์ผ๋ก ๋ณต์ฌํ๊ธฐ
AWS์ ๋ค๋ฅธ ๋ฆฌ์ ์ ๋ฐ์ดํฐ๋ฅผ ๋ฐฑ์ ํ๊ณ ์ถ์ ๋ ์ฐ๋ ๋ฐฉ๋ฒ (์ฌํด ๋ณต๊ตฌ ์ ๋ต, Disaster Recovery (DR) Strategy)
EC2 ์ฝ์ → Snapshots → ์ํ๋ ์ค๋ ์ท ์ ํํ๊ณ ์ฐํด๋ฆญ → Copy snapshot → Destination Region ์ง์ ๐
4-3. ์ค๋ ์ท์ ๊ฐ์ ธ์์ ๋ณผ๋ฅจ์ ๋ค์ ์์ฑํ๊ธฐ
EC2 ์ฝ์ → Snapshots → ์ํ๋ ์ค๋ ์ท ์ ํ → Actions → Create volume from snapshot → Size (GiB) ์ ํ๊ฒ AZ๋ฅผ ์ง์ → Create Volume ๐
๋ณผ๋ฅจํญ๊ฐ์ ํ์ธํ๋ฉด Snapshot ID ๊ฐ์ด ์ ํ ์๋ค. ์ด๊ฑด ์ค๋ ์ท์ ํตํด ๋ณต์๋ ๋ณผ๋ฅจ์ด๋ค. (restored thru snapshot) ์ฆ, ์ค๋ ์ท ๋๋ถ์ EBS ๋ณผ๋ฅจ์ ๋ค๋ฅธ AZ(๊ฐ์ฉ ์์ญ)๋ก "๋ณต์ฌ"ํ ์ ์๋ค ๊ฒ์ด ์ ํํ ์ด๊ฒ์ ๋งํ๋ ๊ฒ์ด๋ค.
4-4. Recycle Bin (ํด์งํต)
ํด์งํต์ ์ค์๋ก ์ญ์ ๋์ง ์๋๋ก EBS ์ค๋ ์ท์ ๋ณดํธํ ์ ์๋ ๋ฐฉ๋ฒ์ด๋ค.
์ฆ Amazon AWS์ Machine Images(AMIs)๋ฅผ ์๊ธฐ์น ๋ชปํ ์ญ์ ์ฌ๊ณ ๋ก๋ถํฐ ๋ณดํธํ ์ ์๋ ๊ธฐ๋ฅ์ด๋ค.
EC2 ์ฝ์ → Snapshots → Recycle Bin → Create retention rule → Retention rule name ์ง์ → Resource type ๋ฐ
Resource period ์ง์ → ์์ฑ ๐
4-5. ์ค๋ ์ท ์์นด์ด๋ธ
์ญ์ ํ๊ธฐ ์ ์ Snapshot ์์ Storage tier๋ฅผ ์ดํด๋ณด๋ฉด ๊ธฐ๋ณธ์ธ Standard๋ก ๋์ด ์๋ค. ์ค๋ ์ท์ Archive(์์นด์ด๋ธ)ํ๋ฉด ์คํ ๋ฆฌ์ง ๊ณ์ธต ๋ค๋ฅธ ๊ฐ๊ฒฉ์์ค์ผ๋ก ์ด๋ํ ์ ์๋ค. ํ์ง๋ง ๋ณต์ํ๋ ค๋ฉด 24์๊ฐ ~ 72์๊ฐ์ ๊ธฐ๋ค๋ ค์ผ ํ๋ค.
EC2 ์ฝ์ → Snapshots → Actions → Archiving → Archive snapshot ๐
4-6. (์ค์๋ก) ์ค๋ ์ท ์ญ์ ํ๊ธฐ
์ด? ์ญ์ ํ ๋ delete๋ผ๋ ๊ธ์๋ฅผ ๋ฐ๋ผ์ ํ์ดํ ํด์ผ๋ง ์ญ์ ํ ์ ์๋๋ก ํ๋ ์ต์ ์ด ์ผ์ ธ ์๋ ๊ฑฐ ๊ฐ์์ ์ค์ ๋ก ์ค์ํ ์ผ์ ์์ ๊ฒ ๊ฐ๋ค. ์ค์ต์ ์ํด ๊ณผ๊ฐํ ์ญ์
4-7. ํด์งํต์์ ์ค๋ ์ท ๋ณต์ํ๊ธฐ
AWS Management Console → EC2 → Snapshots → Recycle Bin ํญ → Resources → ๋ณต์ํ ์ค๋ ์ท ์ ํ → Recover ๐