在CentOS 8/RHEL 8上安装和配置Icinga 2和Icinga Web 2
欢迎使用有关如何使用Icinga Web 2在CentOS 8/RHEL 8上安装Icinga 2的指南。Icinga 2是一个免费且开源的监视工具,旨在可扩展和可扩展Icinga 2检查网络资源的可用性,通知用户中断,并生成性能数据以进行报告。 Icinga 2可用于监视多个位置的大型复杂环境。
使用Icinga 2我们可以监视:服务器资源RAM使用率,CPU负载,磁盘使用率网络服务HTTP,HTTPS,SMTP,IMAP,POP3,NNTP,ping 等网络设备路由器和交换机
Icinga 2的功能
这些是Icinga 2提供的主要功能:
面向性能:Icinga 2具有多线程设计,每秒可以运行数千次检查而不会出现CPU紧张的迹象分布式体系结构:对于大型和复杂环境,请进行具有高可用性的分布式设置.REST API:Icinga 2提供RESTful API,使我们可以即时更新配置或者在自定义仪表板上显示有关当前问题的实时信息。基于规则的配置:使用动态配置作为代码进行监视。将规则应用于主机和服务以创建连续的监视环境。警报:当通过电子邮件,短信或者移动消息应用程序出现问题时,我们会立即收到通知。Icinga2对Graphite和InfluxDB具有本机支持。我们可以轻松地将收集到的性能数据直接发送到第三方工具。Icinga2支持NagiosGrapher,PNP4Nagios和InGraph插件
Icinga 2的标准Web界面称为Icinga Web 2
在CentOS 8/RHEL 8上安装Icinga 2
现在开始在CentOS 8/RHEL 8上安装Icinga2. 下面是确保在CentOS 8/RHEL 8 Linux发行版上正在运行的Icinga 2的遵循步骤。
更新系统
确保CentOS/RHEL系统是最新的:
sudo yum -y update
启用EPEL储存库
确保在RHEL 8/CentOS 8系统中启用了EPEL存储库。
在CentOS 8/RHEL 8上启用EPEL存储库
运行的一行命令是:
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
如果我们运行的是RHEL 8,请考虑启用其他存储库。
sudo subscription-manager repos --enable=rhel-8-server-optional-rpms \ --enable=rhel-8-server-extras-rpms
将Icinga 2储存库添加到CentOS 8/RHEL 8
添加EPEL存储库后,将Icinga 2存储库添加到系统中。
sudo tee /etc/yum.repos.d/icinga2.repo<<EOF [icinga2] name=Icinga 2 Repository for EPEL 8 baseurl=https://packages.icinga.com/epel/8/release enabled=1 EOF
导入GPG密钥:
sudo rpm --import https://packages.icinga.com/icinga.key
更新Yum缓存
sudo dnf clean all sudo dnf makecache
安装MariaDB数据库服务器
在CentOS/RHEL 8服务器上安装MariaDB数据库服务器。
在CentOS/RHEL 8上安装MariaDB
安装后,为Icinga2创建数据库和用户:
$mysql -u root -p CREATE DATABASE icinga; GRANT ALL PRIVILEGES ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'theitroad@localhost'; FLUSH PRIVILEGES; EXIT;
在CentOS 8/RHEL 8上安装Icinga 2
运行以下命令以在CentOS 8/RHEL 8上安装Icinga 2.
sudo dnf -y install icinga2 icinga2-selinux icinga2-ido-mysql vim-icinga2
下面是依赖关系树:
Dependencies resolved. =================================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================================== Installing: icinga2 x86_64 2.11.2-1.el8.icinga icinga2 33 k icinga2-ido-mysql x86_64 2.11.2-1.el8.icinga icinga2 117 k icinga2-selinux x86_64 2.11.2-1.el8.icinga icinga2 64 k Installing dependencies: boost-context x86_64 1.66.0-6.el8 AppStream 15 k boost-coroutine x86_64 1.66.0-6.el8 AppStream 31 k boost-filesystem x86_64 1.66.0-6.el8 AppStream 49 k mysql-common x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 143 k mysql-libs x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 1.2 M icinga2-bin x86_64 2.11.2-1.el8.icinga icinga2 3.8 M icinga2-common x86_64 2.11.2-1.el8.icinga icinga2 152 k Enabling module streams: mysql 8.0 Transaction Summary =================================================================================================================================================== Install 10 Packages Total download size: 5.7 M Installed size: 27 M
启动并启用
启用Icinga 2必需的模块:
sudo icinga2 feature enable command ido-mysql syslog
我们可以根据需要检查并启用其他功能:
$sudo icinga2 feature list Disabled features: api compatlog debuglog elasticsearch gelf graphite influxdb livestatus opentsdb perfdata statusdata syslog Enabled features: checker command ido-mysql mainlog notification
导入Icinga 2数据库:
mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
配置数据库访问:
$sudo vim /etc/icinga2/features-available/ido-mysql.conf
取消注释行并设置访问凭据。
/** * The IdoMysqlConnection type implements MySQL support * for DB IDO. */ object IdoMysqlConnection "ido-mysql" { user = "icinga" password = "theitroad@localhost" host = "localhost" database = "icinga" }
然后启动并启用icinga2服务。
sudo systemctl enable --now icinga2.service
确认服务状态。
$systemctl status icinga2.service ● icinga2.service - Icinga host/service/network monitoring system Loaded: loaded (/usr/lib/systemd/system/icinga2.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2019-11-12 10:27:10 EAT; 6s ago Process: 13756 ExecStartPre=/usr/lib/icinga2/prepare-dirs /etc/sysconfig/icinga2 (code=exited, status=0/SUCCESS) Main PID: 13766 (icinga2) Tasks: 11 (limit: 11512) Memory: 16.6M CGroup: /system.slice/icinga2.service ├─13766 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log ├─13781 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log └─13782 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/ConfigItem: Instantiated 1 UserGroup. Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/ConfigItem: Instantiated 1 IdoMysqlConnection. Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/ConfigItem: Instantiated 235 CheckCommands. Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/ConfigItem: Instantiated 3 TimePeriods. Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/ConfigItem: Instantiated 1 User. Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/ConfigItem: Instantiated 11 Services. Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/ConfigItem: Instantiated 3 ServiceGroups. Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/ScriptGlobal: Dumping variables to file '/var/cache/icin> Nov 12 10:27:10 centos8.novalocal icinga2[13766]: [2019-11-12 10:27:10 +0300] information/cli: Closing console log. Nov 12 10:27:10 centos8.novalocal systemd[1]: Started Icinga host/service/network monitoring system.
在CentOS 8/RHEL 8上安装Icinga Web 2
现在我们已经完成了在CentOS 8/RHEL 8服务器上安装Icinga 2的工作,让我们继续在CentOS 8/RHEL 8上安装Icinga Web 2.
如何在CentOS 8/RHEL 8上安装Icinga Web 2