레이블이 node exporter인 게시물을 표시합니다. 모든 게시물 표시
레이블이 node exporter인 게시물을 표시합니다. 모든 게시물 표시

[PMM] #120 Coffee Break


Coffee Break

{PMM] 이라는 이름으로 11개의 포스팅을 통해서 PMM의 플랫폼을 설치했고, 최종 목적인 MySQL 서버 모니터링 환경(모니터링 정보 수집, 대시보드 구성 등)을 구성해 보았다. 주요 모듈(Prometheus, Grafana, node/mysqld exporter )에 대한 상세한 구조와 원리에 대한 설명보다는 실행(Action)에 중점을 두어 설명했으므로, 여기까지 잘 따라해 보았다면, 잠시 쉬어가자.

지난 포스팅을 쭈욱 살펴보는것도 괜찮다.

[PMM] #010 PMM Tutorial for MySQL Monitoring
[PMM] #020 PMM (Percona Monitoring and Management)
[PMM] #030 PMM Server - Client 서버 정보
[PMM] #040 PMM Server - Prometheus 설치
[PMM] #050 PMM Client - Node Exporter 설치
[PMM] #060 PMM Client - Mysqld Exporter 설치
[PMM] #070 PMM Server - Grafana 설치
[PMM] #080 PMM Server - Grafana/Prometheus 데이터소스 연동
[PMM] #090 PMM Server - Percona App for Grafana 설치
[PMM] #100 Percona Dashboard - 리눅스 모니터링
[PMM] #110 Percona Dashboard - MySQL 모니터링



그리고 본 포스팅시리즈를 읽고 있는 독자들이 갖고 있을지도 모르는 몇가지 의아한 점에 대해서 간단히 언급해본다.



010. PMM 관련 포스팅을 왜 시작했나요?
- 한글 매뉴얼이 없음.
- 인터넷 검색을 해봐도 한글로 포스팅한 자료를 찾을 수 없음. 없는 듯 함.


020. PMM을 설치할 때 왜 Docker 이미지가 아니라 각각의 모듈별로 따로 설치하나요?
- Docker가 익숙치 않은 독자들을 위함.
- PMM을 구성하는 모듈의 개별 버전 업데이트가 빠르게 announce되고 있다. 개별 모듈별로 설치하므로써, 아직 실험적인 모듈들은 나중에 안정화 버전이 나오면 설치하고 싶다.
- PMM의 기능 중에서 꼭 필요한 기능만 사용하고 싶기 때문에.
- 각각의 모듈을 설치해보고 연동하는 과정은 생각보다 간단하기에 독자가 이해하고 실습하기에 더 적절할 것이라고 생각함.


030. PMM 아키텍쳐에는 Query Analytics, Ochestrator, Proxy Exporter 등의 모듈들이 있던데, 이 모듈들의 설명이나 설치에 관련한 내용은 왜 없나요?
- Query Analytics : 추후, 포스팅 하고 싶음. 아직까지는 시간적인 여유가 없기에.
- Ochestrator : 아직 실험적인 툴. 나중에 안정화 버전이 나오면 PMM과는 별도로 테스트해 보고 공유하고 싶음.
- Proxy Exporter : ProxySQL 관련 포스팅은 별도로 진행 예정.


040. Percona Dashborad TokuDB Metrics 대시보드는 언급하지 않고 건너뛴 이유가 있나요?
MySQL 서버를 사용하는 시스템에서 TokuDB 엔진에 비하여 InnoDB 엔진을 사용하는 것이 아직은 일반적이라고 생각하고 있다. 물론 Toku 엔진을 상용서비스( Production환경)에서 사용하고 있는 시스템이 없지는 않을 것이라 예상한다. “보편적으로 더 많이 사용하는 것들에 대한 모니터링하는 것을 먼저 언급하는 것뿐이다. Toku엔진, Galera Cluster, MyISAM 엔진 등에 대한 모니터링 지표도 기회가 되면 꼭 포스팅 하고 싶다


