Centos 7 安裝 icinga2

來源:互聯網
上載者:User

標籤:

1.   通過 yum 安裝icinga2  核心包

a)     Package Repositories

# rpm --import  http://packages.icinga.org/icinga.key

# curl -o/etc/yum.repos.d/ICINGA-release.repohttp://packages.icinga.org/fedora/ICINGA-release.repo

# yum makecache

b)    Installing Icinga 2

# yum install icinga2

# systemctl enable icinga2

# systemctl start icinga2

c)     Enabled Features during Installation

# icinga2 feature list

顯示內容分為Disabled和Eabled 2個部分

Disabledfeatures: api command compatlog debuglog graphite icingastatus ido-mysqlido-pgsql livestatus notification perfdata statusdata syslog

Enabled features: checker mainlognotification

2. 安裝nagios-plugins-all

a)       安裝EPEL
EPEL,即Extra Packages for Enterprise Linux的簡稱,是為企業級Linux提供的一組高品質的額外軟體包,包括但不限於Red Hat EnterpriseLinux (RHEL), 

# yum -y install epel-release

# yum clean all && yum makecache

# yum install nagios-plugins-all –y
檢查
/usr/lib/nagios/plugins or/usr/lib64/nagios/plugins 目錄下,是否有相應的 plugin檔案

3. 運行icinga2

$ systemctl status icinga2

$ systemctl enable icinga2

$ systemctl restart icinga2

COMMAND

DESCRIPTION

start

The start action starts the Icinga 2 daemon.

stop

The stop action stops the Icinga 2 daemon.

restart

The restart action is a shortcut for running the stop action followed by start.

reload

The reload action sends the HUP signal to Icinga 2 which causes it to restart. Unlike the restart action reload does not wait until Icinga 2 has restarted.

checkconfig

The checkconfig action checks if the /etc/icinga2/icinga2.conf configuration file contains any errors.

status

The status action checks if Icinga 2 is running.

4. Setting up Icinga Web 2

a)     Configuring DB IDOMySQL

The DB IDO(Database Icinga Data Output) modules for Icinga 2 take care of exporting allconfiguration and status information into a database. The IDO database is usedby a number of projects including Icinga Web 2, Icinga Reporting or Icinga Web 1.x

                   i.           InstallingMySQL database server

# yum install mariadb-server mariadb

# systemctl enable mariadb

# systemctl start mariadb

# mysql_secure_installation

                 ii.           Installingthe IDO modules for MySQL

# yum install icinga2-ido-mysql

               iii.           Settingup the MySQL database

# mysql -u root -p

mysql> CREATE DATABASE icinga;

       GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTEON icinga.* TO ‘icinga‘@‘localhost‘ IDENTIFIED BY ‘icinga‘;

Aftercreating the database you can import the Icinga 2 IDO schema using thefollowing command:

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

The package provides a new configuration filethat is installed in/etc/icinga2/features-available/ido-mysql.conf. You will need to update the databasecredentials in this file.

 

              iv.           Enablingthe IDO MySQL module

# icinga2 feature enable ido-mysql

Module ‘ido-mysql‘ was enabled.

Make sure to restart Icinga 2 for thesechanges to take effect.
# systemctl restart icinga2

 

b)    安裝Webserver

# yum install httpd

# systemctl enable httpd

# systemctl start httpd

                   i.           FirewallRules

# firewall-cmd --add-service=http

# firewall-cmd --permanent --add-service=http

                 ii.           配置額外的命令通道

Web介面和一些其它模組通過額外的命令通道來向Icinga2發送命令,你可以使用下面的命令啟用它:

 

# icinga2 feature enable command

# systemctl restart icinga2

預設情況下,icingacmd使用者組擁有讀寫命令通道檔案的許可權,因此需要使用下面的命令將Web服務的使用者加入到該組:

$ usermod -a -G icingacmd apache

以使用以下命令來檢測是否成功將使用者加入到icingacmd使用者組:

$ id apache

顯示 uid=48(apache) gid=48(apache) 組=48(apache),989(icingacmd)

c)  安裝icinga Web2

# yum installicingaweb2 icingacli

d)  配置icinga Web2

你可以通過IcingaWeb2設定精靈,或者直接通過執行命令來完成配置,本文僅介紹通過設定精靈來完成配置,如果需要使用命令列來完成,請查看 Icinga Web 2官方文檔。

STEP1: 通過icingacli建立一個token,用來安裝IcingaWeb2:

icingacli setup token create

icingacli setup token show

STEP 2: 使用瀏覽器訪問 http://127.0.0.1/icingaweb2/setup (將IP替換為實際IP或網域名稱),將上一步命令列得到的token輸入到Steup Token的輸入框中,繼續下一步。


Image

STEP 3: 根據需要選擇需要安裝的模組,我這邊選擇了除翻譯外的所有模組。


Image

STEP 4: 根據系統檢查結果,解決需要修改的項,全部完成後重新整理確認。


Image

本例中,需要解決的有PHP時區,LDAP,PDO-MySQL,PDO-PostgreSQL問題。PDO-MySQL,PDO-PostgreSQL只需要重啟Web伺服器即可解決。

修改PHP時區:
使用 vi開啟 /etc/php.ini;尋找date.timezone,刪除最前面的分號,在結尾增加時區標籤,這裡使用: Asia/Shanghai

啟用LDAP:

yum install php-ldap

重啟Web伺服器,CentOS7直接使用systemctl restart httpd 重啟。
如果出現 The directory /etc/icingaweb2 is not writable.就關閉SELINUX
現在介面上所有的狀態應該都已經變成了綠色,繼續下一步吧,後面沒有特別講到的步驟都是直接點擊下一步的!

STEP 5: 配置Icinga Web2資料庫

Image

此處直接填寫我們建立的icingaweb2資料庫的資訊,預設情況下使用者名稱和密碼都是icingaweb2。由於我們並沒有給予icingaweb2使用者建立表的許可權,因此你還需要給一個有建立資料庫和表許可權的使用者。


Image

STEP 6: 建立一個Icinga Web2的管理員帳號


Image

STEP 7: 配置IcingaIDO資料庫資訊

Image

此處直接填寫我們建立的icinga資料庫的資訊,預設情況下使用者名稱和密碼都是icinga。(這些資訊是和設定mysql資料庫的操作步驟的時候填寫的資訊所對應)
如果出現 /usr/share/icingaweb2/etc/schema/mysql.schema.sql檔案沒有發現的錯誤,就運行
# cp  /usr/share/doc/icingaweb2/schema/mysql.schema.sql  /usr/share/icingaweb2/etc/schema/

登入!


Image

Centos 7 安裝 icinga2

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.