Scouter 설치 / 사용
Scouter는 LG CNS 만들어 공개한 모니터링 오픈소스 APM입니다.
아래는 스카우터가 모니터링을 제공하는 실행 환경 흐름에 기반한 Scouter 구조도입니다.
Scouter는 크게 Agent, Collector, Client 로 구분이 됩니다.
* Server (Collector) : Agent가 전송한 데이터 수집 / 처리
* Host Agent : OS의 CPU, Memory, Disk 등의 성능 정보 전송
* Java Agent : 실시간 서비스 성능 정보와 Heap Memory, Thread등의 Java 성능정보
* Client (Viewer) : 수집 된 성능 정보를 확인하기 위한 Client 프로그램
즉 정리를 해보자면
Agent가 전송하는 정보를 Server(Collector)가 수집 및 저장을 하며, Client는 이 성능 정보를 Viewer해주는 역할입니다.
Scouter 시나리오
시나리오는 아래와 같이 진행합니다.
1. 물리적으로 나뉘어진 두개의 서버를 준비합니다.
1-1. 1번 서버 : hostname : testwas1 / ip : 192.168.219.136
1-2. 2번 서버 : hostname : testwas2 / ip : 192.168.219.186
2. 각 서버에 tomcat을 기본 설치 합니다. (tomcat9 버전을 사용했습니다)
3. testwas1, testwas2의 Scouter HostAgent를 실행시키고, testwas1에서만 Scouter Server를 실행시킵니다.
최종적으로 목표하고자 하는 오브젝트는 아래와 같습니다.
Scouter 설치
저는 Scouter 2.7.0 버전으로 이용을 했으며, 아래는 Scouter 다운 링크입니다.
* scouter 다운 링크 : https://github.com/scouter-project/scouter/releases/tag/v2.7.0
scouter-all-2.7.0.tar.gz 과 scouter.client.product-win32.win32.x86_64.zip 을 다운 받아 주시면 됩니다.
testwas1과 testwas2 서버에 각각 scouter-all-2.7.0.tar.gz 업로드 후 압축을 해제합니다. (전 /app/prod/scouter 경로로 잡았습니다)
testwas1 먼저 설정합니다.
Collector Server 설정
Collector 서버는 에이전트 데아터의 전송을 처리합니다.
# pwd
/app/prod/scouter/server/conf
# vi scouter.conf
해당 파일은 비어있으며, 굳이 작성을 하실 필요가 없습니다.
server 디렉토리의 startup.sh로 Collector 서버를 실행하면 됩니다.
# pwd
/app/prod/scouter/server
# ./startup.sh
Host Agent 설정
먼저 agent.host 먼저 설정해줍니다.
/app/prod/scouter/agent.host/conf 로 이동해줍니다.
# vi scouter.conf ##아래의 빨간색으로 표시 된 부분만 이용해주면 됩니다.
# 수정 전
### scouter host configruation sample
#net_collector_ip=127.0.0.1 ### collecotr ip가 기본으로 localhost로 설정이 되어있습니다.
#net_collector_udp_port=6100
#net_collector_tcp_port=6100
#cpu_warning_pct=80
#cpu_fatal_pct=85
#cpu_check_period_ms=60000
#cpu_fatal_history=3
#cpu_alert_interval_ms=300000
#disk_warning_pct=88
#disk_fatal_pct=92
# 수정 후
### scouter host configruation sample
net_collector_ip=192.168.219.136
net_collector_udp_port=6100
net_collector_tcp_port=6100
#cpu_warning_pct=80
#cpu_fatal_pct=85
#cpu_check_period_ms=60000
#cpu_fatal_history=3
#cpu_alert_interval_ms=300000
#disk_warning_pct=88
#disk_fatal_pct=92
Java Agent 설정
먼저, scouter와 연동 할 Tomcat의 catalina.sh 또는 setenv.sh에 아래의 옵션을 추가합니다.
#Scouter
JAVA_OPTS="${JAVA_OPTS} -Dscouter.config=/app/prod/scouter/agent.java/conf/scouter.conf"
JAVA_OPTS="${JAVA_OPTS} -javaagent:/app/prod/scouter/agent.java/scouter.agent.jar"
JAVA_OPTS=" ${JAVA_OPTS} -Dobj_name=testwas1"
다음으로 agent.java의 conf 파일을 수정해줍니다.
pwd
/app/prod/scouter/agent.java/conf
# vi scouter.conf (한 서버 내 다수의 tomcat instance를 기동시 해당 conf를 복사하여 사용하면 됩니다)
# 수정 전
### scouter java agent configuration sample
#obj_name=WAS-01
#net_collector_ip=127.0.0.1
#net_collector_udp_port=6100
#net_collector_tcp_port=6100
#hook_method_patterns=sample.mybiz.*Biz.*,sample.service.*Service.*
#trace_http_client_ip_header_key=X-Forwarded-For
#profile_spring_controller_method_parameter_enabled=false
#hook_exception_class_patterns=my.exception.TypedException
#profile_fullstack_hooked_exception_enabled=true
#hook_exception_handler_method_patterns=my.AbstractAPIController.fallbackHandler,my.ApiExceptionLoggingFilter.handleNotFoundErrorResponse
#hook_exception_hanlder_exclude_class_patterns=exception.BizException
# 수정 후
### scouter java agent configuration sample
obj_name=testwas1
net_collector_ip=192.168.219.136
net_collector_udp_port=6100
net_collector_tcp_port=6100
#hook_method_patterns=sample.mybiz.*Biz.*,sample.service.*Service.*
#trace_http_client_ip_header_key=X-Forwarded-For
#profile_spring_controller_method_parameter_enabled=false
#hook_exception_class_patterns=my.exception.TypedException
#profile_fullstack_hooked_exception_enabled=true
#hook_exception_handler_method_patterns=my.AbstractAPIController.fallbackHandler,my.ApiExceptionLoggingFilter.handleNotFoundErrorResponse
#hook_exception_hanlder_exclude_class_patterns=exception.BizException
이제 Host Agent와 Java Agnet를 기동하여 모니터링을 수행합니다.
# pwd
/app/prod/scouter/agent.host
# ./host.sh
testwas2를 설정합니다.
Collector Server 설정
Collector 서버는 testwas1에서 기동하였으므로, testwas2에선 별도로 실행시키지 않습니다.
Host Agent 설정
먼저 agent.host 먼저 설정해줍니다.
/app/prod/scouter/agent.host/conf 로 이동해줍니다.
# vi scouter.conf ##아래의 빨간색으로 표시 된 부분만 이용해주면 됩니다.
# 수정 전
### scouter host configruation sample
#net_collector_ip=127.0.0.1 ### collecotr ip가 기본으로 localhost로 설정이 되어있습니다.
#net_collector_udp_port=6100
#net_collector_tcp_port=6100
#cpu_warning_pct=80
#cpu_fatal_pct=85
#cpu_check_period_ms=60000
#cpu_fatal_history=3
#cpu_alert_interval_ms=300000
#disk_warning_pct=88
#disk_fatal_pct=92
# 수정 후
### scouter host configruation sample
net_collector_ip=192.168.219.136
net_collector_udp_port=6100
net_collector_tcp_port=6100
#cpu_warning_pct=80
#cpu_fatal_pct=85
#cpu_check_period_ms=60000
#cpu_fatal_history=3
#cpu_alert_interval_ms=300000
#disk_warning_pct=88
#disk_fatal_pct=92
Java Agent 설정
먼저, scouter와 연동 할 Tomcat의 catalina.sh 또는 setenv.sh에 아래의 옵션을 추가합니다.
#Scouter
JAVA_OPTS="${JAVA_OPTS} -Dscouter.config=/app/prod/scouter/agent.java/conf/scouter.conf"
JAVA_OPTS="${JAVA_OPTS} -javaagent:/app/prod/scouter/agent.java/scouter.agent.jar"
JAVA_OPTS=" ${JAVA_OPTS} -Dobj_name=testwas1"
다음으로 agent.java의 conf 파일을 수정해줍니다.
pwd
/app/prod/scouter/agent.java/conf
# vi scouter.conf (한 서버 내 다수의 tomcat instance를 기동시 해당 conf를 복사하여 사용하면 됩니다)
# 수정 전
### scouter java agent configuration sample
#obj_name=WAS-01
#net_collector_ip=127.0.0.1
#net_collector_udp_port=6100
#net_collector_tcp_port=6100
#hook_method_patterns=sample.mybiz.*Biz.*,sample.service.*Service.*
#trace_http_client_ip_header_key=X-Forwarded-For
#profile_spring_controller_method_parameter_enabled=false
#hook_exception_class_patterns=my.exception.TypedException
#profile_fullstack_hooked_exception_enabled=true
#hook_exception_handler_method_patterns=my.AbstractAPIController.fallbackHandler,my.ApiExceptionLoggingFilter.handleNotFoundErrorResponse
#hook_exception_hanlder_exclude_class_patterns=exception.BizException
# 수정 후
### scouter java agent configuration sample
obj_name=testwas2
net_collector_ip=192.168.219.136
net_collector_udp_port=6100
net_collector_tcp_port=6100
#hook_method_patterns=sample.mybiz.*Biz.*,sample.service.*Service.*
#trace_http_client_ip_header_key=X-Forwarded-For
#profile_spring_controller_method_parameter_enabled=false
#hook_exception_class_patterns=my.exception.TypedException
#profile_fullstack_hooked_exception_enabled=true
#hook_exception_handler_method_patterns=my.AbstractAPIController.fallbackHandler,my.ApiExceptionLoggingFilter.handleNotFoundErrorResponse
#hook_exception_hanlder_exclude_class_patterns=exception.BizException
이제 Host Agent와 Java Agnet를 기동하여 모니터링을 수행합니다.
# pwd
/app/prod/scouter/agent.host
# ./host.sh
Scouter Client를 실행
client는 window에서 압축 해제 후 아래 아이콘의 exe를 실행시켜주시면 됩니다.
Server Address에 Scouter Server를 실행시켜준 서버의 IP와 6100번 포트를 입력합니다.
Scouter는 기본적으로 TCP/UDP 6100 포트를 이용합니다. (방화벽 설정이 되어 있다면, 6100포트는 방화벽 설정을 해주셔야 합니다)
ID : admin (scouter default ID입니다)
Password : admin (scouter default Password 입니다)
아래와 같이 Scouter를 통해 testwas1, testwas2를 모니터링 할 수 있습니다.