#!/bin/bash #配置参数 serverIP=192.168.1.16 network=ens32 #关闭selinux setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=disable/g' /etc/selinux/config #关闭防火墙 systemctl stop firewalld.service systemctl disable firewalld.service #创建目录 unzip /mnt/ganglia_server.zip cd /mnt/ganglia_server #解压文件 unzip yilai_1.zip unzip yilai_2.zip unzip yilai_3.zip unzip yilai_4.zip unzip yilai_5.zip unzip yilai_6.zip cp rpmbuild.zip /root cd /root && unzip rpmbuild.zip echo "tar complete!" sleep 5 #启动安装依赖 echo "step 1 start" cd /mnt/ganglia_server/yilai_1 && rpm -ivh * --nodeps --force sleep 30 echo "step 2 start" cd /mnt/ganglia_server/yilai_2 && rpm -ivh * --nodeps --force sleep 30 echo "step 3 start" cd /mnt/ganglia_server/yilai_3 && rpm -ivh * --nodeps --force sleep 20 echo "Rely on complete!" #安装gmetad cd /mnt/ganglia_server && rpm -ivh epel-release-latest-7.noarch.rpm --nodeps --force sleep 10 cd /mnt/ganglia_server/yilai_4 && rpm -ivh * --nodeps #sleep 5 #rpmbuild -tb /mnt/ganglia_server/ganglia-3.7.2.tar.gz sleep 5 cd /root/rpmbuild/RPMS/x86_64/ && rpm -ivh /root/rpmbuild/RPMS/x86_64/* --nodeps --force echo "gmetad complete!" #安装gweb cd /mnt/ganglia_server/yilai_5 && rpm -ivh * --nodeps --force sleep 30 cd /mnt/ganglia_server/yilai_6 && rpm -ivh * --nodeps --force sleep 30 mkdir -p /var/www/html tar zxf /mnt/ganglia_server/ganglia-web-3.7.2.tar.gz -C /var/www/html/ cd /var/www/html/ mv ganglia-web-3.7.2 ganglia ln -s /var/lib/ganglia /var/lib/ganglia-web mkdir -p /var/lib/ganglia-web/ /{compiled,cache} –p chown -R apache:apache /var/lib/ganglia chown -R apache:apache /var/lib/ganglia-web/* cd /var/www/html/ganglia && make install chown -R apache:apache -R /var/lib/ganglia/* echo "web complete!" #修改gmond配置文件 sed -i 's/# setuid_username "nobody"/ setuid_username "apache"/g' /etc/ganglia/gmetad.conf sed -i 's/data_source "my cluster" localhost/localhost/data_source "hadoop_zw" $serverIP/g' /etc/ganglia/gmetad.conf sed -i 's/ name = "unspecified"/ name = "hadoop_zw"/g' /etc/ganglia/gmond.conf ip route add 239.2.11.71 dev $network sleep 10 #启动服务 systemctl restart gmond.service systemctl restart gmetad.service systemctl restart httpd.service echo "all complete!" #配置开启启动 chmod 777 /etc/rc.d/rc.local echo "systemctl restart gmond.service" >> /etc/rc.d/rc.local echo "systemctl restart gmetad.service" >> /etc/rc.d/rc.local echo "systemctl restart httpd.service" >> /etc/rc.d/rc.local