mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
commit
393365f8e5
@ -1,271 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Install and Configure Nagios Core on CentOS 8 / RHEL 8)
|
||||
[#]: via: (https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/)
|
||||
[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/)
|
||||
|
||||
How to Install and Configure Nagios Core on CentOS 8 / RHEL 8
|
||||
======
|
||||
|
||||
**Nagios** is a free and opensource network and alerting engine used to monitor various devices, such as network devices, and servers in a network. It supports both **Linux** and **Windows OS** and provides an intuitive web interface that allows you to easily monitor network resources. When professionally configured, it can alert you in the event a server or a network device goes down or malfunctions via email alerts. In this topic, we shed light on how you can install and configure Nagios core on **RHEL 8** / **CentOS 8**.
|
||||
|
||||
[![Install-Nagios-Core-RHEL8-CentOS8][1]][2]
|
||||
|
||||
### Prerequisites of Nagios Core
|
||||
|
||||
Before we begin, perform a flight check and ensure you have the following:
|
||||
|
||||
* An instance of RHEL 8 / CentOS 8
|
||||
* SSH access to the instance
|
||||
* A fast and stable internet connection
|
||||
|
||||
|
||||
|
||||
With the above requirements in check, let’s roll our sleeves!
|
||||
|
||||
### Step 1: Install LAMP Stack
|
||||
|
||||
For Nagios to work as expected, you need to install LAMP stack or any other web hosting stack since it’s going to run on a browser. To achieve this, execute the command:
|
||||
|
||||
```
|
||||
# dnf install httpd mariadb-server php-mysqlnd php-fpm
|
||||
```
|
||||
|
||||
![Install-LAMP-stack-CentOS8][1]
|
||||
|
||||
You need to ensure that Apache web server is up and running. To do so, start and enable Apache server using the commands:
|
||||
|
||||
```
|
||||
# systemctl start httpd
|
||||
# systemctl enable httpd
|
||||
```
|
||||
|
||||
![Start-enable-httpd-centos8][1]
|
||||
|
||||
To check the status of Apache server run
|
||||
|
||||
```
|
||||
# systemctl status httpd
|
||||
```
|
||||
|
||||
![Check-status-httpd-centos8][1]
|
||||
|
||||
Next, we need to start and enable MariaDB server, run the following commands
|
||||
|
||||
```
|
||||
# systemctl start mariadb
|
||||
# systemctl enable mariadb
|
||||
```
|
||||
|
||||
![Start-enable-MariaDB-CentOS8][1]
|
||||
|
||||
To check MariaDB status run:
|
||||
|
||||
```
|
||||
# systemctl status mariadb
|
||||
```
|
||||
|
||||
![Check-MariaDB-status-CentOS8][1]
|
||||
|
||||
Also, you might consider hardening or securing your server and making it less susceptible to unauthorized access. To secure your server, run the command:
|
||||
|
||||
```
|
||||
# mysql_secure_installation
|
||||
```
|
||||
|
||||
Be sure to set a strong password for your MySQL instance. For the subsequent prompts, Type **Yes** and hit **ENTER**
|
||||
|
||||
![Secure-MySQL-server-CentOS8][1]
|
||||
|
||||
### Step 2: Install Required packages
|
||||
|
||||
Apart from installing the LAMP server, some additional packages are needed for the installation and proper configuration of Nagios. Therefore, install the packages as shown below:
|
||||
|
||||
```
|
||||
# dnf install gcc glibc glibc-common wget gd gd-devel perl postfix
|
||||
```
|
||||
|
||||
![Install-requisite-packages-CentOS8][1]
|
||||
|
||||
### Step 3: Create a Nagios user account
|
||||
|
||||
Next, we need to create a user account for the Nagios user. To achieve this , run the command:
|
||||
|
||||
```
|
||||
# adduser nagios
|
||||
# passwd nagios
|
||||
```
|
||||
|
||||
![Create-new-user-for-Nagios][1]
|
||||
|
||||
Now, we need to create a group for Nagios and add the Nagios user to this group.
|
||||
|
||||
```
|
||||
# groupadd nagiosxi
|
||||
```
|
||||
|
||||
Now add the Nagios user to the group
|
||||
|
||||
```
|
||||
# usermod -aG nagiosxi nagios
|
||||
```
|
||||
|
||||
Also, add Apache user to the Nagios group
|
||||
|
||||
```
|
||||
# usermod -aG nagiosxi apache
|
||||
```
|
||||
|
||||
![Add-Nagios-group-user][1]
|
||||
|
||||
### Step 4: Download and install Nagios core
|
||||
|
||||
We can now proceed and install Nagios Core. The latest stable version in Nagios 4.4.5 which was released on August 19, 2019. But first, download the Nagios tarball file from its official site.
|
||||
|
||||
To download Nagios core, first head to the tmp directory
|
||||
|
||||
```
|
||||
# cd /tmp
|
||||
```
|
||||
|
||||
Next download the tarball file
|
||||
|
||||
```
|
||||
# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz
|
||||
```
|
||||
|
||||
![Download-Nagios-CentOS8][1]
|
||||
|
||||
After downloading the tarball file, extract it using the command:
|
||||
|
||||
```
|
||||
# tar -xvf nagios-4.4.5.tar.gz
|
||||
```
|
||||
|
||||
Next, navigate to the uncompressed folder
|
||||
|
||||
```
|
||||
# cd nagios-4.4.5
|
||||
```
|
||||
|
||||
Run the commands below in this order
|
||||
|
||||
```
|
||||
# ./configure --with-command-group=nagcmd
|
||||
# make all
|
||||
# make install
|
||||
# make install-init
|
||||
# make install-daemoninit
|
||||
# make install-config
|
||||
# make install-commandmode
|
||||
# make install-exfoliation
|
||||
```
|
||||
|
||||
To setup Apache configuration issue the command:
|
||||
|
||||
```
|
||||
# make install-webconf
|
||||
```
|
||||
|
||||
### Step 5: Configure Apache Web Server Authentication
|
||||
|
||||
Next, we are going to setup authentication for the user **nagiosadmin**. Please be mindful not to change the username or else, you may be required to perform further configuration which may be quite tedious.
|
||||
|
||||
To set up authentication run the command:
|
||||
|
||||
```
|
||||
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
|
||||
```
|
||||
|
||||
![Configure-Apache-webserver-authentication-CentOS8][1]
|
||||
|
||||
You will be prompted for the password of the nagiosadmin user. Enter and confirm the password as requested. This is the user that you will use to login to Nagios towards the end of this tutorial.
|
||||
|
||||
For the changes to come into effect, restart your web server.
|
||||
|
||||
```
|
||||
# systemctl restart httpd
|
||||
```
|
||||
|
||||
### Step 6: Download & install Nagios Plugins
|
||||
|
||||
Plugins will extend the functionality of the Nagios Server. They will help you monitor various services, network devices, and applications. To download the plugin tarball file run the command:
|
||||
|
||||
```
|
||||
# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
|
||||
```
|
||||
|
||||
Next, extract the tarball file and navigate to the uncompressed plugin folder
|
||||
|
||||
```
|
||||
# tar -xvf nagios-plugins-2.2.1.tar.gz
|
||||
# cd nagios-plugins-2.2.1
|
||||
```
|
||||
|
||||
To install the plugins compile the source code as shown
|
||||
|
||||
```
|
||||
# ./configure --with-nagios-user=nagios --with-nagios-group=nagiosxi
|
||||
# make
|
||||
# make install
|
||||
```
|
||||
|
||||
### Step 7: Verify and Start Nagios
|
||||
|
||||
After the successful installation of Nagios plugins, verify the Nagios configuration to ensure that all is well and there is no error in the configuration:
|
||||
|
||||
```
|
||||
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
|
||||
```
|
||||
|
||||
![Verify-Nagios-settings-CentOS8][1]
|
||||
|
||||
Next, start Nagios and verify its status
|
||||
|
||||
```
|
||||
# systemctl start nagios
|
||||
# systemctl status nagios
|
||||
```
|
||||
|
||||
![Start-check-status-Nagios-CentOS8][1]
|
||||
|
||||
In case Firewall is running on system then allow “80” using the following command
|
||||
|
||||
```
|
||||
# firewall-cmd --permanent --add-port=80/tcp# firewall-cmd --reload
|
||||
```
|
||||
|
||||
### Step 8: Access Nagios dashboard via the web browser
|
||||
|
||||
To access Nagios, browse your server’s IP address as shown
|
||||
|
||||
<http://server-ip/nagios>
|
||||
|
||||
A pop-up will appear prompting for the username and the password of the user we created earlier in Step 5. Enter the credentials and hit ‘**Sign In**’
|
||||
|
||||
![Access-Nagios-via-web-browser-CentOS8][1]
|
||||
|
||||
This ushers you to the Nagios dashboard as shown below
|
||||
|
||||
![Nagios-dashboard-CentOS8][1]
|
||||
|
||||
We have finally successfully installed and configured Nagios Core on CentOS 8 / RHEL 8. Your feedback is most welcome.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/
|
||||
|
||||
作者:[James Kiarie][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linuxtechi.com/author/james/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Install-Nagios-Core-RHEL8-CentOS8.jpg
|
@ -0,0 +1,272 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Install and Configure Nagios Core on CentOS 8 / RHEL 8)
|
||||
[#]: via: (https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/)
|
||||
[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/)
|
||||
|
||||
如何在 CentOS 8 / RHEL 8 上安装和配置 Nagios Core
|
||||
======
|
||||
|
||||
**Nagios** 是一个免费开源网络和警报引擎,它用于监视各种设备,例如网络设备和网络中的服务器。它支持 **Linux** 和 **Windows**,并提供直观的 Web 界面,可让你轻松监控网络资源。经过专业配置后,它可以在服务器或网络设备下线或者故障时向你发出邮件警报。在本文中,我们说明了如何在 **RHEL 8** / **CentOS 8** 上安装和配置 Nagios Core。
|
||||
|
||||
[![Install-Nagios-Core-RHEL8-CentOS8][1]][2]
|
||||
|
||||
### Nagios Core 的先决条件
|
||||
|
||||
在开始之前,请先检查并确保有以下各项:
|
||||
|
||||
|
||||
* RHEL 8 / CentOS 8 的实例
|
||||
* 能通过 SSH 访问实例
|
||||
* 快速稳定的互联网连接
|
||||
|
||||
|
||||
|
||||
满足上述要求后,我们开始吧!
|
||||
|
||||
### 步骤 1:安装 LAMP
|
||||
|
||||
为了使 Nagios 能够按预期工作,你需要安装 LAMP 或其他网络托管软件,因为它们将在浏览器上运行。 为此,请执行以下命令:
|
||||
|
||||
```
|
||||
# dnf install httpd mariadb-server php-mysqlnd php-fpm
|
||||
```
|
||||
|
||||
![Install-LAMP-stack-CentOS8][1]
|
||||
|
||||
你需要确保 Apache Web 服务器已启动并正在运行。 为此,请使用以下命令启用并启动 Apache 服务器:
|
||||
|
||||
```
|
||||
# systemctl start httpd
|
||||
# systemctl enable httpd
|
||||
```
|
||||
|
||||
![Start-enable-httpd-centos8][1]
|
||||
|
||||
检查 Apache 服务器运行状态
|
||||
|
||||
```
|
||||
# systemctl status httpd
|
||||
```
|
||||
|
||||
![Check-status-httpd-centos8][1]
|
||||
|
||||
接下来,我们需要启用并启动 MariaDB 服务器,运行以下命令
|
||||
|
||||
```
|
||||
# systemctl start mariadb
|
||||
# systemctl enable mariadb
|
||||
```
|
||||
|
||||
![Start-enable-MariaDB-CentOS8][1]
|
||||
|
||||
要检查 MariaDB 状态,请运行:
|
||||
|
||||
```
|
||||
# systemctl status mariadb
|
||||
```
|
||||
|
||||
![Check-MariaDB-status-CentOS8][1]
|
||||
|
||||
另外,你可能会考虑加强或保护服务器,使其不容易受到未经授权的访问。要保护服务器,请运行以下命令:
|
||||
|
||||
```
|
||||
# mysql_secure_installation
|
||||
```
|
||||
|
||||
确保为你的 MySQL 实例设置一个强密码。对于后续提示,请输入 **Yes** 并按**回车**
|
||||
|
||||
![Secure-MySQL-server-CentOS8][1]
|
||||
|
||||
### 步骤 2:安装必需的软件包
|
||||
|
||||
除了安装 LAMP 外,还需要一些其他软件包来安装和正确配置 Nagios。因此,如下所示安装软件包:
|
||||
|
||||
```
|
||||
# dnf install gcc glibc glibc-common wget gd gd-devel perl postfix
|
||||
```
|
||||
|
||||
![Install-requisite-packages-CentOS8][1]
|
||||
|
||||
### 步骤 3:创建 Nagios 用户帐户
|
||||
|
||||
接下来,我们需要为 Nagios 用户创建一个用户帐户。为此,请运行以下命令:
|
||||
|
||||
```
|
||||
# adduser nagios
|
||||
# passwd nagios
|
||||
```
|
||||
|
||||
![Create-new-user-for-Nagios][1]
|
||||
|
||||
现在,我们需要为 Nagios 创建一个组,并将 Nagios 用户添加到该组中。
|
||||
|
||||
```
|
||||
# groupadd nagiosxi
|
||||
```
|
||||
|
||||
现在添加 Nagios 用户到组中
|
||||
|
||||
```
|
||||
# usermod -aG nagiosxi nagios
|
||||
```
|
||||
|
||||
另外,将 Apache 用户添加到 Nagios 组
|
||||
|
||||
```
|
||||
# usermod -aG nagiosxi apache
|
||||
```
|
||||
|
||||
![Add-Nagios-group-user][1]
|
||||
|
||||
### 步骤 4:下载并安装 Nagios Core
|
||||
|
||||
现在,我们可以继续安装 Nagios Core。Nagios 4.4.5 的最新稳定版本于 2019 年 8 月 19 日发布。但首先,请从它的官方网站下载 Nagios tarball 文件。
|
||||
|
||||
要下载 Nagios Core,请首进入 tmp 目录
|
||||
|
||||
```
|
||||
# cd /tmp
|
||||
```
|
||||
|
||||
接下来下载 tarball 文件
|
||||
|
||||
```
|
||||
# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz
|
||||
```
|
||||
|
||||
![Download-Nagios-CentOS8][1]
|
||||
|
||||
下载完 tarball 文件后,使用以下命令将其解压缩:
|
||||
|
||||
```
|
||||
# tar -xvf nagios-4.4.5.tar.gz
|
||||
```
|
||||
|
||||
接下来,进入未压缩的文件夹
|
||||
|
||||
```
|
||||
# cd nagios-4.4.5
|
||||
```
|
||||
|
||||
按此顺序运行以下命令
|
||||
|
||||
```
|
||||
# ./configure --with-command-group=nagcmd
|
||||
# make all
|
||||
# make install
|
||||
# make install-init
|
||||
# make install-daemoninit
|
||||
# make install-config
|
||||
# make install-commandmode
|
||||
# make install-exfoliation
|
||||
```
|
||||
|
||||
要配置 Apache,请运行以下命令:
|
||||
|
||||
```
|
||||
# make install-webconf
|
||||
```
|
||||
|
||||
### 步骤 5:配置 Apache Web 服务器身份验证
|
||||
|
||||
接下来,我们将为用户 **nagiosadmin** 设置身份验证。请注意不要更改用户名,否则,可能会要求你进一步的配置,这可能很繁琐。
|
||||
|
||||
要设置身份验证,请运行以下命令:
|
||||
|
||||
```
|
||||
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
|
||||
```
|
||||
|
||||
![Configure-Apache-webserver-authentication-CentOS8][1]
|
||||
|
||||
系统将提示你输入 nagiosadmin 用户的密码。输入并按要求确认密码。在本教程结束时,你将使用该用户登录 Nagios。
|
||||
|
||||
为使更改生效,请重新启动 Web 服务器。
|
||||
|
||||
```
|
||||
# systemctl restart httpd
|
||||
```
|
||||
|
||||
### 步骤 6:下载并安装 Nagios 插件
|
||||
|
||||
插件将扩展 Nagios 服务器的功能。它们将帮助你监控各种服务、网络设备和应用。要下载插件 tarball 文件,请运行以下命令:
|
||||
|
||||
```
|
||||
# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
|
||||
```
|
||||
|
||||
接下来,解压 tarball 文件并进入到未压缩的插件文件夹
|
||||
|
||||
```
|
||||
# tar -xvf nagios-plugins-2.2.1.tar.gz
|
||||
# cd nagios-plugins-2.2.1
|
||||
```
|
||||
|
||||
要安装插件,请编译源代码,如下所示
|
||||
|
||||
```
|
||||
# ./configure --with-nagios-user=nagios --with-nagios-group=nagiosxi
|
||||
# make
|
||||
# make install
|
||||
```
|
||||
|
||||
### 步骤 7:验证和启动 Nagios
|
||||
|
||||
成功安装 Nagios 插件后,验证 Nagios 配置以确保一切良好,并且配置中没有错误:
|
||||
|
||||
```
|
||||
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
|
||||
```
|
||||
|
||||
![Verify-Nagios-settings-CentOS8][1]
|
||||
|
||||
接下来,启动 Nagios 并验证其状态
|
||||
|
||||
```
|
||||
# systemctl start nagios
|
||||
# systemctl status nagios
|
||||
```
|
||||
|
||||
![Start-check-status-Nagios-CentOS8][1]
|
||||
|
||||
如果系统中有防火墙,那么使用以下命令允许 ”80“ 端口
|
||||
|
||||
```
|
||||
# firewall-cmd --permanent --add-port=80/tcp# firewall-cmd --reload
|
||||
```
|
||||
|
||||
### 步骤 8:通过 Web 浏览器访问 Nagios 面板
|
||||
|
||||
要访问 Nagios,请打开服务器的 IP 地址,如下所示
|
||||
|
||||
<http://server-ip/nagios>
|
||||
|
||||
这将出现一个弹出窗口,提示输入我们在步骤 5 创建的用户名和密码。输入凭据并点击”**登录**“
|
||||
|
||||
![Access-Nagios-via-web-browser-CentOS8][1]
|
||||
|
||||
这将引导你到 Nagios 面板,如下所示
|
||||
|
||||
![Nagios-dashboard-CentOS8][1]
|
||||
|
||||
我们终于成功地在 CentOS 8 / RHEL 8 上安装和配置了 Nagios Core。欢迎你的反馈。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxtechi.com/install-nagios-core-rhel-8-centos-8/
|
||||
|
||||
作者:[James Kiarie][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linuxtechi.com/author/james/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/Install-Nagios-Core-RHEL8-CentOS8.jpg
|
Loading…
Reference in New Issue
Block a user