#!/bin/bash #ThisisOpen-Falconinstallscript #Datais2018/1/10 #EditerZhanxing #本脚本使用Red7和CentOS7系统安装Open-Falcon install_preparation() { yuminstall-ywgetvim yuminstall-ygitpipepel-releasegolangredis pythonget-pip.py pipinstallgunicorn systemctlstartredis systemctlenableredis systemctlstopfirewalld systemctldisablefirewalld sed-i"s/SELINUX=enforcing/SELINUX=disabled/"/etc/selinux/config setenforce0 } install_MysqL() { wget-P/tmphttp://repo.MysqL.com/MysqL-community-release-el7-5.noarch.rpm if[$?-eq0];then echo"MysqLyum源下载成功" else echo"MysqLyum源下载失败" exit fi rpm-ivh/tmp/MysqL-community-release-el7-5.noarch.rpm yuminstallMysqL-server-y if[$?-eq0];then echo"MysqL安装成功" else echo"MysqL安装失败" exit fi systemctlstartMysqL systemctlenableMysqL echo"自行设置MysqL密码,方便记录" read-p"pleaseinputMysqLpassword:"pwd MysqLadmin-urootpassword"$pwd" exportGOROOT=/usr/lib/golang exportGOPATH=/home mkdir-p$GOPATH/src/github.com/open-falcon cd$GOPATH/src/github.com/open-falcon gitclonehttps://github.com/open-falcon/falcon-plus.git if[$?-eq0];then echo"git源码成功" else echo"git源码失败" exit fi cd$GOPATH/src/github.com/open-falcon/falcon-plus/scripts/MysqL/db_schema/ #MysqL-uroot-p123.com</home/src/github.com/open-falcon/falcon-plus/scripts/MysqL/db_schema/1_uic-db-schema.sql MysqL-h127.0.0.1-uroot-p$pwd<1_uic-db-schema.sql MysqL-h127.0.0.1-uroot-p$pwd<2_portal-db-schema.sql MysqL-h127.0.0.1-uroot-p$pwd<3_dashboard-db-schema.sql MysqL-h127.0.0.1-uroot-p$pwd<4_graph-db-schema.sql MysqL-h127.0.0.1-uroot-p$pwd<5_alarms-db-schema.sql cd$GOPATH/src/github.com/open-falcon/falcon-plus/ gogetgithub.com/open-falcon/rrdlite makeall makepack } install_after() { exportWORKSPACE= mkdir-p$WORKSPACE cd$GOPATH/src/github.com/open-falcon/falcon-plus/ tar-xzvf*.tar.gz-C$WORKSPACE sed-i's/root:/root:$pwd/g'/home/work/aggregator/config/cfg.json sed-i's/root:/root:$pwd/g'/home/work/graph/config/cfg.json sed-i's/root:/root:$pwd/g'/home/work/hbs/config/cfg.json sed-i's/root:/root:$pwd/g'/home/work/nodata/config/cfg.json sed-i's/root:/root:$pwd/g'/home/work/api/config/cfg.json sed-i's/root:/root:$pwd/g'/home/work/alarm/config/cfg.json cd$WORKSPACE ./open-falconstart if[$?-eq0];then echo"open-falcon启动成功" else echo"open-falcon启动失败" exit fi } install_before() { exportFRONTSPACE=/home/front/open-falcon mkdir-p$FRONTSPACE cd$FRONTSPACE gitclonehttps://github.com/open-falcon/dashboard.git if[$?-eq0];then echo"git前端代码成功" else echo"git前端代码失败" exit fi yuminstall-ypython-virtualenvpython-developenldap-develMysqL-devel yumgroupinstall"Developmenttools"-y cd$FRONTSPACE/dashboard/ virtualenv./env ./env/bin/pipinstall-rpip_requirements.txt bashcontrolstart if[$?-eq0];then echo"dashboard启动成功" else echo"dashboard启动失败" exit fi } #检测网络 ping-c1-t1www.baidu.com>/dev/null2>&1 if[[\$?==2]];then echo"nameserver114.114.114.114 nameserver8.8.8.8">/etc/resolv.conf fi ping-c1-t1www.baidu.com>/dev/null2>&1 if[[$?==2]];then echo"Networkproblems,Pleasecheck!" exit fi #更换阿里YUM源和fedora的epel仓库 yuminstallwgetvimnet-tools-y mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.bak wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo yumcleanall yummakecache yuminstall-yepel-release #开始安装 echo"1安装准备环境" echo"2安装MysqL" echo"3安装后端组件" echo"4安装前端组件" echo"5单机组合安装" echo"输入您需要安装的组件编号[1-5]" readaNum case$aNumin 1) install_preparation ;; 2) install_MysqL ;; 3) install_after ;; 4) install_before ;; 5) install_preparation install_MysqL install_after install_before echo"安装完成,请通过http://IP:8081进行访问" ;; esac