15G. ElastiCache Redis ํด๋ฌ์คํฐ Security Group ์์ฑ ๋ฐ ์ค์ ํ๊ธฐ
15G. ElastiCache Redis ํด๋ฌ์คํฐ Security Group ์์ฑ ๋ฐ ์ค์ ํ๊ธฐ ๊ด๋ จ

ElastiCache Redis ํด๋ฌ์คํฐ์ ์บ์ ๋ ธ๋๊ฐ ์์ ํ ์์ฑ๋์๋๋ผ๋ ์๋ํฌ์ธํธ ์ฃผ์๋ก ์ ์์ด ๋์ง ์์ต๋๋ค. Redis ํด๋ฌ์คํฐ๋ฅผ ์์ฑํ ๋ Security Group์ ๊ธฐ๋ณธ๊ฐ์ธ default (VPC)๋ก ์ค์ ํ์ต๋๋ค. ์ด default (VPC)๋ ๋ชจ๋ ํธ๋ํฝ์ ๋ํด Inbound๊ฐ ์ด๋ ค์์ง๋ง์ ์ ๊ฐ๋ฅํ IP ๋์ญSource์ default ์๊ธฐ ์์ ์ผ๋ก ์ค์ ๋์ด ์์ต๋๋ค. ์ฆ ๊ฐ์ default (VPC) Security Group ์ค์ ์์์๋ง ์ ์์ด ํ์ฉ๋๋ฏ๋ก ์ธ๋ถ์์๋ ์ ์ํ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ Redis ํด๋ฌ์คํฐ ์ ์ฉ Security Group์ ์์ฑํ๊ณ ํฌํธ(6379)๋ฅผ ์ด์ด์ค์ผ ํฉ๋๋ค.
RDS์ ElastiCache๋ ํฐ ์ฐจ์ด์ ์ด ์์ต๋๋ค. RDS์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์์ง์ AWS ์ธ๋ถ(์ธํฐ๋ท)์์ ์ ์์ด ํ์ฉ๋์ด ์์ง๋ง ElastiCache์ ์บ์ ์์ง์ AWS ์ธ๋ถ์์ ์ ์ํ ์ ์์ต๋๋ค. Security Group์ ์์ฑํ์ฌ ๋ชจ๋ IP ๋์ญ์ ๋ํด ์ ์์ ํ์ฉํ๋๋ผ๋ ๋์ผํ VPC์ ์ํ EC2 ์ธ์คํด์ค์์๋ง ์ ์ํ ์ ์์ต๋๋ค.
์์ธํ ๋ด์ฉ์ ๋งํฌ๋ฅผ ์ฐธ์กฐํ๊ธฐ ๋ฐ๋๋๋ค.
ElastiCache Redis ํด๋ฌ์คํฐ์ฉ Security Group์ ์์ฑํด๋ณด๊ฒ ์ต๋๋ค.

[EC2]
๋ฅผ ํด๋ฆญํฉ๋๋ค.
[NETWORK & SECURITY]
โ [Security Groups]
๋ฅผ ํด๋ฆญํ ๋ค ์์ชฝ์ [Create Security Group]
๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.ElastiCache Redis ํด๋ฌ์คํฐ์ฉ Security Group์ ์์ฑํฉ๋๋ค.
- Security group name: Security Group์ ์ด๋ฆ์ ๋๋ค. Memcached Cluster๋ฅผ ์ ๋ ฅํฉ๋๋ค.
- Description: Security Group ์ค๋ช ์ ๋๋ค. Memcached Cluster๋ฅผ ์ ๋ ฅํฉ๋๋ค.
- VPC: Security Group์ด ์ ์ฉ๋ VPC์ ๋๋ค. ๊ธฐ๋ณธ๊ฐ ๊ทธ๋๋ก ์ฌ์ฉํฉ๋๋ค.
์ธ๋ถ์์ ๋ค์ด์ค๋ ํธ๋ํฝ์ธ Inbound ํญ์ ์ ํํฉ๋๋ค(Inbound๊ฐ ๊ธฐ๋ณธ์ผ๋ก ์ ํ๋์ด ์์ ๊ฒ์
๋๋ค). ์๋์ชฝ [Add Rule]
๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.
- Type: ํธ๋ํฝ ์ข ๋ฅ์ ๋๋ค. Memcached๋ ๋ฏธ๋ฆฌ ์ ์๋ ๊ฒ์ด ์์ผ๋ฏ๋ก Custom TCP Rule์ ์ ํํฉ๋๋ค.
- Protocol: ํํ ๋ก์ฝ์ ๋๋ค. Custom TCP Rule ์ ํํ๋ฉด ์๋์ผ๋ก TCP๊ฐ ์ค์ ๋ฉ๋๋ค.
- Port Range: ํฌํธ ๋ฒํธ์ ๋๋ค. ์ฐ๋ฆฌ๋ Memcached ํฌํธ๋ฅผ ์ด์ด์ผ ํ๋ฏ๋ก 11211์ ์ ๋ ฅํฉ๋๋ค.
- Source: ์ ์ ๊ฐ๋ฅํ IP ๋๋ IP ๋์ญ์ ๋๋ค. Anywhere๋ฅผ ์ ํํฉ๋๋ค(์ค๋ฌด์์๋ My IP๋ฅผ ์ ํํ์ฌ ์์ ์ IP๋ง ์ ์ํ ์ ์๋๋ก ์ค์ ํ๊ฑฐ๋, Custom IP๋ฅผ ์ ํํ์ฌ ํน์ IP ๋์ญ์ ์ค์ ํ๋๋ก ํฉ๋๋ค).

