728x90
반응형
  • grafana 설치 이후 loki 와 promtail 을 설치 하여 로그를 모니터링 하는 방법에 대해 알아 보겠습니다. 

 

구성 설명 

 

  • Promtail: 로그를 수집하고 필터링한 후 Loki로 전송하는 로그 수집기.
  • Loki: 로그 데이터를 저장하고 검색 쿼리를 처리하는 로그 데이터베이스.
  • Grafana: Loki로부터 데이터를 시각화하고 분석하는 대시보드 툴 입니다. .

 

 

설치

Loki 설치 

  • loki 바이너리를 다운로드 받아 압축해제후 loki 설치 합니다. 
#loki 다운로드 
mkdir loki 
cd loki 
wget https://github.com/grafana/loki/releases/download/v2.9.8/loki-linux-amd64.zip    
unzip loki-linux-amd64.zip


#loki 환경설정 파일 다운로드 
wget https://raw.githubusercontent.com/grafana/loki/main/cmd/loki/loki-local-config.yaml

 

 

  • loki-local-config.yaml 수정 
auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096



ingester:
  lifecycler:
    address: 192.168.116.200
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 5m
  chunk_retain_period: 30s
  max_transfer_retries: 0

schema_config:
  configs:
    - from: 2018-04-15
      store: boltdb
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 168h

storage_config:
  boltdb:
    directory: /data/loki/index

  filesystem:
    directory: /data/loki/chunks

limits_config:
  enforce_metric_name: false
  reject_old_samples: true
  reject_old_samples_max_age: 168h

chunk_store_config:
  max_look_back_period: 0s

table_manager:
  retention_deletes_enabled: false
  retention_period: 0s

 

  • loki 실행
nohup ./loki-linux-amd64 -config.file=loki-local-config.yaml   2>&1 &
  • 실행 파일 생성 ( loki-startup.sh)
vi loki-startup.sh 
kill -9 $(lsof -t -i:3100) || true
nohup ./loki-linux-amd64 -config.file=loki-local-config.yaml 2>&1 &

 

 

Promtail 설치

  • Promtail  바이너리를 다운로드 받아 압축 해제후Promtail 설치 합니다. 
mkdir promtail 
cd promtail 

wget https://github.com/grafana/loki/releases/download/v2.8.0/promtail-linux-amd64.zip

unzip promtail-linux-amd64.zip

nohup ./promtail-linux-amd64 -config.file=promtail-config.yaml 2>&1 &
  • promtail-local-config.yaml 설정 변경 : 수집할 로그와 위치를 변경 합니다. 
  • scrape_configs 는 수집할 로그입니다. 
  • 여러개의 job  을 등록 해서 사용할수 있습니다. 
server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://localhost:3100/loki/api/v1/push

