모니터링 · 6 min read · Dec 01, 2025

Rocky Linux에 Prometheus와 Node Exporter 설치하는 방법

Prometheus는 오픈 소스 모니터링 및 경고 플랫폼입니다.

원래 Prometheus는 2012년 Soundcloud에 의해 만들어졌습니다. 그 이후로 Prometheus 프로젝트는 유명한 몇몇 회사에 의해 채택되어 매우 활발한 개발자와 커뮤니티가 있는 더 큰 프로젝트가 되었습니다. 그리고 2016년, Prometheus 프로젝트는 Cloud Native Computing Foundation (CNCF)의 졸업생이 되었습니다.

알아야 할 기본 개념

기본적으로 Prometheus는 대상 서버의 HTTP 엔드포인트를 통해 데이터와 메트릭을 수집한 다음 모든 데이터를 시계열로 저장합니다. Prometheus에서 시계열 데이터는 메트릭 이름과 키/값 쌍으로 식별됩니다.

Prometheus는 Prometheus 쿼리 언어(PromQL)를 통해 유연성을 제공합니다. PromQL을 사용하여 Prometheus 시계열 데이터베이스를 쿼리할 수 있습니다.

대상 서버에는 모든 데이터와 메트릭을 Prometheus에 노출하는 ‘exporter‘ 애플리케이션을 설치해야 합니다. ‘Node Exporter’는 Linux 머신을 모니터링하는 데 일반적으로 사용되는 exporter입니다.

Node exporter는 Linux 머신의 하드웨어 및 커널 관련 메트릭을 노출합니다. 이는 Prometheus 서버에 데이터와 메트릭을 노출하는 단일 바이너리 파일로 제공됩니다.

전제 조건

이 기사에서는 Rocky Linux 8 시스템에 Prometheus 모니터링 도구와 Node Exporter를 설치하는 방법을 배웁니다.

시작하기 전에 다음 요구 사항이 충족되었는지 확인하십시오:

  • 운영 체제: Rocky Linux 8.5 (Green Obsidian)
  • 루트 권한

이 예제에서는 IP 주소가 ‘ 192.168.1.10 ‘인 Rocky Linux 시스템을 사용합니다.

이제 시작해 보겠습니다.

새 사용자 및 디렉토리 추가

먼저, ‘prometheus’라는 새 시스템 사용자를 생성한 다음 Prometheus 설치를 위한 새 구성 디렉토리와 데이터 디렉토리를 생성합니다.

  1. 다음 명령을 실행하여 새 사용자 ‘ prometheus ‘를 생성합니다.
sudo adduser -M -r -s /sbin/nologin prometheus
  1. 그 후, 다음 명령을 사용하여 새 구성 디렉토리 ‘/etc/prometheus ‘와 데이터 디렉토리 ‘ /var/lib/prometheus ‘를 생성합니다.
sudo mkdir /etc/prometheus  
sudo mkdir /var/lib/prometheus

모든 Prometheus 구성은 ‘ /etc/prometheus ‘ 디렉토리에서 사용할 수 있으며, 모든 Prometheus 데이터는 자동으로 ‘ /var/lib/prometheus ‘ 디렉토리에 저장됩니다.

Rocky Linux에 Prometheus 설치

이 단계에서는 tarball 또는 tar.gz 파일에서 Prometheus 모니터링 시스템을 수동으로 설치합니다.

이 링크에서 Prometheus 버전을 선택하십시오. 이 예제에서는 Prometheus의 최신 버전을 설치할 것입니다.

Prometheus tarball 다운로드

  1. 작업 디렉토리를 ‘/usr/src’로 변경하고 다음 명령을 사용하여 Prometheus 바이너리를 다운로드합니다.
cd /usr/src  
wget https://github.com/prometheus/prometheus/releases/download/v2.31.1/prometheus-2.31.1.linux-amd64.tar.gz

다운로드 프로세스가 완료되면 Prometheus 파일을 추출합니다.

tar -xf prometheus-2.31.1.linux-amd64.tar.gz

이제 ‘ prometheus-VERSION.OS ‘라는 새 디렉토리가 표시됩니다.

  1. 다음으로, 모든 Prometheus 구성을 ‘/etc/prometheus’ 디렉토리로 복사하고 바이너리 파일 ‘ prometheus ‘를 ‘ /usr/local/bin ‘ 디렉토리로 복사합니다.

환경 변수 ‘ PROM_SRC ‘를 디렉토리 ‘/usr/src/prometheus-* ‘로 설정합니다.

export PROM_SRC=/usr/src/prometheus-*

Prometheus 구성 ‘ prometheus.yml ‘을 ‘ /etc/prometheus ‘ 디렉토리로 복사합니다.

sudo cp $PROM_SRC/prometheus.yml /etc/prometheus/

바이너리 파일 ‘ prometheus ‘와 ‘ promtool ‘을 ‘/usr/local/bin/ ‘ 디렉토리로 복사합니다.

