Promtheus + MySQL Exporter 연동

2021. 6. 29. 00:21·Infrastructure/Prometheus
반응형

MySQL Exporter 설치 및 연동

MySQL Exporter 다운로드
# 버전
MySQL >= 5.6.
MariaDB >= 10.2

# 유저 없으면 추가, 있으면 접속
useradd -m -s /bin/bash prometheus
su - prometheus

# 다운로드
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz
tar zxvf mysql-5.6.51-linux-glibc2.12-x86_64.tar.gz
mv mysqld_exporter-0.13.0.linux-amd64/ mysql_exporter

exit
MySQL 에 권한 추가
# MySQL 권한 추가 (8버전?) 
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'exporter_password' WITH MAX_USER_CONNECTIONS 2;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
FLUSH PRIVILEGES;
EXIT;

# MySQL 권한 추가 (5.6 도...)
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'exporter_password';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost' WITH MAX_USER_CONNECTIONS 2;
FLUSH PRIVILEGES;
EXIT;
MySQL my.cnf 설정값 추가
# exporter가 비번 안알려주면 집에 어케 들어감
sudo su

vi /etc/my.cnf

[client]
user=exporter
password=exporter_password
Exporter 서비스 등록
  • my.cnf 경로 , 서비스 경로 확인 하도록 하자
# collect 와 config 는 아래서 확인!
# https://github.com/prometheus/mysqld_exporter

# 아래 MySQL my.cnf 경로 확인하도록 하자
vi /etc/systemd/system/mysql_exporter.service

[Unit]
Description=Prometheus MySQL Exporter
After=network.target
User=prometheus
Group=prometheus

[Service]
Type=simple
Restart=always
ExecStart=/home/prometheus/mysql_exporter/mysqld_exporter \
--config.my-cnf /etc/my.cnf \
--collect.global_status \
--collect.info_schema.innodb_metrics \
--collect.auto_increment.columns \
--collect.info_schema.processlist \
--collect.binlog_size \
--collect.info_schema.tablestats \
--collect.global_variables \
--collect.info_schema.query_response_time \
--collect.info_schema.userstats \
--collect.info_schema.tables \
--collect.perf_schema.tablelocks \
--collect.perf_schema.file_events \
--collect.perf_schema.eventswaits \
--collect.perf_schema.indexiowaits \
--collect.perf_schema.tableiowaits \
--collect.slave_status \
--web.listen-address=0.0.0.0:9104

[Install]
WantedBy=multi-user.target
서비스행
systemctl daemon-reload
systemctl start mysql_exporter
systemctl enable mysql_exporter
systemctl status mysql_exporter
728x90
반응형
저작자표시 비영리 (새창열림)
'Infrastructure/Prometheus' 카테고리의 다른 글
  • Prometheus + Node Exporter + Grafana 연동
상쾌한기분
상쾌한기분
  • 상쾌한기분
    상쾌한기분
    상쾌한기분
  • 전체
    오늘
    어제
    • 분류 전체보기 (251)
      • Python (44)
        • Python (26)
        • Django (6)
        • Flask (4)
        • Open Source (6)
      • Kotlin & Java (5)
        • Spring (2)
        • 프로젝트 (1)
      • Go (11)
      • Database (24)
        • MySQL (21)
        • Redis (3)
      • Infrastructure (2)
        • CDC (4)
        • Kafka (5)
        • Prometheus (2)
        • Fluentd (11)
        • Docker (1)
        • Airflow (2)
        • VPN (2)
      • IT (26)
        • AI (9)
        • Langchain (8)
        • Web (18)
        • Git (8)
        • 리팩토링 (9)
        • Micro Service Architecture (8)
        • Clean Code (16)
        • Design Pattern (0)
        • 수학 (1)
        • 알고리즘 (14)
      • OS (14)
        • Centos (10)
        • Ubuntu (3)
        • Mac (1)
      • Search Engine (2)
        • ElasticSearch (1)
        • Lucene Solr (1)
      • PHP (2)
        • Laravel (1)
        • Codeigniter (1)
  • 블로그 메뉴

    • Github 방문
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    fluentd
    git
    Golang
    Kafka
    Langchain
    python
    LLM
    docker
    http
    티스토리챌린지
    MYSQL
    ollama
    go
    백준
    CDC
    Redis
    performance
    prompt
    파이썬
    오블완
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
상쾌한기분
Promtheus + MySQL Exporter 연동
상단으로

티스토리툴바