scrape_configs:
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      __path__: /var/log/*log
      stream: stdout

 

 

Grafana 연동 설정 

  • 로그를 수집 하기 위한 promtail 설치와 수집된 데이터를 저장 하고 분석 하기 위한 loki 설치가 완료 되었다면 이제  grafana 에서 수집된 로그를 모니터링하기 위한 grafana  모니터링 셋팅을 진행 합니다. 

Data Connection 등록 

  • Connection -> Add new Connection 매뉴 선택후 검색창에 loki 를 검색한 후 Connection 연결 설정을 진행 합니다. 

 

 

DashBoard 작성 

  • 대시보드 등록을 통해 promtail 을 통해 수집된 로그를 모니터링 할수있도록 대시보드 셋팅을 진행 합니다. 

 

 

  • Label filters 설정 : promtail 설정 파일에 등록한 정보로 선택합니다.  
    • job 선택 : promtail 에 설정한 job 이름 
    • varlogs 선택 : promtail 에 설정한 로그 내용 
    • Line Contails 설정 : systemd 입력 

 

 

  • 우측 화면 콤보박스(현재는 Logs ) 를 선택하면 아래와 같은 다양한 형태로 데이터를 시각화 할수 있습니다. 

 

  • 설정이 완료되면 Save 버튼을 눌러서 대시보드를 저장합니다. 

 

 

 

728x90
반응형

'07.Monitoring > Grafana' 카테고리의 다른 글

[Grafana] Centos - Grafana Install  (0) 2024.05.13
728x90
반응형

리눅스 웹 콘솔 

  • 웹 콘솔 기능은 Red Hat Enterprise Linux (RHEL) 웹 콘솔은 RHEL 8부터 기본 기능으로 포함되었습니다. 이 웹 콘솔은 Cockpit 프로젝트에 기반을 두고 있으며, 이를 통해 웹 기반의 시스템 관리 인터페이스를 제공하고 있습니다.

접근 방법 및 설치 

dnf install cockpit
systemctl enable --now cockpit.socket

firewall-cmd --add-service=cockpit --permanent
firewall-cmd --reload

 

 

WebConsole Root 접속 방법 

vi /etc/cockpit/disallowed-users 파일 편집 -> root 주석 

[root@my-rocky9 ~]# vi /etc/cockpit/disallowed-users
# List of users which are not allowed to login to Cockpit
#root

 

WebConsole  기능 확인 

  • https://<서버의 IP 주소 또는 호스트 이름>:9090 접속 

 

녹화_2024_02_01_16_31_00_690.mp4
4.04MB

 

 

  • 포트 변경 필요시 vi /etc/systemd/system/sockets.target.wants/cockpit.socket  파일을 열어 ListenStream 포트를 변경 합니다. 
vi /etc/systemd/system/sockets.target.wants/cockpit.socket

 

728x90
반응형
728x90
반응형

이전글에서 Centos7.9 환경에서 Zabbix 5.0 설치를 진행 했습니다. 

이번 글은 Rocky 9.4 환경에서 Zabbix 6.0 설치 하는 방법에 대해 소개합니다. 

 

환경구성

  • Zabbix Server 설치  
    • Rocky Linux release 9.4 (Blue Onyx)
    • PostgreSQL 15.7 
# zabbix_server --version 
zabbix_server: /usr/pgsql-14/lib/libpq.so.5: no version information available (required by zabbix_server)
zabbix_server (Zabbix) 6.0.30
Revision 680df722d6b 21 May 2024, compilation time: May 21 2024 00:00:00

Copyright (C) 2024 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <https://www.gnu.org/licenses/>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 3.0.7 1 Nov 2022
Running with OpenSSL 3.0.7 1 Nov 2022
  • Zabbix Agent 설치 
    • Red Hat Enterprise Linux release 9.2 (Plow)
    • Red Hat Enterprise Linux release 8.7 (Ootpa)
    • Rocky Linux release 8.9 (Green Obsidian)
    • CentOS Linux release 7.9.2009 (Core)

 

Zabbix  설치

  • Zabbix 버전은 6.0 LTS 버전 +  PostgreSQL 15 버전을설치하여 진행 합니다. 

Zabbix  서버 설치

 

Download and install Zabbix

 

www.zabbix.com

 

 

 

  • Zabbix repository 설정
    •  /etc/yum.repos.d/epel.repo 수정 
    • excludepkgs=zabbix*
# vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
excludepkgs=zabbix*

 

  • zabbix repository 설치
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
dnf clean all
# rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm(을)를 복구합니다
경고: /var/tmp/rpm-tmp.w2R0RU: Header V4 RSA/SHA512 Signature, key ID 08efa7dd: NOKEY
Verifying...                          ################################# [100%]
준비 중...                         ################################# [100%]
Updating / installing...
   1:zabbix-release-6.0-4.el9         ################################# [100%]


# dnf clean all
43 파일이 삭제되었습니다

 

  • Zabbix server, frontend, agent 설치
dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

 

# dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
Extra Packages for Enterprise Linux 9 - x86_64                                                                                  8.5 MB/s |  21 MB     00:02    
Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64                                                            399  B/s | 2.5 kB     00:06    
Rocky Linux 9 - BaseOS                                                                                                          1.8 MB/s | 2.2 MB     00:01    
Rocky Linux 9 - AppStream                                                                                                       6.0 MB/s | 7.9 MB     00:01    
Rocky Linux 9 - Extras                                                                                                           21 kB/s |  15 kB     00:00    
Zabbix Official Repository - x86_64                                                                                             197 kB/s | 344 kB     00:01    
Zabbix Official Repository (non-supported) - x86_64                                                                             839  B/s | 1.1 kB     00:01    
Zabbix Official Repository (Agent2 Plugins) - x86_64                                                                            1.3 kB/s | 1.6 kB     00:01    
종속성이 해결되었습니다.
.......................
................
...........

설치되었습니다:
  OpenIPMI-libs-2.0.32-3.el9.x86_64                  apr-1.7.0-12.el9_3.x86_64                             apr-util-1.6.1-23.el9.x86_64                       
  apr-util-bdb-1.6.1-23.el9.x86_64                   apr-util-openssl-1.6.1-23.el9.x86_64                  fping-5.1-1.el9.x86_64                             
  httpd-2.4.57-8.el9.x86_64                          httpd-core-2.4.57-8.el9.x86_64                        httpd-filesystem-2.4.57-8.el9.noarch               
  httpd-tools-2.4.57-8.el9.x86_64                    mod_http2-2.0.26-2.el9_4.x86_64                       mod_lua-2.4.57-8.el9.x86_64                        
  nginx-filesystem-1:1.20.1-14.el9_2.1.noarch        php-bcmath-8.0.30-1.el9_2.x86_64                      php-common-8.0.30-1.el9_2.x86_64                   
  php-fpm-8.0.30-1.el9_2.x86_64                      php-gd-8.0.30-1.el9_2.x86_64                          php-ldap-8.0.30-1.el9_2.x86_64                     
  php-mbstring-8.0.30-1.el9_2.x86_64                 php-pdo-8.0.30-1.el9_2.x86_64                         php-pgsql-8.0.30-1.el9_2.x86_64                    
  php-xml-8.0.30-1.el9_2.x86_64                      rocky-logos-httpd-90.15-2.el9.noarch                  zabbix-agent-6.0.30-release1.el9.x86_64            
  zabbix-apache-conf-6.0.30-release1.el9.noarch      zabbix-selinux-policy-6.0.30-release1.el9.x86_64      zabbix-server-pgsql-6.0.30-release1.el9.x86_64     
  zabbix-sql-scripts-6.0.30-release1.el9.noarch      zabbix-web-6.0.30-release1.el9.noarch                 zabbix-web-deps-6.0.30-release1.el9.noarch         
  zabbix-web-pgsql-6.0.30-release1.el9.noarch       

완료되었습니다!


PostgreSQL 설치 

  • PostgreSQL 15 버전을 설치합니다. 
#Update the system
dnf update

#Install PostgreSQL Repository
 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
#Install the PostgreSQL Server
sudo dnf -qy module disable postgresql
sudo dnf install -y postgresql15-server


#Creating a New PostgreSQL Database Cluster
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb

#PostgreSQL 시작 
systemctl restart postgresql-15
systemctl enable postgresql-15
systemctl status postgresql-15

 

  • PostgreSQL 환경설정
    • vi /var/lib/pgsql/15/data/postgresql.conf 
#listen_addresses 수정
listen_addresses = '*'

 

  • vi /var/lib/pgsql/15/data/pg_hba.conf 
#추가
host    all             all        0.0.0.0/0               trust
  • PostgreSQL 기동
systemctl restart postgresql-15
  • PostgreSQL 상태확인
$ systemctl status postgresql-15
● postgresql-15.service - PostgreSQL 15 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; enabled; preset: disabled)
     Active: active (running) since Wed 2024-06-05 08:49:21 KST; 24s ago
       Docs: https://www.postgresql.org/docs/15/static/
    Process: 46925 ExecStartPre=/usr/pgsql-15/bin/postgresql-15-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 46931 (postmaster)
      Tasks: 7 (limit: 47472)
     Memory: 17.4M
        CPU: 79ms
     CGroup: /system.slice/postgresql-15.service
             ├─46931 /usr/pgsql-15/bin/postmaster -D /var/lib/pgsql/15/data/
             ├─46932 "postgres: logger "
             ├─46933 "postgres: checkpointer "
             ├─46934 "postgres: background writer "
             ├─46936 "postgres: walwriter "
             ├─46937 "postgres: autovacuum launcher "
             └─46938 "postgres: logical replication launcher "
  • PostgreSQL Zabbix Metadata Create 
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix

zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix

 

Zabbix server 환경 설정 및 재기동 

  • Zabbix Server 와 PostgreSQL 서버가 설치 되었다면 
  • ZabbixPostgreSQL  연결을 위해 zabbix server 환경파일을 수정합니다. 
  • vi  /etc/zabbix/zabbix_server.conf

 

  • Zabbix server and agent 재기동
systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server zabbix-agent httpd php-fpm

 

Zabbix 웹 브라우저 접속 

  • http://[서버ip]/zabbix/  접속

 

 

 

 

 

 

 

 

  • 설치가 완료되면 Zabbix 웹 페이지에 접속 해서 모니터링 셋팅을 진행 한다. 
  • http://[서버ip]/zabbix/  접속
  • 최초 접속 비밀 번호는 Admin/zabbix 이다 .
  • 하단 그림 처럼 경고 문구가 발생할 경우 zabbix 서버 로그 를 확인 합니다. 
    • zabbix 서버가 동작하지 않습니다...... .

  • 아래와 같은 에러 가 발생할경우 zabbix 에서 postgresql 에 접속이 실패할경우 아래 두파일의 설정을 재 확인합니다.    
    • /var/lib/pgsql/15/data/postgresql.conf 
    • vi /var/lib/pgsql/15/data/pg_hba.conf 
 

 connection to database 'zabbix' failed: [0] connection to server at "localhost" (::1), port 5432 failed: 치명적오류:  사용자 "zabbix"의 password 인증을 실패했습니다        

617085:20240530:201041.783 Starting Zabbix Server. Zabbix 6.0.30 (revision 680df722d6b).
617085:20240530:201041.783 ****** Enabled features ******
617085:20240530:201041.783 SNMP monitoring:           YES
617085:20240530:201041.783 IPMI monitoring:           YES
617085:20240530:201041.783 Web monitoring:            YES
617085:20240530:201041.783 VMware monitoring:         YES
617085:20240530:201041.783 SMTP authentication:       YES
617085:20240530:201041.783 ODBC:                      YES
617085:20240530:201041.783 SSH support:               YES
617085:20240530:201041.783 IPv6 support:              YES
617085:20240530:201041.783 TLS support:               YES
617085:20240530:201041.783 ******************************
617085:20240530:201041.783 using configuration file: /etc/zabbix/zabbix_server.conf
617085:20240530:201042.064 [Z3001] connection to database 'zabbix' failed: [0] connection to server at "localhost" (::1), port 5432 failed: 치명적오류:  사용자 "zabbix"의 pa
ssword 인증을 실패했습니다

617085:20240530:201042.064 database is down: reconnecting in 10 seconds
617085:20240530:201052.077 [Z3001] connection to database 'zabbix' failed: [0] connection to server at "localhost" (::1), port 5432 failed: 치명적오류:  사용자 "zabbix"의 pa
ssword 인증을 실패했습니다

617085:20240530:201052.077 database is down: reconnecting in 10 seconds
617085:20240530:201102.089 [Z3001] connection to database 'zabbix' failed: [0] connection to server at "localhost" (::1), port 5432 failed: 치명적오류:  사용자 "zabbix"의 pa
ssword 인증을 실패했습니다

 

 

Zabbix 6.0 agent 설치 

 

Download and install Zabbix

Zabbix is being downloaded over 4 000 000 times every year for a reason. Download and install Zabbix for free and try it yourself!

www.zabbix.com

 

  • Rocky Linux release 8.9 서버의 zabbix agent 설치 
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm
dnf clean all

dnf install zabbix-agent2 zabbix-agent2-plugin-*


systemctl restart zabbix-agent2
systemctl enable zabbix-agent2
  • zabbix_agentd.conf 파일 수정 
    • Zabbix Server IP  수정 
    • Zabbix  Agent Port 설정 

Zabbix 모니터링 구성

  • 정상적으로 설치가 완료 되었다면 서버의 자원모니터링 하기 위해 호스트를 등록 합니다. 
  • zabbix 웹 브라우져에 접속 하여 모니터링 할 agent[호스트]를 등록 합니다. 

호스트 등록 

호스트 등록 및 대시 보드 작성은 zabbix 5.0 설정과 큰 차이가 없습니다. 

이전 글을 참고해서 설정 합니다. 

https://growupcoding.tistory.com/114

 

대시보드 작성 

 

유저 그룹 및 유저 생성 

  • zabbix 는 유저그룹 및 유저를 생성하여 권한을 부여할수 있습니다. 
  • 좌측 관리 매뉴를 클릭해서 유저 그룹을 생성 합니다. 
    • 유저 그룹 명을 작성 하고 권한을 선택하하고 추가 버튼을 누르면 신규 생성한 유저 그룹에 부여된 권한을 확인할수 있습니다. 
  • 좌측 관리 매뉴를 클릭해서 유저를 작성 합니다. 

 

 Zabbix 5.0 VS Zabbix 6.0 

Zabbix 6.0은 5.0 버전에 비해 성능, 보안, 사용자 인터페이스, 모니터링 기능, 자동화 및 통합 기능 등 여러 면에서 향상되었습니다. 특히, 대규모 환경에서의 성능 최적화, 클라우드 및 컨테이너 모니터링 강화, 사용자 인터페이스 개선, 보안 기능 향상 등이 주요한 차이점입니다. 이러한 개선 사항을 통해 Zabbix는 더욱 강력하고 유연한 네트워크 모니터링 솔루션이 되었습니다.

 

설치후 크게 변한 부분은 관리 매뉴 처럼 보입니다.

 

 

그리고 5.0 에서는 disk 사용하기 위해서는 템플릿을 사용 했었는데 

이제는 템플릿을 따로 등록 하지 않아도 기본적으로 확인가능한 지표들이 더 많아 진것 같습니다. 

 

결론은 Zabbix 6.0 이 5.0 보다 모니터링할 지표가  더 많이 추가 되고 사용성이 개선되었다 인것 같습니다. 

 

 

며칠전 글쓸때는 없었는데... 이제 Zabbix 7.0 도 나왔습니다. 

 

728x90
반응형

'07.Monitoring > Zabbix' 카테고리의 다른 글

[Zabbix] Zabbix 5.0 Docker 모니터링  (0) 2024.05.14
[Zabbix] Zabbix 5.0 알림 설정-Sendmail 연동  (0) 2024.05.14
[Zabbix]한글 설정  (0) 2024.04.16
[Zabbix] Centos -Zabbix 5.0 Install  (0) 2024.04.11
728x90
반응형
  • Docker 상태를 모니터링 하기 위해서는 zabbix-agent2 설치가 필요합니다. 
  • zabbix-agent2 설치를 통해 Docker 리소스를 모니터링 하는 방법에 알아봅니다. 

Agent vs agent 2 comparison

 

17 Agent vs agent 2 comparison

We greatly appreciate your contribution! Our documentation writers will review the example and consider incorporating it into the page. Please note that while we cannot provide a direct response, your input is highly valuable to us in improving our documen

www.zabbix.com

 

Zabbix 5.0 Agent2 설치

 

Download and install Zabbix

 

www.zabbix.com

Install Zabbix repository

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all

 

 Install Zabbix agent2

yum install zabbix-agent2

 

Zabbix agent2 환경 설정

  • 환경 설정 파일을 수정 합니다. 
  • Server,ListenPort 수정
vi /etc/zabbix/zabbix_agent2.conf

 

Zabbix agent2 Process Start

systemctl restart zabbix-agent2
systemctl enable zabbix-agent2
systemctl status  zabbix-agent2

 

 

Zabbix 5.0 Server 설정 

 

[Zabbix] Centos -Zabbix 5.0 Install

CentOS 7.9 환경에서 Zabbix 5.0 설치 방법에 대해 설명 합니다. 환경구성Zabbix Server 설치 (Vmware) ZAbbix Agent 리눅스(Centos 7.9)  데스크탑Zabbix 5.0 Server 설치PostgreSQL 설치 rpm -Uvh https://download.postgres

growupcoding.tistory.com

 

호스트 정보 입력 

  • 호스트명 , agent 가 설치된 서버 IP  , Agent2 Listenport 작성

 

테플릿 정보 추가 

  • Template App Docker 를 추가 합니다. 

 

Docker Data 모니터링 확인 

  • Zabbix 서버와 Zabbix Agent2 가 정상적으로 연동이 완료 되면 상태 값이 활성화 됩니다. 
  • 그래프 메뉴를 클릭하고 Oracle Docker 상태를 모니터링 합니다. 

 

대시보드 작성 

  • 대시보드에 위젯을 추가 하면 보다 부가적인 지표를 추가 모니터링 할수 있습니다. 

 

 

 

END

728x90
반응형

'07.Monitoring > Zabbix' 카테고리의 다른 글

[Zabbix] Rocky 9.4 -Zabbix 6.0 Install  (1) 2024.06.05
[Zabbix] Zabbix 5.0 알림 설정-Sendmail 연동  (0) 2024.05.14
[Zabbix]한글 설정  (0) 2024.04.16
[Zabbix] Centos -Zabbix 5.0 Install  (0) 2024.04.11
728x90
반응형

환경구성

  • Zabbix 와 리눅스 SendMail 연동 방법에 대해 소개 설명 하는 글입니다. 
  • SendMail 설치 및 환경 설정은 아래 글을 참고합니다. 
 

[SendMail] Centos7 SendMail 설치

SendMail 이란? Sendmail은 인터넷을 통해 이메일을 전송하는데 사용되는 SMTP(Simple Mail Transfer Protocol) 프로토콜을 통해 메일 서비스를 수행하며 범용 목적 인터네트워크 이메일 라우팅 기능이다. SendMa

growupcoding.tistory.com

 

Zabbix 미디어 타입 설정 

  • Zabbix 에서 알림 발생시 메일 전송을 위해서는 미디어 타입 설정이 필요 합니다. 
  • Zabbix 좌측 매뉴에서 관리 -> 미디어 타입 -> Email 설정을 클릭 합니다. 

  • 연락 방법 설정 
    • SendMail 을 설치한 서버 IP 를 작성 합니다. 
    • SMTP 포트 : SendMail 기본 사용 포트는 25 번입니다. 별도로 포트를 변경 하지 않았다면 25번으로 셋팅 합니다. 
    • 메일 주소 입력 : 유효한 Email 주소로 입력 합니다. example@test.co.kr 은 임의로 작성한 이메일 주소 입니다.  
      • 발송자 전자 우편 주소 : 보낸사람 Email 주소 입니다. 
      • 이름 : 받는 사람 Email 주소입니다. 

 

  • Message Templates 작성 
    • 메일 전송시 보낼 메일 포맷입니다. 변경 필요시 포맷을 변경합니다. 

 

  • 설정이 완료 되면 갱신 버튼을 눌러 설정 사항을 저장하고 나옵니다. 

 

Zabbix Email 발송 테스트 

  • 설정이 완료 되면  아래 화면의 우측 테스트 버튼을 눌러서 정상적으로 Zabbix와 Sendmail 연동이 잘 되는지 테스트를 진행합니다. 

 

  • 수신처, 제목 메시지를 입력 하고 테스트 버튼을 클릭합니다. 

  • 메일이 정상적으로 발송되었는지 확인 합니다. 
  • 메일이 정상적으로 수신되지 않는다면 Sendmail 로그를 확인합니다. 
    • Sendmail 설치 서버의 로그 확인 :  /var/log/maillog

 

호스트 장애 발생 알림 메일  테스트 

  • 정상 적으로 테스트가 완료 되었다면 모니터링 서버에 장애 발생 시 알림을 설정합니다. 
  • 테스트는 오라클 .Docker 컨텐이너 장애 발생 시 알림 발송 및 수신에 대한 테스트 예시입니다. 

유저 그룹 생성 

  • 보낸 사람 메일을 설정 하기 위해 유저 그룹을 설정 합니다. 
  • 장애 알림 메일 전송시 보낸 사람 주소로 사용 하게 됩니다. 
  • Zabbix 좌측 메뉴 -> 관리-> 유저 그룹을 선택한후 우측 상단의 유저그룹 작성 버튼을 클릭합니다. 

 

  • 유저 그룹 작성

  • 권한 설정
    • 쓰기가능 으로 활성화 후 모든 호스트 그룹을 등록 합니다. 

  • 갱신 버튼을 눌러 설정 값을 저장 합니다. 

 

유저 생성 

  • 알림 메일 발송 및 수신을 위해 신규 유저를 생성 합니다. 
  • 신규로 생성한 User 의 연락처로 알림 발생 메일 발신 및 수신 테스트를 진행 할 예정입니다. 
  • Zabbix 좌측 메뉴 -> 관리-> 유저 선택후 -> 우측 상단 유저 작성 버튼을 클릭합니다. 
    • 유저 기본 정보 작성

 

  • 연락처 작성

  • 권한 설정

 

 

액션 등록

  • Zabbix 좌측 매뉴에서 설정 -> 액션 메뉴를  클릭합니다.
  • 이름과 템플릿을 선택합니다. 
    • Docker 장애를 감지하기 위해 템플릿은 Template App Docker를 선택합니다. 
    • Docker 모니터링 방법에 대해서는 아래 글을 참고하세요
      • 작성 중  

 

오퍼레이션 설정 

  • 발송자는 신규로 생성한 Oracle(Group) 선택을 합니다. 
  • Send to users : 메일 수신 대상 유저를 선택합니다. 
  • 미디어 타입 선택 : Email(Html) 
  • *) Custom message 체크 박스 선택시 알림 메일 발송시 정해는 메일 제목과 내용으로만 발송 되게 됩니다. 

 

Docker Container 장애 발생 알림 테스트 

  • Docker 장애 발생시 알림이 정상 적으로 발송 되는지 확인 하기 위해 오라클 컨테이너를 중지합니다. 
  • 테스트를 위한 오라클 Docker 설치 방법은 아래 글을 참고 합니다. 
 

docker-compose 를 이용한 Oracle 19c 설치

이전에 Docker 를 활용해 Oracle19c 를 설치 하는 방법에 알아 보았습니다. 이번에는 docker-compose 를 활용해서 Oracle19c 를 설치 해보겠습니다. 설치를 위한 파일 구조 생성 이전에 소개했던 오라클19c 설

growupcoding.tistory.com

  • 아래 명령으로 컨테이너를 중지 / 시작 합니다. 
  • 기동: docker-compose -f docker-compose.ora19c.yml up -d
  • 상태 확인 docker-compose -f docker-compose.ora19c.yml ps -a
  • 정지 : docker-compose -f docker-compose.ora19c.yml  stop ora19c

 

  • Docker 장애시 Zabbix  좌측 메뉴 -> 모니터링 -> 장애 매뉴에서 장애 발생 현황을 확인할수 있습니다. 
  • 장애 발생시 액션 컬럼 내용을 통해 정상적으로 알림이 전송되었는지 확인 할수 있습니다. 

 

  • 메일 수신 확인

 

  • 메일 포멧은 미디어 타입에 설정된 포멧으로 발송 되게 됩니다.

728x90
반응형

'07.Monitoring > Zabbix' 카테고리의 다른 글

[Zabbix] Rocky 9.4 -Zabbix 6.0 Install  (1) 2024.06.05
[Zabbix] Zabbix 5.0 Docker 모니터링  (0) 2024.05.14
[Zabbix]한글 설정  (0) 2024.04.16
[Zabbix] Centos -Zabbix 5.0 Install  (0) 2024.04.11
728x90
반응형

Grafana 란? 

Grafana는 오픈 소스 데이터 시각화 및 모니터링 도구입니다. 주로 다양한 데이터 소스로부터 수집된 데이터를 시각적으로 표현하고 모니터링하는 데 하는 하는 툴입니다.  Grafana를 설치 한후  대시보드를 만들어 다양한 형식의 차트, 그래프, 지표 등을 통해 데이터를 시각화할 수 있습니다.

 

Grafana 설치 

Grafana 다운로드 

아래경로에서 바이너리를 다운로드 받습니다. 

https://grafana.com/grafana/download

 

Grafana 설치 

설치및 테스트 환경은 Centos 7.9 입니다. 

 

sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-10.4.2-1.x86_64.rpm

 

[root@mysvr ~]# sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-10.4.2-1.x86_64.rpm
Loaded plugins: fastestmirror, langpacks
grafana-enterprise-10.4.2-1.x86_64.rpm        22% [========                            ] 268 kB/s |  26 MB  00:05:34 ETA 
grafana-enterprise-10.4.2-1.x86_64.rpm                                                            | 114 MB  00:06:42     
Examining /var/tmp/yum-root-3zwBGu/grafana-enterprise-10.4.2-1.x86_64.rpm: grafana-enterprise-10.4.2-1.x86_64
Marking /var/tmp/yum-root-3zwBGu/grafana-enterprise-10.4.2-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package grafana-enterprise.x86_64 0:10.4.2-1 will be installed
--> Finished Dependency Resolution
base/7/x86_64                                                                                     | 3.6 kB  00:00:00     
centos-sclo-rh/x86_64                                                                             | 3.0 kB  00:00:00     
centos-sclo-sclo/x86_64                                                                           | 3.0 kB  00:00:00     
docker-ce-stable/7/x86_64                                                                         | 3.5 kB  00:00:00     
docker-ce-stable/7/x86_64/primary_db                                                              | 147 kB  00:00:00     
extras/7/x86_64                                                                                   | 2.9 kB  00:00:00     


Dependencies Resolved

=========================================================================================================================
 Package                      Arch             Version               Repository                                     Size
=========================================================================================================================
Installing:
 grafana-enterprise           x86_64           10.4.2-1              /grafana-enterprise-10.4.2-1.x86_64           420 M

Transaction Summary
=========================================================================================================================
Install  1 Package

Total size: 420 M
Installed size: 420 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : grafana-enterprise-10.4.2-1.x86_64                                                                    1/1 
### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
 sudo /bin/systemctl daemon-reload
 sudo /bin/systemctl enable grafana-server.service
### You can start grafana-server by executing
 sudo /bin/systemctl start grafana-server.service
POSTTRANS: Running script
  Verifying  : grafana-enterprise-10.4.2-1.x86_64                                                                    1/1 

Installed:
  grafana-enterprise.x86_64 0:10.4.2-1                                                                                   

Complete!

 

방화벽 포트 해제

  • Grafana 는 3000 번 포트를 기본으로 사용하기 때문 방화벽 포트를 해제해 준다. 
firewall-cmd --zone=public --permanent --add-port=3000/tcp
firewall-cmd --reload
firewall-cmd --zone=public --list-all

 

Grafana 실행 

#grafana 실행
systemctl start grafana-server.service

#grafana 자동 실행 등록
systemctl enable grafana-server.service

#grafana 중지
#systemctl stop grafana-server.service

#grafana 재시작
#systemctl restart grafana-server.service

 

  • grafana Listen 포트 확인

 

Grafana  접속

  • http://[IP]:3000/login
  • admin/admin 으로 접속 

728x90
반응형

'07.Monitoring > Grafana' 카테고리의 다른 글

[Grafana] Centos - Grafana + Loki + Promtail 연동  (0) 2024.06.27
728x90
반응형

Zabbix 설치 이후 한글 설정하는 방법에 대해 설명 합니다. 

Zabbix Web 한글 설정 

  • 매뉴바에서 User settings 버튼을 클릭합니다. 

 

  • 한글을 선택 합니다. 

 

Zabbix 폰트 다운로드 

  • 그래프의 지표 의 한글 항목이 깨져서 출력이 됩니다. 
  • 폰트를 다운로드 받아 한글 깨짐 현상을 해결하는 방법에 대한 설명 입니다. 
  • Zabbix 설치 시 웹 소스는 /usr/share/fonts/dejavu/ 에 위치 하게 됩니다. 
    • Roky Linux 9 버전은 /usr/share/fonts/dejavu-sans-fonts/ 입니다. 
  • 네이버에서 한글 폰트를 다운로드 받아 심볼릭 링크를 걸어 주면 한글 깨짐 현상이 해결 됩니다. 
cd /usr/share/fonts/dejavu/
wget http://cdn.naver.com/naver/NanumFont/fontfiles/NanumFont_TTF_ALL.zip

 cd /etc/alternatives/
 #기존 폰트 백업
 mv zabbix-web-font  zabbix-web-font_bak
 #심볼릭 링크 수행
 ln -s /usr/share/fonts/dejavu/NanumGothic.ttf /etc/alternatives/zabbix-web-font
 
 #Rocky Linux release 9.4 (Blue Onyx)
 ln -s /usr/share/fonts/dejavu-sans-fonts/NanumGothic.ttf /etc/alternatives/zabbix-web-font
[root@mysvr ~]# cd /usr/share/fonts/dejavu/
[root@mysvr dejavu]# wget http://cdn.naver.com/naver/NanumFont/fontfiles/NanumFont_TTF_ALL.zip
--2024-04-16 12:47:38--  http://cdn.naver.com/naver/NanumFont/fontfiles/NanumFont_TTF_ALL.zip
Resolving cdn.naver.com (cdn.naver.com)... 125.209.207.10, 183.111.124.155, 211.47.29.199
Connecting to cdn.naver.com (cdn.naver.com)|125.209.207.10|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14946146 (14M) [application/zip]
Saving to: ‘NanumFont_TTF_ALL.zip’

100%[==================================================================================================================================>] 14,946,146  54.5MB/s   in 0.3s   

2024-04-16 12:47:39 (54.5 MB/s) - ‘NanumFont_TTF_ALL.zip’ saved [14946146/14946146]

[root@mysvr dejavu]# unzip NanumFont_TTF_ALL.zip
Archive:  NanumFont_TTF_ALL.zip
  inflating: NanumBrush.ttf          
  inflating: NanumGothic.ttf         
  inflating: NanumGothicBold.ttf     
  inflating: NanumGothicExtraBold.ttf  
  inflating: NanumMyeongjo.ttf       
  inflating: NanumMyeongjoBold.ttf   
  inflating: NanumMyeongjoExtraBold.ttf  
  inflating: NanumPen.ttf
[root@mysvr dejavu]# cd /etc/alternatives/
  • 웹페이지 에서 확인하면 한글이 정상적으로 출력이 됩니다. 

728x90
반응형
728x90
반응형

리눅스 SELinux 변경 이후  리눅스 재부팅시 에러 해결 방법 

  • 부팅시 Failed to load SELinux policy, freezing. 에러 발생 

 

/etc/selinux/config   파일을 수정이후 부팅이 실패 할 경우 

[root@centos7:/root]$ cat  /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
[root@centos7:/root]$

 

  • 부팅 화면에서 키보드 e 를 누르고 

  • selinux=0 추가 후 재부팅
  • Ctrl + x  를 누르면 다시 부팅이 된다. 

 

 

SELinux 란? 

SELinux(보안 강화 리눅스)는 리눅스 운영 체제의 보안 기능 중 하나로, 프로세스, 파일 및 네트워크에 대한 접근을 제어하는 매커니즘입니다. SELinux는 NSA(미국 국가 안보국)와 레드햇이 공동으로 개발한 프로젝트로, 리눅스 커널에 포함되어 있습니다.

 

  • /etc/selinux/config 파라미터 설명 
    • enforcing 모드: 모든 SELinux 정책이 적용되고 보안 위반이 감지되면 해당 작업이 차단됩니다.
    • permissive 모드: SELinux는 로그를 기록하지만 작업을 차단하지는 않습니다.
    • disabled 모드: SELinux가 완전히 비활성화됩니다.
728x90
반응형
728x90
반응형
  • CentOS 7.9 환경에서 Zabbix 5.0 설치 방법에 대해 설명 합니다. 

환경구성

  • Zabbix Server 설치 (Vmware) 
  • ZAbbix Agent 리눅스(Centos 7.9)  데스크탑

Zabbix 5.0 Server 설치

PostgreSQL 설치 

rpm -Uvh https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum -y install postgresql12-server postgresql12-contrib
/usr/pgsql-12/bin/postgresql-12-setup initdb

 

  • PostgreSQL 환경 설정 
    • vi /var/lib/pgsql/12/data/postgresql.conf 
#listen_addresses = 'localhost' # what IP address(es) to listen on;
listen_addresses = '*'
  • vi /var/lib/pgsql/12/data/pg_hba.conf 
vi /var/lib/pgsql/12/data/pg_hba.conf    
#추가 
host    all             postgres        0.0.0.0/0               trust

 

  • PostgreSQL 기동
systemctl restart postgresql-12
systemctl enable postgresql-12

 

  • PostgreSQL Zabbix Metadata Create 
sudo -u postgres createuser --pwprompt zabbix

sudo -u postgres createdb -O zabbix zabbix

zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix

Zabbix 5.0 sever 설치 

https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&components=server_frontend_agent&db=pgsql&ws=apache

 

Download and install Zabbix

 

www.zabbix.com

  •  Install Zabbix repository & Install Zabbix server, frontend, agent
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

yum clean all
yum install zabbix-server-pgsql zabbix-agent
yum install centos-release-scl

 

  •  /etc/yum.repos.d/zabbix.repo 수정
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

 

  • Zabbix frontend packages 설치
yum install zabbix-web-pgsql-scl zabbix-apache-conf-scl
  • /etc/zabbix/zabbix_server.conf DBPassword 수정
vi /etc/zabbix/zabbix_server.conf

  • PHP for Zabbix frontend 설정 파일 수정 
vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Seoul

 

  •  Zabbix server and agent 시작 
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

# zabbix 중지 
#systemctl stop zabbix-server zabbix-agent httpd rh-php72-php-fpm
  • SELinux httpd 활성화
setsebool -P httpd_can_connect_zabbix on
setsebool -P httpd_can_network_connect_db on

setsebool -P zabbix_can_network on
service httpd restart

 

  • zabbix 로그 확인
tail -f /var/log/zabbix/zabbix_server.log

Zabbix Web 연결 설정

정상적으로 설치가 완료 되면 zabbix 웹 에 접속 하여 추가 환경 설정을 셋팅 한다.

접속  Url 은 http://[서버ip]/zabbix/ 이다 

  • Zabbix 접속 화면 

  •  zabbix install 정보 확인 

  • PostgreSQL 접속 정보 셋팅 

  • Zabbix 서버 접속 정보 설정

  • Zabbix 셋팅 정보 요약

Zabbix 설치 완료

  • /etc/zabbix/web/zabbix.conf.php

 

  • 설치가 완료되면 Zabbix 웹 페이지에 접속 해서 모니터링 셋팅을 진행 한다. 
  • 최초 접속 비밀 번호는 Admin/zabbix 이다 .

  • 로그인 후 DashBord 화면 

 

Zabbix 5.0 모니터링 설정 

  • 정상적으로 설치 및 셋팅이 완료 되었다면 Zabbix 가 설치된 리눅스 서버의 리소스를 모니터링 할수 있다 
  • Monitoring -> Hosts -> Zabbix server -> Graphs 

  • 조회기간 변경 검색 조회

 

 

Zabbix 5.0 Agent 설치

  • 원격 서버의 시스템 자원을 모니터링하기 위해 agent 를 설치하는 방법에 대한 설명한다.

Zabbix repository  및 Agent 설치 

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all

yum install zabbix-agent

 

Zabbix Agent Config 수정

vi /etc/zabbix/zabbix_agentd.conf

 

  • Zabbix Server IP  수정 
  • Zabbix  Agent Port 설정 
### Option: Server
#       List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
#       Incoming connections will be accepted only from the hosts listed here.
#       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
#       and '::/0' will allow any IPv4 or IPv6 address.
#       '0.0.0.0/0' can be used to allow any IPv4 address.
#       Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=

Server=192.168.116.200

### Option: ListenPort
#       Agent will listen on this port for connections from the server.
#
# Mandatory: no
# Range: 1024-32767
# Default:
ListenPort=10050

 

Zabbix Agent 재시작 

systemctl restart zabbix-agent 
systemctl enable zabbix-agent
systemctl status zabbix-agent

 

Zabbix  Web Host 추가 

  • 모니터링할 서버에 Zabbix Agent 를 성공적으로 설치 완료 하였다면 Zabbix Webpage 에 접속하여 
  • 호스트를 작성하여 설치한 리모트 서버의 Zabbix Agent 를 등록해 줍니다. 

 

  • Host name : 모티너링 대상 서버 별칭 
  • Agent : Zabbix Agent 를 설치한 서버 IP 
  • Port : Zabbix Agent Port (default : 10050)

  • 템플릿-> Template OS Linux by Zabbix agent 선택

 

  • 정상적으로  호스트 등록이 완료 되면 ZBX 박스가 녹색으로 표시된다.

 

 

Zabbix  Web DashBord 설정

  • Zabbix 기능중에는 Dash Bord 작성기능이 있습니다. 
  • 원하는 지표를 사용자 정의에 따라 구성하여 모니터링을 할수 있습니다. 
  • 신규로 DashBoard 를 생성 하고 원하는 위젯을 추가 하여 원하는 지표를 생성 합니다. 
  • 매뉴-> 대시보드 ->대시보드 작성 클릭 

 

 

  • DashBoard 구성이 완료 되면 변경사항 저장합니다. 

 

Zabbix  Agent Disk 사용량 항목 추가 

  • Zabbix Agent를 설치시 Disk 모니터링 지표는 기본적으로 설치 되지 않습니다. 
  • Template Import 기능을 사용해서 Disk 부가 정보를 모니터링 하기위한 지표를 추가 합니다. 

Disk 지표 추가 관련 설정 

mkdir -p /etc/zabbix/zabbix_agentd.d/
wget https://raw.githubusercontent.com/grundic/zabbix-disk-performance/master/userparameter_diskstats.conf -O /etc/zabbix/zabbix_agentd.d/userparameter_diskstats.conf

# Scripts download 
wget https://raw.githubusercontent.com/grundic/zabbix-disk-performance/master/lld-disks.py -O /usr/local/bin/lld-disks.py
chmod +x /usr/local/bin/lld-disks.py

 

Disk 지표 템플릿 파일 다운로드

Template Disk Performance.xml
0.05MB

 

  • 매뉴 -> 설정 -> 템플릿 ->가져오기 클릭후 다운로드 받은 템플릿을 Import 시켜 줍니다. 

  • 앞서 등록한 호스트 정보 클릭 후 추가한 Templage Disk Performance 를 추가 합니다. 

 

  • Disk 관련 정보가 보이지 않는다면 Host 그룹에 Zabbix Sservers 도 추가 합니다.

 

  • Disk 지표가 추가 작업이 정상적으로 완료 되었다면 원형 그래프로 디스크 사용량을 확인할수 있습니다. 

728x90
반응형
728x90
반응형

NFS 란? 

NFS(Network File System)는 여러 컴퓨터 간에 파일을 공유하기 위한 분산 파일 시스템 프로토콜입니다. NFS는 클라이언트-서버 모델을 기반으로 하며, 클라이언트는 네트워크를 통해 NFS 서버의 파일 시스템에 액세스할 수 있습니다. 이를 통해 여러 사용자가 동일한 파일이나 디렉터리를 공유하고, 파일 시스템 자원을 효율적으로 활용할 수 있습니다.

 

NFS 동작 원리

  1. 서버 설정: 먼저 파일을 공유할 서버에서 NFS를 설정해야 합니다. 서버의 파일 시스템 중 NFS로 공유하고자 하는 디렉터리를 선택하고, 이 디렉터리를 /etc/exports와 같은 설정 파일에 등록합니다. 이 설정 파일은 클라이언트에게 공유 디렉터리의 경로와 액세스 권한을 제공합니다.
  2. 클라이언트 마운트: NFS 클라이언트에서는 NFS 서버의 공유 디렉터리를 마운트하여 사용할 수 있습니다. 클라이언트에서는 NFS 마운트 포인트를 생성하고, 이를 통해 서버의 공유된 디렉터리에 액세스할 수 있습니다.

 

NFS 동작 원리

  1. 파일 공유: NFS는 여러 사용자가 동일한 파일이나 디렉터리를 공유할 수 있도록 합니다. 이를 통해 여러 사용자가 동일한 파일에 접근하여 작업할 수 있습니다.
  2. 중앙 관리: NFS를 사용하면 파일이 중앙 서버에 저장되므로 관리 및 유지 보수가 간단해집니다. 파일의 한 복사본을 유지하므로 데이터 일관성도 쉽게 유지할 수 있습니다.
  3. 데이터 백업: NFS를 사용하여 클라이언트에서 중앙 서버로 데이터를 백업할 수 있습니다. 이를 통해 중앙화된 백업 시스템을 유지하고, 데이터를 보호할 수 있습니다.
  4. 클라우드 스토리지: 클라우드 환경에서도 NFS는 파일 공유 및 저장에 널리 사용됩니다. 클라우드에서 NFS를 사용하면 여러 가상 머신 간에 데이터를 공유하고, 파일 시스템을 유연하게 확장할 수 있습니다.

 

NFS  서버 설치 

centos 7.9 환경에서 NFS 설치 하는 방법에 대해 알아보겠습습니다. 

 

nfs 패키지 설치 

#설치 유무 확인
rpm -qa | grep nfs-utils

#nfs 팩키지 설치 
yum install nfs-utils

 

서비스 시작 

systemctl enable nfs-server
systemctl start nfs-server

 

서비스 상태 확인 

[root@mysvr:/root]$ systemctl status nfs-server
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
   Active: active (exited) since 화 2024-03-12 16:20:39 KST; 23s ago
  Process: 2523 ExecStartPost=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=exited, status=0/SUCCESS)
  Process: 2506 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 2504 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 2506 (code=exited, status=0/SUCCESS)
    Tasks: 0
   CGroup: /system.slice/nfs-server.service

 3월 12 16:20:39 mysvr systemd[1]: Starting NFS server and services...
 3월 12 16:20:39 mysvr systemd[1]: Started NFS server and services.

 

마운트 디렉토리 생성 

mkdir share_disk

chmod 777 /share_disk

 

마운트 설정

  • /etc/exports 파일 수정 및 적용 
  • 수정된 파일 내용 적용: exportfs -r 
/share_disk 192.168.116.*(rw,no_root_squash,sync)

 

  • /share_disk: 공유할 디렉터리의 경로입니다.
  • *: 모든 클라이언트에게 액세스를 허용함을 나타냅니다.
  • rw: 읽기 및 쓰기 액세스를 허용하는 옵션입니다.
  • sync: 변경 사항을 디스크에 즉시 동기화하는 옵션입니다.
  • no_root_squash: 클라이언트의 root 사용자가 파일에 액세스할 때 해당 사용자를 시스템의 root로 매핑하지 않음을 나타내는 옵션입니다.
  • async: 변경 사항을 비동기적으로 디스크에 동기화합니다.
  • no_root_squash: 클라이언트의 root 사용자를 서버의 root 사용자로 매핑하지 않습니다.
  • root_squash: 클라이언트의 root 사용자를 서버의 nfsnobody 사용자로 매핑합니다.
  • all_squash: 모든 사용자를 서버의 nfsnobody 사용자로 매핑합니다.

적용된 마운트 설정 확인

showmount -e
exportfs -v

NFS 클라이언트 설정

 

마운트 디렉토리 생성 

 mkdir nfs_share_disk
 chmod 777 nfs_share_disk

 

NFS 설치 

#설치 유무 확인
rpm -qa | grep nfs-utils

#nfs 팩키지 설치 
yum install nfs-utils

#서비스 시작 
systemctl enable nfs-server
systemctl start nfs-server

 

마운트

mount -t nfs 192.168.116.10:/share_disk /nfs_share_disk

 

[root@mysvr:/root]$ df -Th
Filesystem                 Type      Size  Used Avail Use% Mounted on
devtmpfs                   devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs                      tmpfs     1.9G     0  1.9G   0% /dev/shm
tmpfs                      tmpfs     1.9G   13M  1.9G   1% /run
tmpfs                      tmpfs     1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root    xfs        26G  6.3G   20G  25% /
/dev/sda1                  xfs      1014M  185M  830M  19% /boot
/dev/mapper/centos-home    ext2       25G   15G  9.3G  61% /home
tmpfs                      tmpfs     378M   12K  378M   1% /run/user/42
tmpfs                      tmpfs     378M     0  378M   0% /run/user/0
192.168.116.10:/share_disk nfs4       26G  6.5G   20G  25% /nfs_share_disk

 

마운트 영구 적용 (/etc/fstab)

192.168.116.10:/share_disk /nfs_share_disk nfs rw,noatime,sync 0 0

 

  • 마운트 사용 정의는 아래와 같습니다. 
<device> <mount_point> <filesystem_type> <mount_options> <dump> <pass>

 

  • <device>: 마운트할 디바이스의 경로 또는 UUID입니다. 이것은 보통 디스크 파티션 또는 네트워크 파일 시스템의 주소입니다.
  • <mount_point>: 디바이스가 마운트될 디렉터리의 경로입니다.
  • <filesystem_type>: 파일 시스템의 종류를 나타냅니다. 예를 들어, ext4, nfs, ntfs 등이 있습니다.
  • <mount_options>: 마운트 옵션을 나타냅니다. 읽기 전용으로 마운트할지 읽기/쓰기로 마운트할지 등을 정의할 수 있습니다. 
      1. rw / ro:
        • rw: 읽기/쓰기 모드로 파일 시스템을 마운트합니다.
        • ro: 읽기 전용 모드로 파일 시스템을 마운트합니다.
      2. auto / noauto:
        • auto: 부팅 시 자동으로 마운트됩니다.
        • noauto: 수동으로 마운트해야 합니다. 부팅 시 자동으로 마운트되지 않습니다.
      3. exec / noexec:
        • exec: 이 파일 시스템에서 바이너리 실행 파일을 실행할 수 있습니다.
        • noexec: 이 파일 시스템에서 바이너리 실행 파일을 실행할 수 없습니다.
      4. user / nouser:
        • user: 일반 사용자도 마운트 및 언마운트를 할 수 있습니다.
        • nouser: 일반 사용자는 마운트 및 언마운트를 할 수 없습니다. 관리자 권한이 필요합니다.
      5. sync / async:
        • sync: 변경 사항을 디스크에 즉시 동기화합니다. 안정성을 높이지만 성능이 저하될 수 있습니다.
        • async: 변경 사항을 비동기적으로 디스크에 동기화합니다. 성능을 높이지만 안정성이 낮아질 수 있습니다.
      6. defaults: 기본 마운트 옵션을 사용합니다. 일반적으로 rw, suid, dev, exec, auto, nouser, async와 같은 옵션을 포함합니다.
      7. uid, gid: 특정 사용자 ID 또는 그룹 ID에 속하는 사용자 또는 그룹에 대해 마운트된 파일 시스템을 마운트합니다.
      8. umask, dmask, fmask: 마운트된 디렉터리 또는 파일에 대한 권한 마스크를 설정합니다.
      9. noatime, relatime, strictatime: 파일 시스템에 대한 액세스 시간을 변경하는 옵션입니다. 성능을 높이기 위해 noatime을 사용할 수 있습니다.
      10. noacl, acl: Access Control Lists (ACL)를 사용할지 여부를 지정합니다.
  • <dump>: 백업 프로그램이 시스템을 백업할 때 이 파일 시스템을 백업해야 하는지 여부를 나타냅니다. 일반적으로 0으로 설정되어 있습니다.
  • <pass>: 시스템 부팅 시 파일 시스템을 체크해야 하는 순서를 나타냅니다. 일반적으로 1로 설정되어 있습니다.

 

NFS 연동 테스트 

  • 각 nfs 설치된 서버에서 파일을 생성하면 어떤 노드에서도 생성하더라도 파일을 공유할수 있게된다.

728x90
반응형

+ Recent posts