1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!/bin/bash
#This is Open-Falcon install script
#Data is 2018/1/10
#Editer Zhanxing
#本脚本使用Red 7和CentOS 7系统安装Open-Falcon
install_preparation()
{
yum
install
-y wget vim
yum
install
-y git pip epel-release golang redis
python get-pip.py
pip
install
gunicorn
systemctl start redis
systemctl
enable
redis
systemctl stop firewalld
systemctl disable firewalld
sed
-i
"s/SELINUX=enforcing/SELINUX=disabled/"
/etc/selinux/config
setenforce 0
}
install_mysql()
{
wget -P
/tmp
http:
//repo
.mysql.com
/mysql-community-release-el7-5
.noarch.rpm
if
[ $? -
eq
0 ];
then
echo
"mysql yum源下载成功"
else
echo
"mysql yum源下载失败"
exit
fi
rpm -ivh
/tmp/mysql-community-release-el7-5
.noarch.rpm
yum
install
mysql-server -y
if
[ $? -
eq
0 ];
then
echo
"mysql 安装成功"
else
echo
"mysql 安装失败"
exit
fi
systemctl start mysql
systemctl
enable
mysql
echo
"自行设置MySQL密码,方便记录"
read
-p
"please input mysql password:"
pwd
mysqladmin -u root password
"$pwd"
export
GOROOT=
/usr/lib/golang
export
GOPATH=
/home
mkdir
-p $GOPATH
/src/github
.com
/open-falcon
cd
$GOPATH
/src/github
.com
/open-falcon
git clone https:
//github
.com
/open-falcon/falcon-plus
.git
if
[ $? -
eq
0 ];
then
echo
"git源码成功"
else
echo
"git源码失败"
exit
fi
cd
$GOPATH
/src/github
.com
/open-falcon/falcon-plus/scripts/mysql/db_schema/
#mysql -u root -p123.com < /home/src/github.com/open-falcon/falcon-plus/scripts/mysql/db_schema/1_uic-db-schema.sql
mysql -h 127.0.0.1 -u root -p$
pwd
< 1_uic-db-schema.sql
mysql -h 127.0.0.1 -u root -p$
pwd
< 2_portal-db-schema.sql
mysql -h 127.0.0.1 -u root -p$
pwd
< 3_dashboard-db-schema.sql
mysql -h 127.0.0.1 -u root -p$
pwd
< 4_graph-db-schema.sql
mysql -h 127.0.0.1 -u root -p$
pwd
< 5_alarms-db-schema.sql
cd
$GOPATH
/src/github
.com
/open-falcon/falcon-plus/
go get github.com
/open-falcon/rrdlite
make
all
make
pack
}
install_after()
{
export
WORKSPACE=
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-falcon
start
if
[ $? -
eq
0 ];
then
echo
"open-falcon启动成功"
else
echo
"open-falcon启动失败"
exit
fi
}
install_before()
{
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
"git 前端代码成功"
else
echo
"git 前端代码失败"
exit
fi
yum
install
-y python-virtualenv python-devel openldap-devel mysql-devel
yum groupinstall
"Development tools"
-y
cd
$FRONTSPACE
/dashboard/
virtualenv .
/env
.
/env/bin/pip
install
-r pip_requirements.txt
bash
control start
if
[ $? -
eq
0 ];
then
echo
"dashboard启动成功"
else
echo
"dashboard启动失败"
exit
fi
}
#检测网络
ping
-c 1 -t 1 www.baidu.com >
/dev/null
2>&1
if
[[ \$? == 2 ]];
then
echo
"nameserver 114.114.114.114
nameserver 8.8.8.8" >
/etc/resolv
.conf
fi
ping
-c 1 -t 1 www.baidu.com >
/dev/null
2>&1
if
[[ $? == 2 ]];
then
echo
"Network problems,Please check!"
exit
fi
#更换阿里YUM源和fedora的epel仓库
yum
install
wget vim net-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
.repo http:
//mirrors
.aliyun.com
/repo/Centos-7
.repo
yum clean all
yum makecache
yum
install
-y epel-release
#开始安装
echo
"1 安装准备环境"
echo
"2 安装MySQL"
echo
"3 安装后端组件"
echo
"4 安装前端组件"
echo
"5 单机组合安装"
echo
"输入您需要安装的组件编号[1-5]"
read
aNum
case
$aNum
in
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
|
本文转自 Bill_Xing 51CTO博客,原文链接:http://blog.51cto.com/zhanx/2061307