본문 바로가기
모니터링/LibreNMS

Centos - LibreNMS 설치 하기 :: 모니터링 서비스

by bigju 2022. 1. 5.

 

 

설치 환경

OS: Centos 7.9

TOOL : VMware

DB : MariaDB


모니터링이 가능한 프로그램 LibreNMS 설치 입니다.

설치 순서는 여러 경우로 해봤으나 해당 순서가 가장 최적화되었다고 생각해 정리했습니다.

 


1. MariaDB 설치

 

1-1. respo 작성

vi /etc/yum.repos.d/MariaDB.repo

↓ 아래 내용 작성 ↓ 

# MariaDB 10.2 CentOS repository list - created 2018-01-11 07:40 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
 

*LibreNMS는 Mariadb 10.2 이상 지원합니다.

그러므로 최소 10.2 설치를 위해 respo 작성 하였습니다.

 

2-2. 설치

yum install epel-release yum-utils  -y


yum install mariadb mariadb-server  -y

*오류 발생!
GPG key retrieval failed: [Errno 14] curl#60 - "Peer's Certificate has expired."
-> rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB
 

 


2. 패키지 설치

 
yum localinstall http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y

yum-config-manager --enable remi-php73 -y

yum install composer cronie fping git ImageMagick jwhois mtr MySQL-python net-snmp net-snmp-utils nginx nmap php-fpm php-cli php-common php-curl php-pear php-gd php-mbstring php-process gcc php-snmp php-xml php-zip php-memcached php-mysqlnd python-memcached rrdtool python3 python3-pip -y

yum -y install python3-devel.x86_64
 

3. MariaDB 설정

 

3-1. MariaDB 시작

systemctl start mariadb
 

3-2 패스워드 설정

 mysql_secure_installation

 엔터 -> y ->패스워드 입력 -> y -> y -> y -> y 
 

3-3. Database 및 User 설정

mysql -u root -p

CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE USER 'librenms'@'localhost' IDENTIFIED BY '패스워드 설정';

GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';

FLUSH PRIVILEGES;

exit
 

 

4. LibreNMS 다운로드 및 설정

/opt 에서 진행

4-1 유저 생성 및 설정

useradd librenms -d /opt/librenms -M -r

usermod -a -G librenms nginx
 

4-2 LibreNMS 다운로드

cd /opt/

git clone https://github.com/librenms/librenms.git librenms
 

4-3 디렉토리 설정 및 권한 수정

chown -R librenms:librenms /opt/librenms

chmod 770 /opt/librenms

setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

chgrp apache /var/lib/php/session/
 

5. PHP Dependencies 설치

5-1 . 설치

su - librenms

./scripts/composer_wrapper.php install --no-dev

exit
 

*gcc 에러 발생

-> yum -y install python3-devel.x86_64 설치


 

6. 저장소 확장

PEAR 저장소를 업데이트하고 PEAR (PHP Extension 및 Application Repository) 확장을 설치합니다

6-1 확장

pear channel-update pear.php.net

pear install Net_IPv4-1.3.4

pear install Net_IPv6-1.2.2b2
 

7. PHP-FPM 설정

 

7-1. php.ini 수정

vi /etc/php.ini

 
797 ;cgi.fix_pathinfo=0
--> cgi.fix_pathinfo=1

922 ;date.timezone =
--> date.timezone = Asia/Seoul

:wq
 

7-2. www.conf 수정

vi /etc/php-fpm.d/www.conf

user = apache
-> user = nginx

listen = 127.0.0.1:9000
-> listen = /var/run/php-fpm/php7.3-fpm.sock


;listen.owner = nobody
--> listen.owner = nginx

;listen.group = nobody
--> listen.group = nginx

;listen.mode = 0660
--> listen.mode = 0660

:wq
 

7-3 php-fpm 재시작

systemctl restart php-fpm

 

8. selinux 설치

 

8-1 설치

yum install policycoreutils-python -y
 

8-2. 설정

semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/logs(/.*)?'

semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/logs(/.*)?'

restorecon -RFvv /opt/librenms/logs/

semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/rrd(/.*)?'

semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/rrd(/.*)?'

restorecon -RFvv /opt/librenms/rrd/

semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/storage(/.*)?'

semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/storage(/.*)?'

restorecon -RFvv /opt/librenms/storage/

semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/bootstrap/cache(/.*)?'

semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/bootstrap/cache(/.*)?'

restorecon -RFvv /opt/librenms/bootstrap/cache/

setsebool -P httpd_can_sendmail=1

setsebool -P httpd_execmem 1

 

 

 

9. LibreNMS 가상 호스트 구성

 

9-1. librenms.conf 생성

vi /etc/nginx/conf.d/librenms.conf


server {
 listen      80;
 server_name 서버IP;
 root        /opt/librenms/html;
 index       index.php;

 charset utf-8;
 gzip on;
 gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
 location / {
  try_files $uri $uri/ /index.php?$query_string;
 }
 location /api/v0 {
  try_files $uri $uri/ /api_v0.php?$query_string;
 }
 location ~ \.php {
  include fastcgi.conf;
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass unix:/run/php-fpm/php7.3-fpm.sock;
 }
 location ~ /\.ht {
  deny all;
 }
}


:wq
 

9-2. nginx 테스트

nginx -t
 

 

9-3 nginx 재시작

systemctl restart nginx
 

 

10. firewalld 설정

 

10-1. 설치 및 시작

yum -y install firewalld

systemctl start firewalld

systemctl enable firewalld
 

10-2 정책 설정

firewall-cmd --zone public --add-service http

firewall-cmd --permanent --zone public --add-service http

firewall-cmd --zone public --add-service https

firewall-cmd --permanent --zone public --add-service https
 

11. 최종 확인

11-1. 접속

http:/IP
 

 


Big Ju
LibreNMS 설치 1

 

댓글

메인으로가기


    

Big Ju

IT Engineer


항상 답을 위해 노력하는

엔지니어입니다.

 

 

    


 UP!