050. 리눅스 모니터링, MySQL 모니터링 지표 설명이 너무 간단한 것 같다. 실제로 MySQL 모니터링 지표를 성능 관점의 튜닝 등을 위하여 자세히 설명하거나 다양한 케이스를 예를 들어 설명해줄 수 없나요?
가장 공유하고 싶은 내용이다. 하지만 이 내용은 매우 자세하고 다양한 케이스를 언급해야 하는데 내용도 많고, 튜닝 케이스 재연이 필요하므로 포스팅에 오랜 시간이 필요하다. 이 내용도 나중에 기회가 된다면


060. 다음 PMM관련 포스팅 내용에는 어떤 것들이 있을지 미리 알려주세요.
다음 포스팅 내용을 미리 공유하자면 간단히 다음과 같다.

MySQL 실시간 모니터링
MySQL
모니터링 지표 중 실시간으로 조회하는 것이 의미있는 그래프로 구성하는 대시보드 만들기..
- [PMM] #130 MySQL
모니터링 - Realtime#1
- [PMM] #140 MySQL
모니터링
- Realtime#2

MySQL
일별 모니터링
MySQL
모니터링 지표 중 일별로 조회하는 것이 의미있는 그래프로 구성하는 대시보드 만들기
- [PMM] #150 MySQL
모니터링 - Daily#1
- [PMM] #160 MySQL
모니터링
- Daily#2


MySQL 모니터링 알림
Prometheus
Alert Manager를 설치하여 MySQL 모니터링 지표 중 특정 지표의 상태 변경시 알림(이메일 등) 기능 연동
- [PMM] #170 MySQL
모니터링 - 알림-Prometheus Alertmanager 설치
- [PMM] #180 MySQL
모니터링 - 알림
-Replication Stop

MySQL
데이터 모니터링
MySQL 성능 지표가 아닌 MySQL 서버의 특정 테이블들에 대한 SQL 질의 결과를 Prometheus에 저장하고 이를 대시보드로 구성.
- [PMM] #190 MySQL
모니터링 - 데이터모니터링#1-mysqlexporter 설치
- [PMM] #200 MySQL
모니터링 - 데이터모니터링#2-대시보드구성













[PMM] #050 PMM Client - Node Exporter 설치

PMM Client - Node Exporter 설치

Node Exporter
Node Exporter는 리눅스 시스템의 시스템 메트릭(disk I/O 통계, CPU 부하, 메모리 사용량, 네트워크 통계 등)들을 Prometheus용 포멧으로 추출에서 웹 서비스로 제공하는 에이전트이다.
- 공식 홈페이지(github) : https://github.com/prometheus/node_exporter

Node Exporter 설치
- 다운로드 메인 : https://prometheus.io/download/
- 설치버전 - v0.13.0-rc.1 / 2016-10-16 Release
- 웹 서비스 포트 : 9100 (기본값)

010. Node Exporter 바이너리 압축 해제
Node Exporter 바이너리(node_exporter-0.13.0-rc.1.linux-amd64.tar.gz) 파일을 다운로드 받아 /home/mysql/DBA/programs/PMM105/client/ 디렉토리에 복사 한 후, 해당 파일을 압축 해제 한다.

1
2
3
4
5
6
[mysql@pmmclient ~]$ cd /home/mysql/DBA/programs/PMM105/client/
[mysql@pmmclient client]$ tar xvzf node_exporter-0.13.0-rc.1.linux-amd64.tar.gz
node_exporter-0.13.0-rc.1.linux-amd64/
node_exporter-0.13.0-rc.1.linux-amd64/LICENSE
node_exporter-0.13.0-rc.1.linux-amd64/NOTICE
node_exporter-0.13.0-rc.1.linux-amd64/node_exporter
cs


020. Node Exporter 설치 디렉토리 생성
- 설치 디렉토리 : /data/pmm_client/node_exporter/
- 심볼릭 링크 생성 : /home/mysql/ node_exporter à /data/pmm_client/node_exporter/node_exporter-0.13.0-rc.1.linux-amd64
Node Exporter 설치 디렉토리를 생성하고 압축 해제한 Node Exporter 바이너리를 설치 디렉토리에 옮긴다(move). 그 후, 설치 디렉토리에 대한 심볼릭 링크를 생성하여 편의상 디렉토리 경로를 단순하게 한다.

