In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to use Munin monitoring server in CentOS. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Introduction and principle of Munin
Munin is a server monitoring tool based on perl, which can collect the information of all node servers regularly through the network, save the data information of the server as RRD file format, and draw graphs and curves through RRDTool (also written by perl), which can be displayed on the web page. Can monitor computers, services, networks, SANS, applications, etc. Munin (stands for memory, is the name of a crow of Odin)
Mode of work:
Munin is divided into master and node
Master only needs to be installed on a server. It collects information from each node every 5 minutes, records the data in RRD format and plots it into a chart.
Node is installed on each monitored server, and many plugin can be configured on node. Each plugin has different responsibilities and is responsible for obtaining different information about the server.
On the Munin server, when there are more than 20 nodes, the resource consumption will be very large, so if there are more servers, it is better to use things like Nagios (this is not the case where you have tried to monitor so many servers).
How to install munin on CentOs, RHEL, Fedora
I recently upgraded from centos6.4 to centos 6.5. In CentOS,RHEL,Scientific Linux 6.5Compact 6.4Compact 6.3Compact 6.x, where x stands for minor version updates. As long as it belongs to 6.x, you can use the epel source for online installation.
Premise 1: I install munin only if I have installed the lnmp environment. So, you can install lnmp first, and then follow my tutorial to install mumin.
Premise 2: because I have only one vps on hand, I act as both a monitoring server (master) and a monitored client (node node). Of course, I will also insert a method to monitor multiple server nodes in the tutorial.
Premise 3: make sure your nginx has the http_stub_status_module module loaded.
The code is as follows:
# / usr/local/nginx/sbin/nginx-v / / View the nginx version
The code is as follows:
# / usr/local/nginx/sbin/nginx-V / /
Here-V is uppercase. Check the compilation parameters of nginx to see which modules are in it. If the output contains-- with-http_stub_status_module text, the http_stub_status_module module is included. Premise three is met. If you don't have http_stub_status_module, you can recompile and install nginx. (brother Jun's lnmp has been installed by default), you can also combine the grep command to view it.
Install for CentOs,RHEL,Fedora
Execute the following command:
32-bit system of RHEL/CentOS 6.x
The code is as follows:
# rpm-ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
32-bit system of RHEL/CentOS 5.x
The code is as follows:
# rpm-ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
There are also 64-bit systems, etc., see "how to install EPEL third-party sources in centos"
Because the epel-release-6-8.noarch.rpm in the epel source only retains the latest version. So, it's very likely that by the time you read this article, epel- release-6-8.noarch.rpm no longer exists. At this time, you need your own system version and whether the system is 32-bit to go to the http://dl.fedoraproject.org/pub/epel/ directory to find the latest epel-release-x-x.noarch.rpm. You can install epel-release-6-x.noarch.rpm as long as your system is 6.x. Similarly, epel-release-5-x.noarch.rpm can also be installed for centos5.x.
For Fedora users, there is no need to install the Epel source manually, because munin is already included in fedora's software library and can be installed directly by yum.
Install mumin
The installation of munin is divided into three parts:
Master server
Node monitored node
Plugins plug-in (the nginx plug-in seems to be available in the munin installation package, so I don't need to download it any more. I didn't download it anyway. I can get the surveillance image by installing munin directly.)
The only vps I have is both as a monitoring server (master) and as a monitored client (node node).
Execute the following command:
Install on the server side (master):
The code is as follows:
# yum-- enablerepo=epel-y install munin munin-node
Note: if you are only a server, you do not have to install munin-node
After the installation is complete, the following files are created by default:
/ etc/munin/munin.conf: Munin master (server side) configuration file.
/ etc/cron.d/munin: Munin sets the crontab schedule task file.
/ etc/httpd/conf.d/munin.conf: Munin Apache configuration file.
/ var/log/munin: Munin log log directory.
/ var/www/munin: Munin website directory.
/ etc/munin/munin-node.conf: Munin Node node configuration file (specifies which nodes to monitor).
/ etc/munin/plugins.conf: Munin plugins plug-in configuration file.
/ etc/rc.d/init.d/munin-node: Munin startup script
/ etc/munin/plugin-conf.d/munin-node
Server master will not add any service, but it will automatically add a cron task to collect node information every 5 minutes. If it is not added, you can join it manually:
The code is as follows:
# crontab-e
* / 5 * / usr/bin/munin-cron
Note: this default installation has already set up scheduled tasks. After the configuration, we can judge whether the information is being collected continuously by drawing the statistical curve of munin.
Install on the client (node):
The code is as follows:
# yum-- enablerepo=epel-y install munin-node
Note: if you want to monitor N servers, you only need to install munin-node on these N servers.
Configure munin and nginx
I set up a vhost for munin to access munin's monitoring page directly with a specified secondary domain name, such as my munin website: http://test.dabu.info/munin
Server-side (master) configuration web:
Nginx:
Use test.dabu.info to visit the munin website here
Create a new virtual host (Virtual Host) for nginx, and change the server {} segment in its vhost configuration file to
The code is as follows:
Server {
Listen 80
Access_log logs/server-access_log
# set the secondary domain name to access munin. Of course, you can also use vps public network ip to access it.
# but I set up on vps to prohibit ip from accessing the website
Server_name test.dabu.info
Server_name_in_redirect off
Root / var/www/html
# set a password to restrict access to munin websites
Location / munin {
Auth_basic "Administrator Login"
Auth_basic_user_file / var/www/.htpasswd
}
# the following is to open the http_stub_status_module module for vhost
# this location can be put into any server {}, and some can be put directly into the virtual machine server {} of munin.
Location / nginx_status {
Stub_status on
Access_log off
# only allow local access to request statistics in / nginx_status
# if there are no two lines below, then others can use the
# http://test.dabu.info/nginx_status saw the information of nginx's request
# 175.0.137.58 is your vps public network ip
Allow 175.0.137.58
Deny all
}
}
Note: if you separate the location / nginx_status {} segment from the munin virtual host configuration file and put it into a separate server {} section, you should first create a new virtual host to open the http_stub_status_module module and change its server {} to look like the following:
The code is as follows:
Server
{
Listen 127.0.0.1
Server_name localhost
Location / nginx_status {
Stub_status on
Access_log off
Allow 127.0.0.1
Deny all
}
}
At the same time, change the server segment of munin virtual machine to:
The code is as follows:
Server {
Listen 80
Access_log logs/server-access_log
Server_name test.dabu.info
Server_name_in_redirect off
Root / var/www/html
Location / munin {
Auth_basic "Administrator Login"
Auth_basic_user_file / var/www/.htpasswd
}
}
At this point, you can only access http://localhost/nginx_status locally to get the request information of nginx.
Save it after modification. Then restart nginx
The code is as follows:
# service nginx restart
Apache:
The code is as follows:
# vi / etc/httpd/conf.d/munin.conf
Add the following at the end of the file:
The code is as follows:
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 192.168.1.0/24
Restart apache as well:
The code is as follows:
# service httpd restart
Now you can use http://test.dabu.info/munin to visit munin's web page. However, because we use the account password to restrict access, we also have to set the access password.
Set the account and password to access the website:
The default munin Web site file directory for yum installation munin is in / var/www/html/munin. Create a user password for the munin directory and execute the command:
The code is as follows:
# htpasswd-c / var/www/.htpasswd dabu / / create a new user named dabu
Then the following will be displayed, allowing you to set the password and enter the password twice (the password will not be displayed):
The code is as follows:
New password:
Re-type new password:
Adding password for user dabu
After adding the password, go ahead and set up the configuration file for munin. Http://test.dabu.info/munin is the munin I installed, account: dabu, password: dabu1
Set the environment parameters for munin:
Edit the / etc/munin/plugin-conf.d/munin-node file, the purpose of this configuration file:
1. Tell munin where to get the parameters
If you are monitoring nginx, you need to add the following to the end of the / etc/munin/plugin-conf.d/munin-node file. So that munin can get request and other information from http_stub_status_module module.
A. when the location / nginx_status {} segment is in the server {} of the munin virtual machine, add the following
The code is as follows:
[nginx*]
Env.url http://test.dabu.info/nginx_status
B. when the location / nginx_status {} segment is placed separately in a server {}, the following is added
The code is as follows:
[nginx*]
Env.url http://localhost/nginx_status
Or execute the following command directly:
# if [[$(cat / etc/munin/plugin-conf.d/munin-node | grep "nginx") = "]]; then echo-e"\ n [Nginx *]\ nenv.url http://test.dabu.info/nginx_status" > > / etc/munin/plugin-conf.d/munin-node; fi
Note: replace http://test.dabu.info/nginx_status with the URL you set to access request
Account password parameters of 2.munin login software
For example, to monitor mysql, you need to tell munin the account password to log in to mysql, or even the mysql path, etc.
Soft link the two plug-ins of munin, nginx_request and nginx_status, into / etc/munin. Of course, the official has given the script to quickly configure the plug-in and run the command:
The code is as follows:
# munin-node-configure-- shell-- families=contrib,auto | sh-x
If the soft connection is not created successfully, manually execute the following two commands:
The code is as follows:
# ln-s / usr/share/munin/plugins/nginx_request / etc/munin/plugins/-v
# ln-s / usr/share/munin/plugins/nginx_status / etc/munin/plugins/-v
Remote monitoring of multiple server clients (node):
Suppose I want to collect the health status of 192.168.1.10, 192.168.1.11, 192.168.1.12 servers, then
The code is as follows:
# vi / etc/munin/munin.conf
# add the node to be collected:
The code is as follows:
[luxiang2f;mysqlsrv]
Address 192.168.1.10
Use_node_name yes
[luxiang3f;websrv]
Address 192.168.1.11
Use_node_name yes
[nanyuan2f;websrv]
Address 192.168.1.1
Use_node_name yes
# the semicolon is preceded by the group name, followed by the node name
# use_node_name yes means to use the group name and node name defined above, otherwise a DNS query will be executed to check the DNS name of the node
# address indicates the ip address of the node
# in version 1.4.5, grouping or generating errors, some charts can not be generated, don't bother to think about it, just change it to [websrvxxx] and you can succeed.
# looks like it's changed to "." to separate groups instead of semicolons. Specifically, I don't bother to try.
See the official document: http://munin-monitoring.org/wiki/munin-node.conf
Client (node) configuration operation:
Server collection is allowed, assuming that the server IP is 192.168.1.10. At the same time, 4949 tcp port should be opened on the client node, which can be specified in / etc/munin/munin-node.conf.
a. When a vps acts as both a server and a client. To change the operation or to operate on the server, execute the following command:
The code is as follows:
# vi / etc/munin/munin-node.conf
You can see that the line allow ^ 127\. 0\. 1$ is available by default. Explain that when vps acts as both a server and a client. Allow the machine to collect itself. So, if you're just monitoring yourself, you don't need to modify the configuration file.
b. When this vps acts only as a server, you need to execute the following command on the client:
The code is as follows:
# vi / etc/munin/munin-node.conf
Add server ip to the bottom line, allowing the server to collect
The code is as follows:
Allow ^ 192\ .168\ .1\ .10 $
Remember to write in this form. There are more descriptions in / etc/munin/munin-node.conf.
Then restart the service on both the server and the client:
The code is as follows:
# service munin-node restart
Or
The code is as follows:
# / etc/init.d/munin-node restart
Join the service and boot up:
The code is as follows:
# chkconfig-- levels 235 munin-node onn
The way to test whether the munin configuration is good:
The code is as follows:
[root@ksharpdabu ~] # munin-run nginx_request
Display: request.value 3
Note:
A. 3 represents the number of requests received instantly by my nginx. So, that may not be 3, it's some other number. This number may change all the time, after all, the people who visit your site at different times must be different.
b. If the result you get is request.value U. So it means that munin has not collected the information of nginx. There is something wrong with the configuration of your munin.
c. It is possible to report other errors, so go to google according to the error information.
After the test is successful, you can directly access http://test.dabu.info/munin to check the status of the server. By default, cpu, memory, hard disk, network and so on no longer need to be configured separately, you can view them directly.
This is how to use Munin to monitor the server in CentOS shared by Xiaobian. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.