Munin 是一个非常好用安装和设置方便的监测软件,可监控核心系统资源,包括内存、磁盘、CPU 占用、服务器应用如 MySQL、Apache 和 Squid 等。
我这里的安装环境为RedHat5 作为 munin 的master,一个Munin node也将安装到master. CentOS7作为munin-node下面是详细的过程。
一 :安装 munin node
1.1:安装新的yum源包
wget http://mirrors.ustc.edu.cn/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm-ivh epel-release-7-5.noarch.rpm
我这里是直接在服务器上执行的 wget命令来下载 epel-release-7-5.noarch.rpm,如果你的服务器没有联网,请先下载然后上传,再执行rpm安装。
1.2 安装munin node
yum --enablerepo=epel -y install munin-node
如果安装成功会出现 munin-node.noarch 0:2.0.25-2.el7 的提示
1.3 配置munin node
vi /etc/munin/munin-node.conf
这里需要将
allow ^127\.0\.0\.1$
allow ^::1$
改为
allow ^10\.3\.2\.111$ (master 所在的IP地址)
allow ^127\.0\.0\.1$
allow ^::1$
到这里munin-node的配置算完成了,
启动服务
systemctl start munin-node.service
设置成开机自启动
systemctl enable munin-node.service
1.4 测试munin-node是否可链接
通过 /etc/munin/munin-node.conf 可以查看到监听的端口
# And which port
port 4949
telnet 10.3.2.121 4949 如果出现
Trying 10.3.2.121...
Connected to 10.3.2.121 (10.3.2.121).
Escape character is '^]'.
# munin node at localhost.localdomain
出现上述信息就说明munin-node是可以链接的,我在测试过程出现了防火墙阻挡的问题。
现象如下
Trying 10.3.2.121...
telnet: connect to address 10.3.2.121: No route to host
telnet: Unable to connect to remote host: No route to host
解决方法如下
firewall-cmd--zone=public --add-port=4949/tcp --permanent
出现 Success 的提示就成功了
重启防火墙
systemctlrestart firewalld.service
这里说要的说明的是CentOS7使用firewall 替代了 iptables,如果自己不习惯firewall 可卸载掉继续安 iptables然后开放4949端口就可以了
--------------------------------------munin-node end -------------------------------------------
二:安装 munin master
我这里的munin master的环境为 RedHat5 + Apache2 ,这里不再说明Apache2的安装和配置了,如不
明白请问万能的度娘啊。
2.1 安装新的 yum 源包
sudo rpm -Uvh http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm
同样的我这里的master 也是联网的,如果你的服务器没有联网请单独下载并上转epel-release
-5-4.noarch.rpm 并安装
2.2安装master
yum--enablerepo=epel -y install munin munin-node (这里同时安装了munin 和 munin-node)
2.3配置master
vi /etc/munin/munin.conf
将下面的地方的注释去掉
#dbdir /var/lib/munin
#htmldir /var/www/html/munin
#logdir /var/log/munin
#rundir /var/run/munin
#tmpldir /etc/munin/templates
注意 htmldir所执行的路径,将配置到Apache的配置文件中
# a simple host tree
下的节点改成
[Dev.111RedHat5.2]
address 127.0.0.1 # 本机
use_node_name yes
[214.121CentOS7]
address 10.3.2.121 #第一部分安装的node
use_node_name yes
到这里munin master的配置结束了
2.3配置Apache指向munin的静态页面
我的服务器上有不少应用都部署到到了Apache,所以我用的虚拟主机。
首先绑定一个新的IP地址,执行命令
ifconfig eth0:6 10.3.2.194 (这里的6是ID,10.3.2.194是IP地址)
修改Apache 虚拟主机配置extra下的httpd-vhosts.conf
增加一个新的虚拟主机
<VirtualHost 10.3.2.194:80>
ServerAdmin you@example.com
DocumentRoot "/var/www/html/munin"
ServerName www.mymunin.com
ErrorLog "logs/munin.error_log"
CustomLog "logs/munin.com-access_log" common
</VirtualHost>
保存配置文件,并重启Apache。
-------------------------------------munin master end-----------------------------------
2.4测试 munin master
访问 http://10.3.2.194/index.html
结束!