1.环境准备。
redis和mysql是必备的,nginx最后做反向代理用。
yum install -y redis mysql-server nginx
chkconfig redis on
chkconfig mysqld on
chkconfig nginx on
service redis start
service mysqld start
service nginx start
2.数据库初始化和数据导入
cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git
cd /tmp/falcon-plus/scripts/mysql/db_schema/
mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql
如果从v1升级到当前版本v2,那么只需要执行如下命令:
mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql
3.准备go语言环境,因为我是源码编译安装的,go版本必须是1.6以上,不然编译的时候回提示缺少包什么的。
wget https://www.golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz
tar xvf https://www.golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz -C /usr/local/
添加环境变量
vim /etc/profile
export GOROOT=$HOME/go
export GOPATH=$HOME/workspace
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
查看go环境
[root@open-falcon src]# go version
go version go1.9.2 linux/amd64
4.创建编译环境和程序打包
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
cd $GOPATH/src/github.com/open-falcon/falcon-plus/
# make all modules
make all
# make specified module
make agent
# pack all modules
make pack
当前目录回生成一个open-falcon-v0.2.1.tar.gz,拿着这个包就可以去部署了。
5.open-falcon 部署
#创建后端部署目录
[root@open-falcon /]#mkdir /data/open-falcon
[root@open-falcon /]#tar xvf open-falcon-v0.2.1.tar.gz -C /data/open-falcon
[root@open-falcon /]# cd /data/open-falcon/
[root@open-falcon open-falcon]# ls
agent aggregator alarm api data gateway graph hbs judge nodata open-falcon plugins public transfer
#启动后端服务
[root@open-falcon open-falcon]# ./open-falcon start
[falcon-graph] 10645
[falcon-hbs] 10660
[falcon-judge] 10674
[falcon-transfer] 10685
[falcon-nodata] 10696
[falcon-aggregator] 10706
[falcon-agent] 10719
[falcon-gateway] 10729
[falcon-api] 10740
[falcon-alarm] 10753
[root@open-falcon open-falcon]#
# 检查所有模块的启动状况
[root@open-falcon open-falcon]# ./open-falcon check
falcon-graph UP 10645
falcon-hbs UP 10660
falcon-judge UP 10674
falcon-transfer UP 10685
falcon-nodata UP 10696
falcon-aggregator UP 10706
falcon-agent UP 10719
falcon-gateway UP 10729
falcon-api UP 10740
falcon-alarm UP 10753
#拉取前端代码(前端代码部署在/data/open-falcon目录下和后端模块代码放在一起)
[root@open-falcon /]# cd /data/open-falcon/
[root@open-falcon open-falcon]#git clone https://github.com/open-falcon/dashboard.git
Initialized empty Git repository in /data/open-falcon/dashboard/.git/
remote: Counting objects: 1044, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 1044 (delta 0), reused 1 (delta 0), pack-reused 1039
Receiving objects: 100% (1044/1044), 1.43 MiB | 285 KiB/s, done.
Resolving deltas: 100% (561/561), done.
#前端代码目录dashboard
[root@open-falcon open-falcon]# ls
agent aggregator alarm api dashboard data gateway graph hbs judge nodata open-falcon plugins public transfer
#安装前端依赖包
yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall "Development tools"
[root@open-falcon dashboard]# cd /data/open-falcon/dashboard/
[root@open-falcon dashboard]# virtualenv ./env
New python executable in ./env/bin/python
Please make sure you remove any previous custom paths from your /root/.pydistutils.cfg file.
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
[root@open-falcon dashboard]# ./env/bin/pip install -r pip_requirements.txt -i http://pypi.douban.com/simple
#前端应用的配置文件
/data/open-falcon/dashboard/rrd/config.py
## API_ADDR 表示后端api组件的地址
API_ADDR = "http://127.0.0.1:8080/api/v1"
## 根据实际情况,修改PORTAL_DB_*, 默认用户名为root,默认密码为""
## 根据实际情况,修改ALARM_DB_*, 默认用户名为root,默认密码为""
#启动前端
[root@open-falcon dashboard]# ./control start
falcon-dashboard started..., pid=12148
#关闭前端
[root@open-falcon dashboard]# ./control stop
falcon-dashboard quit...
[root@open-falcon dashboard]#
#查看日志
[root@open-falcon dashboard]# ./control tail
[2017-11-03 15:59:11 +0000] [12154] [INFO] Booting worker with pid: 12154
[2017-11-03 15:59:11 +0000] [12157] [INFO] Booting worker with pid: 12157
[2017-11-03 15:59:11 +0000] [12160] [INFO] Booting worker with pid: 12160
#open-falcon模块的日志文件,都在模块目录下面的var文件下。
6.系统初始化
前端用户需要注册,第一个注册的root账号就是管理员,所以第一件事先注册root用户。
登录服务器的http://ip:8081,注册root用户。
注册完root用户,最好把注册功能关闭,可以通过root创建其他用户的。
需要修改api模块的配置文件,signup_disable改为ture就可以了。
vim /data/open-falcon/api/config/cfg.json
"signup_disable": true,
#重启open-falcon服务使配置生效
7.安装邮件报警模块
我的环境是阿里云,阿里云的ECS服务器,防火墙限制25端口,根本连不通外网的邮件服务器,所以要对邮件接口做smtps处理。需要接口的同学留邮箱,我回发给你们。
[root@open-falcon]# tar xvf mail-provider.tar.gz -C /data/open-falcon/
[root@open-falcon]# ls /data/open-falcon/mail-provider
cfg.json config control falcon-mail-provider http main.go README.md var
#给主程序加执行权限
[root@open-falcon]# cd /data/open-falcon/mail-provider
[root@open-falcon mail-provider]# chmox +x control falcon-mail-provider
#修改配置文件,填写smtp服务器地址,邮箱信息(注意端口只支持465)。
[root@open-falcon mail-provider]# vim cfg.json
{
"debug": true,
"http": {
"listen": "0.0.0.0:4000",
"token": ""
},
"smtp": {
"addr": "smtp.mxhichina.com:465",
"username": "xxx@xx.com.cn",
"password": "xxxxx",
"from": "xxx@xx.com.cn"
}
}
#启动邮件接口
[root@open-falcon mail-provider]# ./control start
falcon-mail-provider started..., pid=12641
#查看接口状态
[root@open-falcon mail-provider]# ./control tail
2017/11/03 17:00:26 config.go:68: load configuration file cfg.json successfully
2017/11/03 17:00:26 http.go:25: http listening 0.0.0.0:4000
#测试邮件接口
curl http://127.0.0.1:4000/sender/mail -d "tos=XXX@qq.com&subject=xx&content=yy"
如果smtp服务器,邮箱信息都没错,应该可以发出测试邮件的。
因我暂时没有短信通道,所以没弄短信报警。v2也支持微信报警的, 前提是你要有公众号。
服务器端部署大概就这些。
客户端部署:
1.客户端只需要部署agent模块,修改配置文件。
在服务器端/data/open-falcon/目录下,打包agent目录传到客户端。
tar xvf agent.tar.gz -C /data/open-falcon/
cd /data/open-falcon/agent
vim config/cfg.json
"hostname": "xwwd-bailor" #默认为空,抓取hostname,这个最好自己定义下
"heartbeat": #心跳服务器
"addr":"0.0.0.0:6030" #ip地址指向服务器内网ip,端口不要乱改
"interval": 60 #每隔多久秒发送一次信息
"transfer": #传输模块
"addr":"0.0.0.0:8433" #ip地址指向服务器内网,端口不要乱改
本文档详细介绍了open-falcon v2的部署步骤,包括环境准备(redis、mysql和nginx)、数据库初始化、Go语言环境配置、程序编译与打包、open-falcon部署、系统初始化(注册root用户)、邮件报警模块安装。对于客户端,只需部署agent模块并修改配置。部署过程中涉及阿里云ECS的防火墙设置和SMTP服务器配置。

2379

被折叠的 条评论
为什么被折叠?