sudo cp $PROM_SRC/prometheus /usr/local/bin/  
sudo cp $PROM_SRC/promtool /usr/local/bin/

Prometheus 콘솔 템플릿과 라이브러리를 ‘/etc/prometheus’ 디렉토리로 복사합니다.

sudo cp -r $PROM_SRC/consoles /etc/prometheus  
sudo cp -r $PROM_SRC/console_libraries /etc/prometheus
  1. 다음으로, nano 편집기를 사용하여 Prometheus 구성 ‘ /etc/prometheus/prometheus.yml’을 편집합니다.
nano /etc/prometheus/prometheus.yml

‘scrape_configs’ 옵션에서 모니터링 작업과 대상에서 모든 데이터를 스크랩하는 방법을 추가해야 할 수 있습니다.

기본 구성은 기본 모니터링 작업 이름 ‘prometheus’와 ‘ static_configs ‘ 옵션을 통해 대상 서버 ‘ localhost ‘와 함께 제공됩니다.

대상을 ‘localhost:9090’에서 서버 IP 주소 ‘ 192.168.1.10:9090 ‘로 변경합니다.

# 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=` to any timeseries scraped from this config.  
  - job_name: "prometheus"  
   
    # metrics_path defaults to '/metrics'  
    # scheme defaults to 'http'.  
   
    static_configs:  
      - targets: ["192.168.1.10:9090"]

구성을 저장하고 종료합니다.

  1. 이제 다음 명령을 실행하여 구성 및 데이터 디렉토리를 사용자 ‘ prometheus ‘로 변경합니다.
sudo chown prometheus:prometheus /etc/prometheus  
sudo chown prometheus:prometheus /var/lib/prometheus

이제 기본 Prometheus 설치를 완료했습니다.

Prometheus 구성

Prometheus 서비스 파일 설정

이 단계에서는 Prometheus를 systemd 서비스로 설정합니다.

  1. nano 편집기를 사용하여 새 systemd 서비스 파일 ‘/etc/systemd/system/prometheus.service’를 생성합니다.
sudo nano /etc/systemd/system/prometheus.service

다음 구성을 복사하여 붙여넣습니다.

[Unit]  
Description=Prometheus  
Wants=network-online.target  
After=network-online.target  
  
[Service]  
User=prometheus  
Group=prometheus  
Type=simple  
ExecStart=/usr/local/bin/prometheus \  
    --config.file /etc/prometheus/prometheus.yml \  
    --storage.tsdb.path /var/lib/prometheus/ \  
    --web.console.templates=/etc/prometheus/consoles \  
    --web.console.libraries=/etc/prometheus/console_libraries  
  
[Install]  
WantedBy=multi-user.target

구성을 저장하고 종료합니다.

  1. 다음으로, 새로운 구성을 적용하기 위해 systemd 관리자를 다시 로드합니다.
sudo systemctl daemon-reload
  1. 이제 다음 명령을 실행하여 Prometheus 서비스를 시작하고 활성화한 다음 현재 상태를 확인합니다.
sudo systemctl enable --now prometheus  
sudo systemctl status prometheus

설치가 성공하면 Prometheus 서비스가 활성 상태로 실행되고 있는 것을 볼 수 있습니다.

systemd 서비스로 Prometheus 구성

이제 Prometheus 모니터링 도구에 TCP 포트 ‘ 9090 ‘에서 접근할 수 있습니다.

  1. 웹 브라우저를 열고 주소 표시줄에 포트 ‘ 9090 ‘와 함께 서버 IP 주소를 입력합니다.

http://192.168.1.10:9090/

그러면 아래의 Prometheus 대시보드 쿼리를 볼 수 있습니다.

Prometheus 쿼리 대시보드

이제 Prometheus 설치를 완료했습니다. Node Exporter 설치를 위한 다음 단계로 이동합니다.

Rocky Linux에 Node Exporter 설치

Node exporter는 Prometheus 프로젝트의 일부입니다. Node exporter를 사용하여 Linux 서버의 메트릭을 Prometheus 서버로 내보낼 수 있습니다.

이 단계에서는 tar.gz 파일에서 Rocky Linux 시스템에 node exporter를 설치합니다.

이 링크를 확인하여 node exporter의 최신 버전을 가져옵니다. 이 예제에서는 node exporter 버전 1.3.0을 설치합니다.

Node Exporter 다운로드

  1. 작업 디렉토리를 ‘ /usr/src ‘로 변경하고 다음 명령을 사용하여 node exporter 바이너리 파일을 다운로드합니다.
cd /usr/src/  
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.0/node_exporter-1.3.0.linux-amd64.tar.gz

다운로드 프로세스가 완료되면 node exporter 파일을 추출합니다.

tar -xf node_exporter-1.3.0.linux-amd64.tar.gz

이제 ‘node_exporter-VERSION.OS’라는 새 디렉토리가 생성됩니다.

  1. 다음으로, node exporter 바이너리 파일을 ‘/usr/local/bin ‘ 디렉토리로 이동합니다.
