웹사이트 검색

CentOS 7에서 Icinga 2 및 Icingaweb 2로 서버 모니터링


이 페이지에서

  1. 1. 요구 사항\n
  2. 2. 서문
  3. 3. 준비
    1. 네트워크 연결 확인\n
    2. 루트로 변경
    3. 예비 소프트웨어 설치\n
    4. SELinux 비활성화\n
    5. 시스템 업데이트 및 재부팅

    1. 추가 저장소 설치
    2. Apache, php 설치 및 php.ini 준비
    3. mariadb 설치 및 구성
    4. icinga2용 데이터베이스 생성 및 채우기
    5. ido-mysql.conf 수정
    6. 시작 시 icinga2 활성화 및 시작\n

    Icinga 2는 확장 가능한 OpenSource 모니터링 소프트웨어입니다. 이 튜토리얼은 Icinga 2를 Icingaweb과 함께 CentOS 7 서버에 설치하는 방법을 설명합니다.

    1. 요건

    이러한 시스템을 설치하려면 다음이 필요합니다.

    • Centos 7 최소 서버 시스템. 이는 Centos 7.1 최소 서버 자습서에 설명된 대로 처음부터 새로 설치한 서버이거나 최소 Centos 7 설정이 설치된 호스팅 회사의 가상 서버 또는 루트 서버일 수 있습니다.\n
    • 빠른 인터넷 연결.

    2. 서문

    • 이 튜토리얼에서는 IP 주소가 192.168.250.100/24이고 게이트웨이가 192.168.250.254인 호스트 이름 icinga2.domain.tld를 사용합니다. 이러한 설정은 사용자에 따라 다를 수 있으므로 적절하게 교체해야 합니다.\n
    • 여기에 표시된 출력은 예시일 뿐이며 기본 시스템 및 이미 설치된 패키지에 따라 시스템에 따라 다를 수 있습니다.\n
    • 데이터베이스 서버는 maria db이며 동일한 호스트에 설치됩니다.\n
    • 사용자 관리자가 존재하고 sudoers 목록에 있습니다.\n
    • 이 자습서에서는 SELinux를 비활성화합니다.\n

    3. 준비

    관리자로 로그인

    login as: administrator
    's password:
    [ ~]$

    네트워크 연결 확인

    인터넷 연결이 설정되고 이름 확인이 작동하는지 테스트합니다.

    ping www.google.de -c3

    출력은 다음과 같습니다.

    [ ~]$ ping www.google.de -c3
    PING www.google.de (172.217.20.67) 56(84) bytes of data.
    64 bytes from fra02s27-in-f3.1e100.net (172.217.20.67): icmp_seq=1 ttl=57 time=19.2 ms
    64 bytes from fra02s27-in-f3.1e100.net (172.217.20.67): icmp_seq=2 ttl=57 time=19.3 ms
    64 bytes from fra02s27-in-f3.1e100.net (172.217.20.67): icmp_seq=3 ttl=57 time=19.6 ms
    
    --- www.google.de ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2001ms
    rtt min/avg/max/mdev = 19.276/19.430/19.649/0.195 ms
    [ ~]$
    

    루트로 변경

    이제 우리는 뿌리를 내릴 것입니다. 이렇게 하려면 다음을 입력하십시오.

    sudo su

    출력은 다음과 같습니다.

    [ ~]$ sudo su
    
    We trust you have received the usual lecture from the local System
    Administrator. It usually boils down to these three things:
    
             #1) Respect the privacy of others.
             #2) Think before you type.
             #3) With great power comes great responsibility.
    
    [sudo] password for administrator:
    [ administrator]#

    예비 소프트웨어 설치

    이제 몇 가지 예비 소프트웨어를 설치합니다.

    • deltarpm은 전체 패키지 대신 차등 파일만 있는지 확인하여 다운로드할 양을 줄입니다.\n
    • nano는 텍스트 편집기입니다.
    • URL에서 파일을 다운로드하려면 wget이 필요합니다.\n
    • net-tools는 네트워크 프로세스에 대한 특정 검사에 필요합니다.\n
    • gcc는 GNU 컴파일러입니다.

    yum -y install deltarpm

    출력은 다음과 같습니다.

    Loaded plugins: fastestmirror
    base                                                                             | 3.6 kB  00:00:00
    extras                                                                           | 3.4 kB  00:00:00
    updates                                                                          | 3.4 kB  00:00:00
    (1/4): extras/7/x86_64/primary_db
    ...
    ...
    Total download size: 82 k
    Installed size: 209 k
    Downloading packages:
    warning: /var/cache/yum/x86_64/7/base/packages/deltarpm-3.6-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
    Public key for deltarpm-3.6-3.el7.x86_64.rpm is not installed
    deltarpm-3.6-3.el7.x86_64.rpm                                                    |  82 kB  00:00:00
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    Importing GPG key 0xF4A80EB5:
     Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <>"
     Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
     Package    : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@anaconda)
     From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : deltarpm-3.6-3.el7.x86_64                                                            1/1
      Verifying  : deltarpm-3.6-3.el7.x86_64                                                            1/1
    
    Installed:
      deltarpm.x86_64 0:3.6-3.el7
    
    Complete!
    
    yum -y install nano wget net-tools gcc

    출력은 다음과 같습니다.

    Loaded plugins: fastestmirror
    base                                                                             | 3.6 kB  00:00:00
    extras                                                                           | 3.4 kB  00:00:00
    updates                                                                          | 3.4 kB  00:00:00
    (1/4): extras/7/x86_64/primary_db
    ...
    ...
    Installed:
      gcc.x86_64 0:4.8.5-4.el7      nano.x86_64 0:2.3.1-10.el7 net-tools.x86_64 0:2.0-0.17.20131004git.el7
      wget.x86_64 0:1.14-10.el7_0.1
    
    Dependency Installed:
      cpp.x86_64 0:4.8.5-4.el7                         glibc-devel.x86_64 0:2.17-106.el7_2.4
      glibc-headers.x86_64 0:2.17-106.el7_2.4          kernel-headers.x86_64 0:3.10.0-327.13.1.el7
      libmpc.x86_64 0:1.0.1-3.el7                      mpfr.x86_64 0:3.1.1-4.el7
    
    Dependency Updated:
      glibc.x86_64 0:2.17-106.el7_2.4                 glibc-common.x86_64 0:2.17-106.el7_2.4
    
    Complete!
    

    SELinux 비활성화

    /etc/selinux/config 편집

    nano /etc/selinux/config

    찾다

    SELINUX=enforcing

    로 변경

    SELINUX=disabled

    파일 저장

    시스템 업데이트 및 재부팅

    이제 시스템을 업데이트하겠습니다.

    yum -y update && yum -y upgrade

    다소 시간이 걸릴 수 있습니다. 재부팅 후.

    reboot

    4. icinga2 및 추가 소프트웨어 설치

    추가 저장소 설치

    시스템이 다시 시작된 후 관리자로 로그인하고 자신을 다시 루트로 만드십시오.

    디렉토리를 /tmp로 변경

    cd /tmp

    epel 저장소 설치

    yum install -y epel-release

    icinga 저장소 설치

    rpm --import http://packages.icinga.org/icinga.key
    wget http://packages.icinga.org/epel/ICINGA-release.repo -O /etc/yum.repos.d/ICINGA-release.repo

    yum 캐시 재구축(시간이 걸릴 수 있음)

    yum makecache

    icinga2, icinga2 mysql 커넥터 및 nagios 플러그인 설치

    yum install -y nagios-plugins-all icinga2 icinga2-ido-mysql icinga-idoutils-libdbi-mysql

    Apache, php 설치 및 php.ini 준비

    yum install -y httpd
    yum install -y php-cli php-pear php-xmlrpc php-xsl php-pdo php-soap php-gd php-ldap

    php.ini 편집

    찾다

    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    ;date.timezone =
    

    로 변경

    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    date.timezone = "Europe/Berlin"
    

    파일 저장

    시작할 때 Apache 활성화

    systemctl enable httpd
    [ tmp]# systemctl enable httpd
    Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
    systemctl start httpd

    Apache가 실행 중인지 확인

    netstat -nlp | grep 80
    [ tmp]# netstat -nlp | grep 80
    tcp6       0      0 :::80                   :::*                    LISTEN      10360/httpd

    mariadb 설치 및 구성

    yum install -y mariadb-server
    systemctl start mariadb
    systemctl enable mariadb

    산출:

    [ tmp]# systemctl enable mariadb
    Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

    mariadb가 실행 중인지 확인

    netstat -nlp | grep 3306

    산출:

    [ tmp]# netstat -nlp | grep 3306
    tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      11623/mysqld
    

    사용자 루트의 비밀번호 설정

    mysql -u root

    산출:

    [ tmp]# mysql -u root
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2
    Server version: 5.5.47-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]>
    
    [MariaDB [(none)]> use mysql

    산출:

    [MariaDB [(none)]> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    MariaDB [mysql]>
    
    [MariaDB [(mysql)]> update user set password=PASSWORD("root_password") where User='root';

    산출:

    update user set password=PASSWORD("root_password") where User='root';
    Query OK, 4 rows affected (0.00 sec)
    Rows matched: 4  Changed: 4  Warnings: 0
    
    [MariaDB [(mysql)]> flush privileges;

    산출:

    MariaDB [mysql]> flush privileges;
    Query OK, 0 rows affected (0.00 sec0
    
    [MariaDB [(mysql)]> exit;

    산출:

    MariaDB [mysql]> exit;
    Bye
    

    마리아DB 재시작

    systemctl restart mariadb

    icinga2용 데이터베이스 생성 및 채우기

    루트 비밀번호를 사용하여 MySQL에 로그온합니다.

    mysql -u root -p

    산출:

    [ tmp]# mysql -u root -p
    Enter password:
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 7
    Server version: 5.5.47-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]>
    
    [MariaDB [(none)]>CREATE DATABASE icinga2;

    산출:

    MariaDB [(none)]> CREATE DATABASE icinga2;
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]>
    
    [MariaDB [(none)]>GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga2.* TO 'icinga2'@'localhost' IDENTIFIED BY 'icinga2_password';

    산출:

    MariaDB [(none)]> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga2.* TO 'icinga2'@'localhost' IDENTIFIED BY 'icinga2_password';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]>
    
    [MariaDB [(none)]>flush privileges;;

    산출:

    MariaDB [(none)]> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]>
    
    [MariaDB [(none)]> exit;

    산출:

    MariaDB [none]> exit;
    Bye
    

    데이터베이스 채우기

    mysql -u root -p icinga2 < /usr/share/icinga2-ido-mysql/schema/mysql.sql

    ido-mysql.conf 수정

    icinga2를 mariadb 데이터베이스에 연결하려면 /etc/icinga2/ido-mysql.conf를 수정해야 합니다.

    nano /etc/icinga2/features-available/ido-mysql.conf

    찾다

    /**
     * The db_ido_mysql library implements IDO functionality
     * for MySQL.
     */
    
    library "db_ido_mysql"
    
    object IdoMysqlConnection "ido-mysql" {
      //user = "icinga"
      //password = "icinga"
      //host = "localhost"
      //database = "icinga"
    }
    

    로 변경

    /**
     * The db_ido_mysql library implements IDO functionality
     * for MySQL.
     */
    
    library "db_ido_mysql"
    
    object IdoMysqlConnection "ido-mysql" {
      user = "icinga2"
      password = "icinga2_password"
      host = "localhost"
      database = "icinga2"
    }
    

    시작 시 icinga2 활성화 및 시작

    시작 시 icinga2 활성화

    systemctl enable icinga2

    산출:

    [ tmp]# systemctl enable icinga2
    Created symlink from /etc/systemd/system/multi-user.target.wants/icinga2.service to /usr/lib/systemd/system/icinga2.service.
    

    icinga2 시작

    systemctl start icinga2

    모든 것이 작동하는지 확인하기 위해 tail -f /var/log/icinga2/icinga2.log를 수행합니다. CTRL-C를 눌러 출력을 중지할 수 있습니다.

    tail -f /var/log/icinga2/icinga2.log

    출력은 다음과 같아야 합니다.

    [ tmp]# tail -f /var/log/icinga2/icinga2.log
    [2016-05-10 23:21:50 +0200] information/DbConnection: Resuming IDO connection: ido-mysql
    [2016-05-10 23:21:50 +0200] information/ConfigItem: Activated all objects.
    [2016-05-10 23:21:50 +0200] information/ConfigCompiler: Compiling config file: /var/lib/icinga2/modified-attributes.conf
    [2016-05-10 23:21:50 +0200] information/IdoMysqlConnection: MySQL IDO instance id: 1 (schema version: '1.14.0')
    [2016-05-10 23:21:50 +0200] information/IdoMysqlConnection: Finished reconnecting to MySQL IDO database in 0.201981 second(s).
    

    부팅 시 icinga2를 시작하도록 설정:

    systemctl enable icinga2

    산출:

    [ tmp]# systemctl enable icinga2
    Created symlink from /etc/systemd/system/multi-user.target.wants/icinga2.service to /usr/lib/systemd/system/icinga2.service.
    

    icinga2 명령 모듈 활성화:

    icinga2 feature enable command

    산출:

    [ tmp]# icinga2 feature enable command
    Enabling feature command. Make sure to restart Icinga 2 for these changes to take effect.
    

    icinga2 다시 시작

    systemctl restart icinga2