웹사이트 검색

Alma Linux 8에서 Nginx로 Netdata를 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. 필수 종속성 설치\n
  3. Netdata 설치
  4. 방화벽 구성\n
  5. Nginx를 Netdata용 역방향 프록시로 구성\n
  6. Netdata 대시보드 액세스
  7. 결론

Netdata는 CPU 사용량, RAM 사용량, 로드, SWAP 사용량, 대역폭 사용량, 디스크 사용량 등과 같은 실시간 데이터를 시각화하고 모니터링하는 무료 오픈 소스 실시간 서버 모니터링 도구입니다. 무슨 일이 일어나고 있는지, 그리고 시스템이나 애플리케이션에서 방금 일어난 일에 대한 개요를 얻습니다. 모든 물리적 서버, 가상 머신, 컨테이너 및 IoT 장치에 설치할 수 있습니다. 영구 스토리지를 위한 다양한 데이터 저장소를 지원하여 서버 메트릭을 볼 수 있는 대화형 웹 인터페이스를 제공합니다.

이 튜토리얼에서는 Alma Linux 8에 Netdata 모니터링 도구를 설치하는 방법을 보여줍니다.

전제 조건

  • Alma Linux 8을 실행하는 서버.\n
  • 서버 IP를 가리키는 유효한 도메인 이름입니다.\n
  • 루트 암호는 서버에서 구성됩니다.\n

필수 종속성 설치

먼저 Netdata 설치에 필요한 EPEL 저장소 및 기타 종속 항목을 설치해야 합니다. 다음 명령을 실행하여 모두 설치할 수 있습니다.

dnf install epel-release -y
dnf install git libuuid-devel autoconf automake pkgconfig zlib-devel curl findutils libmnl gcc make -y

모든 패키지가 설치되면 다음 단계로 진행할 수 있습니다.

넷데이터 설치

기본적으로 Netdata는 Alma Linux 기본 리포지토리에 포함되지 않습니다. 따라서 소스에서 설치해야 합니다.

먼저 다음 명령을 사용하여 Git 리포지토리에서 최신 버전의 Netdata를 다운로드합니다.

git clone --recurse-submodules https://github.com/netdata/netdata.git --depth=100

다운로드가 완료되면 디렉토리를 netdata로 변경하고 다음 명령을 사용하여 필요한 모든 종속성을 설치합니다.

cd netdata
./packaging/installer/install-required-packages.sh --non-interactive --dont-wait netdata

다음으로 다음 명령을 사용하여 다른 패키지를 설치합니다.

dnf --enablerepo=powertools install libuv-devel

다음으로 Netdata 설치 스크립트를 실행하여 설치를 시작합니다.

./netdata-installer.sh

다음과 같은 결과가 표시됩니다.

 --- real-time performance monitoring, done right! --- 

  You are about to build and install netdata to your system.

  The build process will use /tmp for
  any temporary files. You can override this by setting $TMPDIR to a
  writable directory where you can execute files.

  It will be installed at these locations:

   - the daemon     at /usr/sbin/netdata
   - config files   in /etc/netdata
   - web files      in /usr/share/netdata
   - plugins        in /usr/libexec/netdata
   - cache files    in /var/cache/netdata
   - db files       in /var/lib/netdata
   - log files      in /var/log/netdata
   - pid file       at /var/run/netdata.pid
   - logrotate file at /etc/logrotate.d/netdata

  This installer allows you to change the installation path.
  Press Control-C and run the same command with --help for help.


  NOTE:
  Anonymous usage stats will be collected and sent to Netdata.
  To opt-out, pass --disable-telemetry option to the installer or export
  the environment variable DISABLE_TELEMETRY to a non-zero or non-empty value
  (e.g: export DISABLE_TELEMETRY=1).

Press ENTER to build and install netdata to your system >                                                                   

Netdata를 시스템에 설치하려면 Enter 키를 누르십시오. Netdata가 설치되면 다음과 같은 결과가 표시됩니다.

Setting netdata.tarball.checksum to 'new_installation'

 --- We are done! --- 

  ^
  |.-.   .-.   .-.   .-.   .-.   .  netdata  .-.   .-.   .-.   .-.   .-.   .-
  |   '-'   '-'   '-'   '-'   '-'               '-'   '-'   '-'   '-'   '-'   
  +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->

 --- is installed and running now! --- 
  enjoy real-time performance and health monitoring...
systemctl start netdata
systemctl enable netdata

이제 다음 명령을 사용하여 Netdata의 상태를 확인할 수 있습니다.

systemctl status netdata

다음과 같은 결과가 표시됩니다.

