open-falcon安装自动化部署
程序员文章站
2022-03-04 17:37:40
...
更换yum源的时候请注意,此yum源为centos7的源,如有需要可更改
#!/bin/bash
server=(go git redis mysql-server)
db=(1_uic-db-schema.sql 2_portal-db-schema.sql 3_dashboard-db-schema.sql 4_graph-db-schema.sql 5_alarms-db-schema.sql)
function move_repos () {
mv /etc/yum.repos.d{,.bak}
mkdir /etc/yum.repos.d
cd /etc/yum.repos.d
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum update -y
yum install -y epel-release
if [ $? -eq 0 ]
then
echo "go yum源下载成功"
else
echo "go yum源下载失败"
exit
fi
}
function pd () {
for ((i=0;i<3;i++))
do
P=`rpm -qa|grep ${server[$i]}|wc -l`
if [ $P -ge 1 ]
then
continue
else
if [ i -eq 3]
then
wget -P /tmp http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install ${server[$i]}
if [ $? -eq 0 ]
then
echo "mysql 安装成功"
else
echo "mysql 安装失败"
exit
fi
systemctl start ${server[$i]}
else
yum -y install ${server[$i]}
if [ $? -eq 0 ]
then
echo "${server[$i]} 安装成功"
else
echo "${server[$i]} 安装失败"
exit
fi
systemctl start ${server[$i]}
fi
fi
done
}
function bushu () {
export GOROOT=/usr/lib/golang
export GOPATH=/home
mkdir $/home/src/github.com/open-falcon/ -p
cd /home/src/github.com/open-falcon/
git clone https://github.com/open-falcon/falcon-plus.git
if [ $? -eq 0 ]
then
echo "源码下载成功"
else
echo "源码下载失败"
fi
cd $GOPATH/src/github.com/open-falcon/falcon-plus/scripts/mysql/db_schema/
if ((a=0;a<5;a++))
then
mysql -h 127.0.0.1 -u root -p < ${db[$a]}
fi
}
function bianyi () {
export WORKSPACE=/home/work
mkdir -p $WORKSPACE
cd $GOPATH/src/github.com/open-falcon/falcon-plus/
go get github.com/open-falcon/rrdlite
make all
make pack
if [ $? -eq 0 ]
then
echo "打包成功"
else
echo "打包失败"
exit
fi
cd $GOPATH/src/github.com/open-falcon/falcon-plus/
tar -xzvf open-falcon-v0.2.0.tar.gz -C $WORKSPACE
cd $WORKSPACE
./open-falcon start
if [ $? -eq 0 ]
then
echo "成功启动"
else
echo "启动失败"
exit
fi
export FRONTSPACE=/home/front/open-falcon
mkdir -p $FRONTSPACE
cd $FRONTSPACE
git clone https://github.com/open-falcon/dashboard.git
if [ $? -eq 0 ]
then
echo "web源码下载成功"
else
echo "web源码下载失败"
fi
yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall "Development tools" -y
cd $FRONTSPACE/dashboard/
virtualenv ./env
./env/bin/pip install -r pip_requirements.txt
if [ $? -eq 0 ]
then
echo "web界面安装成功"
else
echo "web界面安装失败"
exit
fi
bash contral start
./env/bin/python wsgi.py
if [ $? -eq 0 ]
then
echo "web界面启动成功"
else
echo "web界面启动失败"
exit
fi
}
echo "1 更换yum源"
echo "2 准备环境"
echo "3 下载源码,部署数据库信息"
echo "4 编译安装"
echo "5 一键安装"
echo "请输入需要安装的组件"
read Num
case $Num in
1)
move_repos
;;
2)
pd
;;
3)
bushu
;;
4)
bianyi
;;
5)
move_repos
pd
bushu
bianyi
echo "安装完成"
;;
esac