mv node_exporter-*/node_exporter /usr/local/bin

node exporter를 systemd 서비스로 설정하는 다음 단계로 이동합니다.

Node_exporter를 서비스로 설정

node exporter 서비스 파일을 만들기 전에 ‘ node_exporter ‘라는 새 시스템 사용자를 생성합니다.

  1. 다음 명령을 실행하여 새 시스템 사용자를 생성합니다.
sudo adduser -M -r -s /sbin/nologin node_exporter
  1. 다음으로, nano 편집기를 사용하여 node exporter에 대한 새 서비스 파일 ‘/etc/systemd/system/node_exporter.service’를 생성합니다.
sudo nano /etc/systemd/system/node_exporter.service

다음 구성을 복사하여 붙여넣습니다.

[Unit]  
Description=Node Exporter  
After=network.target  
  
[Service]  
User=node_exporter  
Group=node_exporter  
Type=simple  
ExecStart=/usr/local/bin/node_exporter  
  
[Install]  
WantedBy=multi-user.target

구성을 저장하고 종료합니다.

  1. 이제 새로운 구성을 적용하기 위해 systemd 관리자를 다시 로드합니다.
sudo systemctl daemon-reload
  1. 다음 명령을 사용하여 ‘node_exporter’ 서비스를 시작하고 활성화합니다.
sudo systemctl enable --now node_exporter

Node Exporter 구성

그 후, ‘node_exporter’ 서비스의 현재 상태를 확인합니다.

sudo systemctl status node_exporter

node_exporter ‘ 서비스가 활성 상태로 실행되고 있는지 확인합니다.

systemd 서비스로 Node Exporter 구성

  1. node exporter는 기본 포트 ‘ 9100 ‘에서 실행되고 있습니다. 아래의 ss 명령을 사용하여 확인합니다.
ss -aplnt | grep node

아래와 유사한 출력을 볼 수 있습니다.

State    Recv-Q   Send-Q     Local Address:Port     Peer Address:Port   Process  
LISTEN   0        128              0.0.0.0:22            0.0.0.0:*       users:(("sshd",pid=683,fd=4))  
LISTEN   0        128                    *:9090                *:*       users:(("prometheus",pid=709,fd=8))  
LISTEN   0        128                    *:9100                *:*       users:(("node_exporter",pid=5786,fd=3))  
LISTEN   0        128                         [::]:22               [::]:*       users:(("sshd",pid=683,fd=6))

이제 Rocky Linux 시스템에 node exporter 설치를 완료했습니다.

Node_exporter를 Prometheus에 추가

Prometheus와 node exporter 설치를 완료한 후, node exporter를 Prometheus 서버에 추가합니다.

  1. nano 편집기를 사용하여 Prometheus 구성을 편집합니다.
sudo nano /etc/prometheus/prometheus.yml

‘scrape_config’ 섹션 아래에 다음 구성을 사용하여 새로운 Prometheus 작업을 추가합니다. 그리고 서버 IP 주소를 대상 서버로 변경했는지 확인합니다.

  - job_name: 'node_exporter_metrics'  
    scrape_interval: 5s  
    static_configs:  
      - targets: ['SERVER-IP:9100']

구성을 저장하고 종료합니다.

  1. 이제 새로운 구성을 적용하기 위해 Prometheus 서비스를 재시작합니다.
sudo systemctl restart prometheus

이제 node exporter를 Prometheus 서버에 추가했습니다.

Prometheus 및 Node Exporter 설치 확인

  1. Prometheus 대시보드로 돌아가서 메뉴 ‘ Status ‘를 클릭하고 ‘ Targets ‘를 선택합니다.

두 개의 다른 엔드포인트, ‘ prometheus ‘와 ‘ node_exporter_metrics ‘를 볼 수 있습니다.

Prometheus 대상 메트릭

  1. 다음으로, 메뉴 ‘ graph ‘로 이동하여 검색창에 PromQL 쿼리를 입력합니다. 이 예제에서는 쿼리 ‘ node_os_info ‘를 사용하여 운영 체제의 세부 정보를 확인합니다.

현재 운영 체제에 대한 자세한 정보를 볼 수 있습니다.

prometheus 예제 PromQL 쿼리

  1. 또 다른 예로, 쿼리 ‘ node_network_speed_bytes ‘를 사용하여 네트워크 속도를 확인한 후 ‘ Graph ‘ 탭으로 이동합니다. 아래와 유사한 출력을 볼 수 있습니다.

prometheus 예제 PromQL 쿼리

이제 Rocky Linux 시스템에 Prometheus와 node exporter를 성공적으로 설치했습니다.

결론

축하합니다! Rocky Linux 시스템에 Prometheus 모니터링 시스템과 node exporter의 기본 설치 및 구성을 배웠습니다.

다음 단계로는 다른 애플리케이션을 위한 또 다른 Prometheus exporter와 모니터링 대시보드로 Grafana를 탐색할 수 있습니다.

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.