[Create]
๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.์ด์ ๋ค์ ElastiCache ์บ์ ํด๋ฌ์คํฐ ๋ชฉ๋ก([Amazon ElastiCache]
โ [Cache Clusters]
)์ผ๋ก ์ด๋ํฉ๋๋ค.

examplememcached
)์ ์๋ [Modify]
๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.ElastiCache Redis ํด๋ฌ์คํฐ์ ์ค์ ์ ๋ณ๊ฒฝํฉ๋๋ค.

[Yes, Modify]
๋ฅผ ํด๋ฆญํฉ๋๋ค.
exampleredis
)์ ์ค์ ์ด ๋ณ๊ฒฝ ์ค์
๋๋ค. 10์ด ์ ๋ ๊ธฐ๋ค๋ฆฌ๋ฉด ์ค์ ์ด ์์ ํ ์ ์ฉ๋ฉ๋๋ค. 1 node ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ์บ์ ๋
ธ๋ ๋ชฉ๋ก์ผ๋ก ์ด๋ํฉ๋๋ค.
.Redis๋ ํ ๋ทtelnet์ผ๋ก ์ ์ํ ์ ์์ต๋๋ค. ์์์ ์์ฑํ EC2 ์ธ์คํด์ค(Example Server)์์ ํ ๋ท์ ์ด์ฉํ์ฌ Redis ์บ์ ๋ ธ๋๋ก ์ ์ํด๋ณด๊ฒ ์ต๋๋ค(์์ง EC2 ์ธ์คํด์ค๋ฅผ ์์ฑํ์ง ์์๋ค๋ฉด '4.3 EC2 ์ธ์คํด์ค ์์ฑํ๊ธฐ'๋ฅผ ์ฐธ์กฐํ์ฌ EC2 ์ธ์คํด์ค๋ฅผ ์์ฑํ๊ธฐ ๋ฐ๋๋๋ค).
.telnet <์๋ํฌ์ธํธ ์ฃผ์> 6379
์์ผ๋ก ๋ช
๋ น์ ์
๋ ฅํ๋ฉด Redis ์บ์ ๋
ธ๋๋ก ์ ์ํ ์ ์์ต๋๋ค. ์ ์ํ ํ info๋ฅผ ์
๋ ฅํ๋ฉด ํ์ฌ ์บ์ ๋
ธ๋์ ์ ๋ณด๊ฐ ํ์๋ฉ๋๋ค.
.exampleredis.o5nouc.0001.apne1.cache.amazonaws.com
๋ ์ ๊ฐ ์์ฑํ ์บ์ ๋
ธ๋ ์๋ํฌ์ธํธ ์ฃผ์ ์
๋๋ค. ์ฌ๋ฌ๋ถ๋ค์ด ์์ฑํ ์บ์ ๋
ธ๋์ ์๋ํฌ์ธํธ ์ฃผ์๋ฅผ ์
๋ ฅํ๊ธฐ ๋ฐ๋๋๋ค.
telnet exampleredis.o5nouc.0001.apne1.cache.amazonaws.com 6379
#
# Escape character is '^]'.
# info
# $1747
# # Server
# redis_version:2.8.6
# redis_git_sha1:00000000
# redis_git_dirty:0
# redis_build_id:37f1586c49770bbe
# redis_mode:standalone
# os:Amazon ElastiCache
# arch_bits:64
# multiplexing_api:epoll
# gcc_version:0.0.0
# process_id:1
# run_id:6e1a8b8dacf399db74b53526ed722c9820e8e20b
# tcp_port:6379
# ์๋ต...
์ ์์ด ๋์ง ์๋๋ค๋ฉด Security Group์ ํฌํธ ๋ฒํธ๋ฅผ ์ ์์ ์ผ๋ก ์ ๋ ฅํ์๋์ง, Memcached ํด๋ฌ์คํฐ ์ค์ ์์ ๋ฐฉ๊ธ ์์ฑํ Security Group์ ์ ํํ์๋์ง, ํ ๋ท ์ ์์์ ์๋ํฌ์ธํธ ์ฃผ์์ ํฌํธ ๋ฒํธ๋ฅผ ์ ํํ๊ฒ ์ ๋ ฅํ์๋์ง, EC2 ์ธ์คํด์ค๊ฐ ๊ฐ์ VPC์ ์ํด ์๋์ง ํ์ธํฉ๋๋ค.
์์์ ์ค๋ช ํ ๊ฒ์ฒ๋ผ ElastiCache์ ์บ์ ๋ ธ๋๋ AWS ์ธ๋ถ์์ ์ ์ํ ์ ์์ต๋๋ค.
redis-cli
.Redis๋ redis-cli๋ผ๋ ์ ์ฉ ํด๋ผ์ด์ธํธ๋ฅผ ์ ๊ณตํ๊ณ ์์ต๋๋ค. ๋ค์ด๋ก๋ ๋ฐ ์ค์น๋ฐฉ๋ฒ์ ๋งํฌ๋ฅผ ์ฐธ์กฐํ๊ธฐ ๋ฐ๋๋๋ค.
