第7週−3 NLBによる負荷バランス実験
NLBの作成
EC 2->ロードバランサ->
Load Balancer 생성
をクリック
[
생성
]をクリックします.
1. 기본 구성
- 이름(NLB-TEST), 인터넷 경계
- 리스너 : 프로토콜(UDP), 포트(161)
- 가용 영역 : ELB-VPC, 2a 와 2c 선택 - IP는 AWS에서 할당 or 사용자의 EIP 사용 가능


대상 그룹(새 대상 그룹), 이름(NLB-TG), 대상 유형(인스턴스), 프로토콜(UDP), 포트(161)
상태 검사(HTTP) → 고급 상태 검사 설정 : 간격(10), 나머지는 기본값 ⇒ UDP는 기본 단방향 통신으로 상태검사에 비적합



インスタンスを選択して->
Include as pending below
をクリックします
下の
Create target group
をクリックします
ターゲットグループの選択

[
Create load balancer
]をクリックします.
My-EC 2で確認
NLB= NLB DNS 주소
echo $NLB
# NLB는 아래 도메인 쿼리 응답 IP가 고정
dig $NLB +short
while true; do dig $NLB +short && echo "------------------------------" && date; sleep 5; done
# NLB IP를 변수에 지정 << 아래 NLB1 NLB2 IP 정보는 각자 멤버들 'dig $NLB' 출력된 IP 2개 정보를 각각 입력
NLB1=3.38.32.124
NLB2=13.124.129.65
curl 접속 테스트
# NLB 는 5 Tuple Hash 결과로 분산하며 default 설정이 Cross Zone Load Balancing(교차 영역 로드 밸런싱)이 비활성화 상태
for i in {1..20}; do snmpget -v2c -c public $NLB 1.3.6.1.2.1.1.5.0 ; done | sort | uniq -c | sort -nr
for i in {1..20}; do snmpget -v2c -c public $NLB1 1.3.6.1.2.1.1.5.0 ; done | sort | uniq -c | sort -nr
for i in {1..20}; do snmpget -v2c -c public $NLB2 1.3.6.1.2.1.1.5.0 ; done | sort | uniq -c | sort -nr








ELB-EC 2-1/2確認
# 패킷덤프 시 클라이언트IP가 NLB를 경유해서 인입하였지만 변경 안됨 - 클라이언트IP보존
# EC2 보안그룹에 NLB로 서비스하는 포트의 대상을 대부분 0.0.0.0/0 지정하게됨 - 클라이언트IP로 인입되기 때문
tcpdump udp port 161 -nn
エラー修正完了!出てくるのはいいですねハハ、どうしてもバイトの文字しか出てこなかったら、My-EC 2でもう一度for文の最初のコードを回しましょう.


NLB Cross Zone Loadバランスの有効化
EC 2->ロードバランサ->タスクのクリック->プロパティの編集をクリック

交差領域のロード・バランシングの有効化(Enable Crossing Area Load Balance)をクリックします.

My-EC 2で確認
# curl 접속 테스트
for i in {1..20}; do snmpget -v2c -c public $NLB1 1.3.6.1.2.1.1.5.0 ; done | sort | uniq -c | sort -nr
for i in {1..20}; do snmpget -v2c -c public $NLB2 1.3.6.1.2.1.1.5.0 ; done | sort | uniq -c | sort -nr
エラー修正完了!最近ミスを修正して、成功した时が一番幸せです.

リソースの削除(重要!)
ロードバランサの削除(EC 2→ロードバランサ→ロードバランサ→操作→削除)
ターゲットグループの削除(EC 2→ロードバランシング→ターゲットグループ→操作→削除)
クラウドフォーマットスタックの削除
参考資料:AFOS[2期]活動内容
Reference
この問題について(第7週−3 NLBによる負荷バランス実験), 我々は、より多くの情報をここで見つけました https://velog.io/@icebear2n2/7주차-3-NLB를-통한-로드-밸런싱-실습テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol