多语言展示
当前在线:1997今日阅读:19今日分享:20

S-Munin监控的安装与配置

Munin 是一款类似 RRD tool 的优秀系统监控工具,它能提供给你多方面的系统性能信息,例如 磁盘、网络、进程、系统和用户。《Linux就该这么学》-技术干货-《Munin监控的安装与配置》一文向大家风向如何在服务器中配置 Munin。Munin 的工作原理Munin 以客户端-服务器模式运行,主服务器上运行的 Munin 服务器进程会从本地运行的客户端守护进程(Munin 可以监控它自己的资源)或者远程客户端(Munin 可以监控上百台机器)收集数据,然后在它的 web 界面上以图形的方式显示出来。
安装
1

在 Linux 上安装 munin 服务器端在基于Ubuntu/Debian的机器上安装 Munin 服务器:apt-get install munin apache2在基于 Redhat/CentOS 的机器上安装 Munin 服务器:在基于 Redhat 的机器上安装 Munin 之前,你需要确保 启用 EPEL 软件仓库,因为基于 Redhat 的机器的软件仓库默认没有 Munin,下载EPEL 的rpm 安装包(下载对应版本):wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm下载完成后,通过以下命令安装EPEL 软件包rpm -ivh epel-release-6-8.noarch.rpm或rpm -ivh epel-release*安装好EPEL 源后,用yum 命令来检查是否添加到源列表:# yum repolistLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.vonline.vn * epel: buaya.klas.or.id * extras: centos-hn.viettelidc.com.vn * updates: mirrors.fibo.vnrepo id        repo name                                              statusbase           CentOS-6 - Base                                         6,381epel           Extra Packages for Enterprise Linux 6 - x86_64         10,023extras         CentOS-6 - Extras                                          13nginx          nginx repo                                                 47updates        CentOS-6 - Updates                                      1,555repolist: 18,019EPEL已经在repo 后列出,并且显示提供了上万个软件包,所以EPEL 已经安装到你的CentOS了,EPEL源的配置安装到了/etc/yum.repos.d/epel.repo 文件。然后就可以直接安装munin了,执行命令:yum install munin httpd

2

在 Linux 上配置 Munin 服务器端:下面是我们要在服务器上启动 Munini 所进行的步骤:步骤 1:在 /etc/munin/munin.conf 中添加需要监控的主机详情。在 /etc/munin/munin.conf 文件中添加主机条目,调到文件末尾添加要监控的客户端。在这个例子中,我添加了要监控的数据库服务器和它的 IP 地址。[db.linuxprobe.com]address 192.168.1.25use_node_name yes保存文件并退出。步骤 2:配置 apache web 服务器使其包括 munin 配置。在 /etc/apache2/conf.d 目录中编辑或创建文件 munin.conf 用于包括 Munin 和 Apache 相关的配置,另外注意一点,默认其它和 web 相关的 Munin 配置保存在 /var/www/munin 目录。vi /etc/apache2/conf.d/munin.conf内容:Alias /munin /var/www/muninOrder allow,denyAllow from localhost 127.0.0.0/8 ::1AllowOverride NoneOptions ExecCGI FollowSymlinksAddHandler cgi-script .cgiDirectoryIndex index.cgiAuthUserFile /etc/munin/munin.passwdAuthType basicAuthName 'Munin stats'require valid-userExpiresActive OnExpiresDefault M310保存文件并退出。步骤 3:为 web 界面创建用户名和密码。现在为查看 munin 的图示而创建用户名和密码:htpasswd -c /etc/munin/munin-htpasswd munin注意:对于 Redhat/Centos 机器,要访问你的配置文件,需要在每个路径中用 “httpd” 替换 “apache2”。步骤 4:重启 apache 服务器。重启 Apache 服务器,使得 Munin 配置生效。基于 Ubuntu/Debian :service apache2 restart基于 Centos/Redhat :service httpd restart

3

在 Linux 上安装和配置 Munin 客户端:步骤 1:在 Linux 上安装 Munin 客户端。apt-get install munin-node注意:如果你想监控你的 Munin 服务器端,你也需要在服务器端安装 munin-node。步骤 2:编辑 munin-node.conf 文件配置客户端。vi /etc/munin/munin-node.conf示例:allow ^127\.0\.0\.1$allow ^10\.10\.20\.20$# 监听到哪个地址上host *# 以及哪个端口port 4949注意: 10.10.20.20 是我的 Munin 服务器,它连接到客户端的 4949 端口获取数据。步骤 3:在客户端机器中重启 munin-node:service munin-node restart

测试连接

检查你是否能从服务器的连接到客户端的 4949 端口,如果不行,你需要在客户端机器中的防火墙打开该端口。访问 Munin web 页面http://munin.linuxprobe.com/munin/index.html即可。注意,测试之前已经将域名定义到了指定的服务端的80端口。

推荐信息