? netdata.service - Real time performance monitoring
   Loaded: loaded (/usr/lib/systemd/system/netdata.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2022-03-19 04:22:22 UTC; 4min 16s ago
 Main PID: 58935 (netdata)
    Tasks: 50 (limit: 11412)
   Memory: 103.1M
   CGroup: /system.slice/netdata.service
           ??58935 /usr/sbin/netdata -P /var/run/netdata/netdata.pid -D
           ??58938 /usr/sbin/netdata --special-spawn-server
           ??59063 /usr/libexec/netdata/plugins.d/apps.plugin 1
           ??59064 /usr/libexec/netdata/plugins.d/ebpf.plugin 1
           ??59065 /usr/libexec/netdata/plugins.d/go.d.plugin 1

Mar 19 04:22:22 linux systemd[1]: Starting Real time performance monitoring...
Mar 19 04:22:22 linux systemd[1]: Started Real time performance monitoring.
Mar 19 04:22:22 linux netdata[58935]: CONFIG: cannot load cloud config '/var/lib/netdata/cloud.d/cloud.conf'. Running with internal defaults.
Mar 19 04:22:22 linux netdata[58935]: 2022-03-19 04:22:22: netdata INFO  : MAIN : CONFIG: cannot load cloud config '/var/lib/netdata/cloud.d/>
Mar 19 04:22:22 linux netdata[58935]: 2022-03-19 04:22:22: netdata INFO  : MAIN : Found 0 legacy dbengines, setting multidb diskspace to 256MB
Mar 19 04:22:22 linux netdata[58935]: 2022-03-19 04:22:22: netdata INFO  : MAIN : Created file '/var/lib/netdata/dbengine_multihost_size' to >
Mar 19 04:22:22 linux netdata[58935]: Found 0 legacy dbengines, setting multidb diskspace to 256MB
Mar 19 04:22:22 linux netdata[58935]: Created file '/var/lib/netdata/dbengine_multihost_size' to store the computed value
Mar 19 04:22:23 linux ebpf.plugin[59064]: Does not have a configuration file inside `/etc/netdata/ebpf.d.conf. It will try to load stock file.
Mar 19 04:22:23 linux ebpf.plugin[59064]: Cannot read process groups configuration file '/etc/netdata/apps_groups.conf'. Will try '/usr/lib/n>

이 시점에서 Netdata는 실행 중이며 포트 19999에서 수신 대기합니다. 다음 명령으로 확인할 수 있습니다.

ss -antpl | grep netdata

다음과 같은 결과가 표시됩니다.

LISTEN 0      128        127.0.0.1:8125       0.0.0.0:*    users:(("netdata",pid=58935,fd=29))
LISTEN 0      128          0.0.0.0:19999      0.0.0.0:*    users:(("netdata",pid=58935,fd=6)) 
LISTEN 0      128            [::1]:8125          [::]:*    users:(("netdata",pid=58935,fd=28))
LISTEN 0      128             [::]:19999         [::]:*    users:(("netdata",pid=58935,fd=7))

완료되면 다음 단계로 진행할 수 있습니다.

방화벽 구성

시스템에서 방화벽 방화벽을 사용하는 경우 방화벽을 통해 포트 19999 및 80을 허용해야 합니다. 다음 명령으로 허용할 수 있습니다.

firewall-cmd --permanent --add-port=19999/tcp
firewall-cmd --permanent --add-port=80/tcp

다음으로 firewalld 데몬을 다시 로드하여 변경 사항을 적용합니다.

firewall-cmd --reload

완료되면 다음 단계로 진행할 수 있습니다.

Nginx를 Netdata용 리버스 프록시로 구성

Netdata에 액세스하려면 항상 Nginx를 리버스 프록시로 설치 및 구성하는 것이 좋습니다. 먼저 다음 명령을 사용하여 Nginx 서버를 설치합니다.

dnf install nginx httpd-tools -y

다음으로 다음 명령을 사용하여 암호 파일을 생성합니다.

htpasswd -c /etc/nginx/.htpasswd netadmin

아래와 같이 관리자 비밀번호를 설정합니다.

New password: 
Re-type new password: 
Adding password for user netadmin

다음으로 다음 명령을 사용하여 Nginx 가상 호스트 구성 파일을 만듭니다.

nano /etc/nginx/conf.d/netdata.conf

다음 줄을 추가합니다.

upstream backend {
server 127.0.0.1:19999;
keepalive 64;
}

server {
listen 80;
server_name netdata.example.com;

    location / {

    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://backend;
    proxy_http_version 1.1;   
    proxy_pass_request_headers on;
    proxy_set_header Connection "keep-alive";
    proxy_store off;
    auth_basic "Private Property";
    auth_basic_user_file /etc/nginx/.htpasswd;
}
}

파일을 저장하고 닫은 다음 구문 구성 오류가 있는지 Nginx를 확인합니다.

nginx -t

모든 것이 정상이면 다음과 같은 결과가 표시됩니다.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

그런 다음 Nginx 서비스를 다시 시작하여 구성 변경 사항을 적용합니다.

systemctl restart nginx

다음 명령을 사용하여 Nginx 상태를 확인할 수도 있습니다.

systemctl status nginx

다음 출력이 표시되어야 합니다.

? nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2022-03-19 04:28:44 UTC; 4s ago
  Process: 61706 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 61705 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 61703 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 61708 (nginx)
    Tasks: 2 (limit: 11412)
   Memory: 3.7M
   CGroup: /system.slice/nginx.service
           ??61708 nginx: master process /usr/sbin/nginx
           ??61709 nginx: worker process

Mar 19 04:28:44 linux systemd[1]: Starting The nginx HTTP and reverse proxy server...
Mar 19 04:28:44 linux nginx[61705]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Mar 19 04:28:44 linux nginx[61705]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Mar 19 04:28:44 linux systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Mar 19 04:28:44 linux systemd[1]: Started The nginx HTTP and reverse proxy server.

완료되면 다음 단계로 진행할 수 있습니다.

Netdata 대시보드에 액세스

이제 웹 브라우저를 열고 URL http://your-server-ip를 사용하여 Netdata 대시보드에 액세스하십시오. Netdata 로그인 페이지가 표시됩니다.

관리자 사용자 이름, 비밀번호를 제공하고 로그인 버튼을 클릭합니다. 다음 페이지에 Netdata 대시보드가 표시되어야 합니다.

결론

축하합니다! Alma Linux 8에 Netdata 모니터링 도구를 성공적으로 설치했습니다. 이제 Netdata 대시보드에서 실시간으로 서버 매트릭스 모니터링을 시작할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.