1
2
3
4
5
6
7
[mysql@pmmclient client]$ mkdir /data/pmm_client
[mysql@pmmclient client]$ mkdir /data/pmm_client/node_exporter
[mysql@pmmclient client]$ mv node_exporter-0.13.0-rc.1.linux-amd64 /data/pmm_client/node_exporter/
[mysql@pmmclient client]$ cd /home/mysql/
[mysql@pmmclient ~]$ ln -/data/pmm_client/node_exporter/node_exporter-0.13.0-rc.1.linux-amd64 ./node_exporter 
[mysql@pmmclient ~]$ ls -al | grep node_exporter
lrwxrwxrwx   1 mysql mysql    68 2016-10-19 11:49 node_exporter -> /data/pmm_client/node_exporter/node_exporter-0.13.0-rc.1.linux-amd64
cs

030. Node Exporter 기동
Node Exporter 바이너리를 압축만 해제하면 설치는 완료된다. 이제 Node Exporter를 기동하고 정상적으로 기동되었는지 로그와 프로세스 정상여부를 확인해본다.
Node Exporter 기동 시, 설정한 옵션은 다음과 같다.
-collectors.enabled : 수집을 원하는 지표에 대한 콜렉터를 지정한다.
또한 백그라운드 실행 시, Node Exporter의 정상작동 여부를 확인하기 위하여 /home/mysql/node_exporter/node_exporter.log 와 같이 로그를 남기도록 실행한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[mysql@pmmclient ~]$ cd /home/mysql/node_exporter/
[mysql@pmmclient node_exporter]$ nohup ./node_exporter -collectors.enabled="diskstats,filesystem,loadavg,meminfo,netdev,stat,time,uname,vmstat" -log.level=info > /home/mysql/node_exporter/node_exporter.log 2>&1 &
[153809
[mysql@pmmclient node_exporter]$ ps -ef | grep node_exporter
mysql    53809 25822  0 11:51 pts/0    00:00:00 ./node_exporter -collectors.enabled=diskstats,filesystem,loadavg,meminfo,netdev,stat,time,uname,vmstat -log.level=info
mysql    53830 25822  0 11:51 pts/0    00:00:00 grep node_exporter
[mysql@pmmclient node_exporter]$ cat /home/mysql/node_exporter/node_exporter.log
nohup: ignoring input
time="2016-10-19T11:51:17+09:00" level=info msg="Starting node_exporter (version=0.13.0-rc.1, branch=master, revision=2ff8e5f0e4553371161b98293d52ed98ecb8117b)" source="node_exporter.go:135"
time="2016-10-19T11:51:17+09:00" level=info msg="Build context (go=go1.7.1, user=root@197f6ac1b691, date=20161016-12:36:43)" source="node_exporter.go:136"
time="2016-10-19T11:51:17+09:00" level=info msg="Enabled collectors:" source="node_exporter.go:155"
time="2016-10-19T11:51:17+09:00" level=info msg=" - filesystem" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg=" - loadavg" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg=" - netdev" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg=" - stat" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg=" - time" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg=" - uname" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg=" - diskstats" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg=" - meminfo" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg=" - vmstat" source="node_exporter.go:157"
time="2016-10-19T11:51:17+09:00" level=info msg="Listening on :9100" source="node_exporter.go:176"
cs

Node Exporter기동 시, 명시적으로 지정한 콜렉터들이 수집하는 지표는 다음과 같다.

Name
Description
OS
diskstats
Exposes disk I/O statistics from /proc/diskstats.
Linux
filesystem
Exposes filesystem statistics, such as disk space used.
FreeBSD, Dragonfly, Linux, OpenBSD
loadavg
Exposes load average.
Darwin, Dragonfly, FreeBSD, Linux, NetBSD, OpenBSD, Solaris
meminfo
Exposes memory statistics.
Dragonfly, FreeBSD, Linux
netdev
Exposes network interface statistics such as bytes transferred.
Dragonfly, FreeBSD, Linux, OpenBSD
stat
Exposes various statistics from /proc/stat. This includes CPU usage, boot time, forks and interrupts.
Linux
time
Exposes the current system time.
any
vmstat
Exposes statistics from /proc/vmstat.
Linux

Node Exporter기동 시, 지정할 수 있는 모든 콜렉터에 대한 정보는 Node Exporter github 사이트(https://github.com/prometheus/mysqld_exporter)에서 확인할 수 있다. 


040. Prometheus 설정 파일 변경(클라이언트 추가)
PMM Serverprometheus.yml 파일에 PMM Client의 노드정보를 추가한다.
추가한 PMM Client Node Exporter가 추출하는 시스템 모니터링 지표를 5초마다 Prometheus가 수집(scrape)하도록 설정하는 것이다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[pmm@pmmserver ~]$ cd prometheus
[pmm@pmmserver prometheus]$ vi prometheus.yml
# my global config
global:
  scrape_interval:     5s # By default, scrape targets every 15 seconds.
  evaluation_interval: 5s # By default, scrape targets every 15 seconds.
  # scrape_timeout is set to the global default (10s).
  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
      monitor: 'codelab-monitor'
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first.rules"
  # - "second.rules"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    static_configs:
      - targets: ['localhost:9090']
  - job_name: 'linux'
    scrape_interval: 5s
    static_configs:
      - targets: ['192.168.0.11:9100']
        labels:
          alias"pmmclient:3306"
cs


050. Prometheus 재 기동
prometheus.yml 설정 파일의 변경사항(PMM Client 추가)을 적용하기 위해서는 Prometheus를 재 기동해야 한다. Prometheus의 프로세스를 중지하고 재 기동한다.

1
2
3
4
5
6
7
[pmm@pmmserver prometheus]$ ps -ef | grep prometheus
pmm      13952     1  0 11:36 pts/0    00:00:03 /home/pmm/prometheus/prometheus -config.file=/home/pmm/prometheus/prometheus.yml -storage.local.retention=8760h -log.level=info
[pmm@pmmserver prometheus]$ kill 13952
[pmm@pmmserver prometheus]$ nohup /home/pmm/prometheus/prometheus -config.file=/home/pmm/prometheus/prometheus.yml -storage.local.retention=8760h -log.level=info > /home/pmm/prometheus/prometheus.log 2>&1 &
[163570
[pmm@pmmserver prometheus]$ ps -ef | grep prometheus
pmm      63570 59220  0 11:55 pts/0    00:00:00 /home/pmm/prometheus/prometheus -config.file=/home/pmm/prometheus/prometheus.yml -storage.local.retention=8760h -log.level=info
cs



060. Prometheus 웹 서비스 접속
Prometheus를 정상적으로 재 기동하였다면, Prometheus 웹 서비스에 접속하여 추가한 pmmclient 서버가 정상적으로 등록되었는지 확인해본다.

- Status > Targets : http://192.168.0.10:9090/targets
Job name“linux” pmmclient(192.168.0.11) 노드가 추가되었고, stateUP(정상)이라면 Prometheuspmmclient 서버를 정상적으로 인식한것이다. 


Linux
Endpoint
State
Labels
Last Scrape
Error
UP
alias="pmmclient:3306"
4.017s ago
 
Prometheus
Endpoint
State
Labels
Last Scrape
Error
UP
None
4.134s ago
 


추가한 pmmclient Linux 메트릭을 클릭하면, 현재 Prometheuspmmclient 서버의 node_exporter로부터 수집한 리눅스 모니터링 정보를 확인할 수 있다.

..............
# HELP node_cpu Seconds the cpus spent in each mode.
# TYPE node_cpu counter
node_cpu{cpu="cpu0",mode="guest"} 0
node_cpu{cpu="cpu0",mode="idle"} 6.70609821e+06
node_cpu{cpu="cpu0",mode="iowait"} 43862.4
node_cpu{cpu="cpu0",mode="irq"} 0.5
node_cpu{cpu="cpu0",mode="nice"} 1.43
node_cpu{cpu="cpu0",mode="softirq"} 917.97
..............
cs






[PMM] #020 PMM (Percona Monitoring and Management)

PMM (Percona Monitoring and Management)


Percona Monitoring and Management(이하 PMM)MySQLMongoDB 성능 모니터링을 위하여 Percona사에서 개발한 오픈 소스 기반의 모니터링, 관리 플랫폼이다.

PMM은 간단한 클라이언트-서버 구조를 기반으로 효율적인 확장성을 갖고 있다. PMM 클라이언트와 서버의 역할은 간단히 다음과 같다.

PMM Client
모니터링 대상 호스트의 일반적인 OS(Linux) 시스템 정보와 데이터베이스(MySQL, MongoDB )의 성능정보 및 쿼리 분석 데이터를 수집하며, 모니터링 대상 호스트에 설치된다.

PMM Server
모니터링 대상 호스트로부터 수집(Scraping)한 모니터링 정보(metrics)를 저장하고, 그 정보들을 대시보드, 그래프 등의 직관적이고 효과적인 GUI형태로 보여준다. PMM 플랫폼의 역할의 중심이라고 말할 수 있다.


PMM Architecture
다음은 PMM 플랫폼의 전체적인 아키텍처를 보여주는 다이어그램이다.

PMM 아키텍처(출처 : https://www.percona.com/doc/percona-monitoring-and-management/architecture.html)


PMM Client
PMM Client는 우분투, 데비앙, 레드햇, CentOS, Oracle 리눅스, Amazon 리눅스등 대부분의 공개형 리눅스를 위한 패키지로 제공된다. 또한 범용 리눅스를 위한 tarball 바이너리로도 제공된다. PMM Client 패키지는 다음과 같은 세부 모듈로 구성되어 있다.
- pmm-admin : PMM client를 관리하기 위한 커맨드라인 툴
:
https://www.percona.com/doc/percona-monitoring-and-management/pmm-admin.html#pmm-admin
- percona-quan-agent : 쿼리 성능 데이터를 수집하는 Query Analytics(QAN)을 관리하는 서비스.
- node_exporter : 일반적인 시스템 정보를 수집하는 Prometheus 익스포터.
:
https://github.com/prometheus/node_exporter
- mysqld_exporter : MySQL 서버 정보를 수집하는 Prometheus익스포터.
: https://github.com/percona/mysqld_exporter
- mongodb_exporter : MongoDB 서버 정보를 수집하는 Prometheus익스포터.
: https://github.com/Percona-Lab/prometheus_mongodb_exporter
- proxysql_exporter : ProxySQL의 성능 정보를 수집하는 Prometheus 익스포터.


PMM Server
PMM Server Docker 이미지로 배포되며 다음의 모듈들로 구성되어 있다.

- Query Analytics(QAN) : 특정기간의 MySQL 쿼리 성능을 분석하고, 수집된 Query Analytics 데이터를 웹 어플리케이션(QAN Wep App)으로 시각화하여 보여준다.
- Metrics Monitor(MM) : MySQL 서버나 MongoDB 서버 인스턴스의 모니터링 지표들을 저장하고 GUI형태로 보여준다. MM은 크게 Prometheus Grafana로 구성되어 있다.
   . Prometheus : 서드 파티 시계열(time-series) 데이터베이스로서 PMM Client가 수집한 시스템 정보를 저장한다.
   . Grafana : Prometheus 등의 다양한 데이터소스의 데이터들을 대시보드나 효과적인 그래프 형태로 보여주는 서드 파티 웹 인터페이스 시각화 도구이다.
- Orchestrator : MySQL Replication 토폴로지 관리도구이다


PMM Demo 사이트
- PMM Query Analytics : https://pmmdemo.percona.com/qan/
- PMM Metrics Monitor : https://pmmdemo.percona.com/graph/
- PMM MySQL Replication Topology Manager : https://pmmdemo.percona.com/orchestrator/