在 RHEL、CentOS 和 Fedora 中安装 Munin(网络监控)
Munin(网络监控工具)是一个用Perl编写的基于开源网络的网络监控应用程序,以图形形式显示服务器和服务的网络使用情况使用RRDtool。在 Munin 的帮助下,您可以监控系统、网络、SANS 和应用程序的性能。
它具有主/节点架构,其中主节点定期连接到每个节点并从中提取数据。然后,它使用 RRDtool 记录并生成更新的图表。
建议阅读: 20 个监控 Linux 性能的命令行工具
在本文中,我们将向您介绍在 RHEL< 中使用 Munin 节点 设置 Munin(网络监控工具)的步骤/strong>、CentOS 和 Fedora 系统使用以下环境。
Munin Server - hostname: munin.linux-console.net and IP Address: 192.168.103
Munin Client - hostname: munin-node.linux-console.net and IP Address: 192.168.15
在 RHEL、CentOS 和 Fedora 中安装 Munin
安装 Munin 非常简单,只需按照我下面的分步命令将其安装到您的服务器上即可。
第 1 步:安装 EPEL 存储库
Munin 可以使用 Fedora 的 EPEL 存储库在 RHEL 7.x/ 下安装6.x/5.x 和 CentOS 7.x/6.x/5.x。
只需以 root 用户身份运行以下命令,即可使用 wget 安装并启用 Epel 存储库。
RHEL/CentOS 7
------------------ RHEL/CentOS 7 - 64-Bit ------------------
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
rpm -ivh epel-release-7-9.noarch.rpm
RHEL/CentOS 6
------------------ RHEL/CentOS 6 - 32-Bit ------------------
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
------------------ RHEL/CentOS 6 - 64-Bit ------------------
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
RHEL/CentOS 5
------------------ RHEL/CentOS 5 - 32-Bit ------------------
wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -ivh epel-release-5-4.noarch.rpm
------------------ RHEL/CentOS 5 - 64-Bit ------------------
wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -ivh epel-release-5-4.noarch.rpm
注意:Fedora 用户不需要安装 EPEL 存储库,因为 munin 已包含在 Fedora 中并且可以使用yum或dnf包管理器安装。
建议阅读: 20 个管理 Linux 包管理的 Yum 命令
建议阅读: 管理 Fedora 包管理的 27 个 Dnf 命令
接下来,进行系统更新以确保在安装 Munin 之前加载 EPEL 软件包数据库。
------------------ On RHEL and CentOS Only ------------------
yum -y update
第 2 步:安装 Apache Web 服务器
Munin 需要一个可用的 Web 服务器,例如 Apache 或 Nginx 来显示其统计文件。我们将安装 Apache Web 服务器来为 Munin 图提供服务。
------------------ On RHEL, CentOS and Fedora ------------------
yum install httpd
------------------ On Fedora 22+ Releases ------------------
dnf install httpd
安装 Apache 后,启动并启用该服务在系统启动时自动启动。
------------------ On RHEL, CentOS and Fedora ------------------
service httpd start
chkconfig --level 35 httpd on
------------------ On RHEL/CentOS 7 and Fedora 22+ ------------------
systemctl enable httpd
systemctl start httpd
步骤 3:安装 Munin 和 Munin-Node
现在是时候安装 Munin 和 Munin-Node 了,如图所示。
------------------ On RHEL, CentOS and Fedora ------------------
yum -y install munin munin-node
------------------ On Fedora 22+ Releases ------------------
dnf -y install munin munin-node
默认情况下,上述安装会创建以下目录。
- /etc/munin/munin.conf :Munin 主配置文件。
- /etc/cron.d/munin :Munin cron 文件。
- /etc/httpd/conf.d/munin.conf :Munin Apache 配置文件。
- /var/log/munin :Munin 日志目录。
- /var/www/html/munin :Munin Web 目录。
- /etc/munin/munin-node.conf:Munin 节点主配置文件。
- /etc/munin/plugins.conf :Munin 插件配置文件。
步骤 3:配置 Munin 并用密码保护 Munin
此步骤是可选的,仅当您想在 HTML 输出中使用 munin.howtoing.com
而不是 localhost
时才适用,如下所示:
打开 /etc/munin/munin.conf
配置文件并按照建议进行更改,不要忘记将 munin.howtoing.com
替换为您的服务器名称。
a simple host tree
[munin.linux-console.net]
address 127.0.0.1
use_node_name yes
[...]
接下来使用 Apache 基本身份验证模块使用用户名和密码密码保护 Munin 统计信息,如下所示:
htpasswd /etc/munin/munin-htpasswd admin
接下来重新启动 Munin 并使其在启动时自动启动。
------------------ On RHEL, CentOS and Fedora ------------------
service munin-node start
chkconfig --level 35 munin-node on
------------------ On RHEL/CentOS 7 and Fedora 22+ ------------------
systemctl enable munin-node
systemctl start munin-node
第 4 步:访问 Munin Web 界面
等待30分钟,以便Munin可以生成图表并显示。要查看图形的第一个输出,请打开浏览器并导航到 http://munin.howtoing.com/munin
并输入登录凭据。
如果没有提示输入用户名和密码,请打开/etc/httpd/conf.d/munin.conf
并更改用户名Munin
到 admin
并重新启动 Apache。
AuthUserFile /etc/munin/munin-htpasswd
AuthName "admin"
AuthType Basic
require valid-user
步骤 5:将 Linux 客户端添加到 Munin 服务器
登录 Linux 客户端计算机并仅安装 munin-node
软件包,如下所示:
yum install munin-node
dnf install munin-node [On Fedora 22+ versions]
apt-get install munin-node [On Debian based systems]
现在打开 /etc/munin/munin-node.conf
配置文件并添加 munin 服务器 IP 地址以启用从客户端获取数据。
vi /etc/munin/munin-node.conf
按照以下格式添加 Munin 服务器的 IP 地址,如下所示:
A list of addresses that are allowed to connect.
allow ^127\.0\.0\.1$
allow ^::1$
allow ^192\.168\.0\.103$
最后,重新启动munin客户端:
------------------ On RHEL, CentOS and Fedora ------------------
service munin-node start
chkconfig --level 35 munin-node on
------------------ On RHEL/CentOS 7 and Fedora 22+ ------------------
systemctl enable munin-node
systemctl start munin-node
步骤 6:配置 Munin 服务器以连接客户端节点
打开 /etc/munin/munin.conf 配置文件并添加远程 Linux 客户端节点的以下新部分以及服务器名称和 IP 地址,如下所示:
a simple host tree
[munin.linux-console.net]
address 127.0.0.1
use_node_name yes
[munin-node.linux-console.net]
address 192.168.0.15
use_node_name yes
接下来,重新启动 munin 服务器并导航到 http://munin.howtoing.com/munin 页面以查看正在运行的新客户端节点图。
有关更多信息和用法,请访问 http://munin-monitoring.org/wiki/Documentation。