yum的安装配置参见我转的博客:http://blog.youkuaiyun.com/yu_fu/article/details/17096041
软件仓库 epel
直接使用epel源中的ganglia(自己编译安装有点小麻烦)。
1. 安装epel源
1 wget http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm -P /usr/local/src
2 rpm -ivh /usr/local/src/epel-release-6-5.noarch.rpm
3 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
2. ganglia服务端安装gemtad和gmond
4 yum install ganglia ganglia-devel ganglia-gmetad ganglia-gmond ganglia-web ganglia-gmond-python
会自动安装相应的依赖包。
3. 其他服务器(作为客户端)只需安装gmond
5 yum install ganglia ganglia-gmond
4. 配置ganglia的gemtad
6 cd /etc/ganglia
7 vi gmetad.conf
8 data_source "ganglia_hadoop" 192.168.255.128 192.168.255.130 192.168.255.131
修改数据源data_source这一行即可。
data_source "name" ip01:port01 ip02:port02 ...
说明:后面这些IP地址就是进行监控的主机,冒号后面跟的是要监听的端口号(默认为8649)。
启动服务
9 service gmetad start
10 chkconfig gmetad on
5. 所有服务器配置客户端gmond(使用多播)
11 vi /etc/ganglia/gmond.conf
12 cluster {
13 name = "ganglia_hadoop"
14 ...
只需将集群的name设置为gmetad中data_source设置的名字即可。
启动服务
15 service gmond start
6. 配置nginx
16 vi /usr/local/nginx/conf/vhosts/ganglia.conf
17 server
18 {
19 listen 80;
20 server_name 域名;
21 index index.html index.htm index.php;
22 root /usr/share/ganglia;
23
24 location ~ ^(.*)\/\.svn\/
25 {
26 deny all;
27 }
28
29 location ~ .*\.(php|php5)?$
30 {
31 # fastcgi_pass unix:/tmp/php-cgi.sock;
32 fastcgi_pass php_server01;
33 fastcgi_index index.php;
34 include fcgi.conf;
35 }
36
37 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
38 {
39 expires 30d;
40 access_log off;
41 }
42
43 location ~ .*\.(js|css)?$
44 {
45 expires 1h;
46 access_log off;
47 }
48
49 log_format ganglia '$remote_addr - $remote_user [$time_local] [$request_time] "$request"'
50 '$status $body_bytes_sent "$http_referer"'
51 '"$http_user_agent" $http_x_forwarded_for';
52 access_log off;
53 }
主目录为:/usr/share/ganglia
可以添加通过nginx设置用户名密码访问和限制IP访问。
访问http://域名
会报错:
Notice: Undefined variable: private in /usr/share/ganglia/auth.php on line 27
因为我的php-fpm的运行用户为nobody,程序auth.php中fopen打开的文件为private_clusters,链接到/etc/ganglia/private_clusters,查看文件的拥有者
54 ls -l /etc/ganglia/private_clusters
55 -rw-r----- 1 root apache 1222 Feb 17 2010 /etc/ganglia/private_clusters
组拥有者为apache,修改组为php-fpm运行的用户即可。
56 chown root:nobody /etc/ganglia/private_clusters