Deployment Guide from finishing the last of the open-falcon ( https://www.cnblogs.com/straycats/p/7199209.html ) has been more than a year, then just contact with linux, a lot of things in order is not very reasonable (for example, Some description of the operation), the deployment of some of the content is not very strict (such as how to boot from Kai).
Just recently doing the monitoring system of selection, open-falcon I was again out as a test target. Later, some of the differences between 0.2.1 and 0.2.0 deployment, I decided to re-deploy for 0.2.1 compile a manual for reference passers together.
As the new document to change some of the deployment paths and configure content before the document, based on the recommendations capability is not strong students can ignore my 17 years of finishing 0.2.0 version of the Deployment Guide, direct look at this manual.
Before deploying a system, the first concern of the entire architecture, where the official map directly to the Pirates over.
First, prepare the environment
OS: CentOS 7.6 ( www.centos.org
Virtual machine IP: 192.168.12.55
1.1 Configure the firewall
# In order to facilitate you can choose to directly turn off the firewall
systemctl stop firewalld
systemctl disable firewalld
Of course, if you need to open the firewall, open ports on the need to open several businesses.
Service Module | Features | port |
hbs | Connect all service agent heartbeat | 6030 |
transfer | Receiving the monitoring data sent from the agent | 8433 |
dashboard | page | 8081 |
firewall-cmd --add-port=6030/tcp --permanent
firewall-cmd --add-port=8433/tcp --permanent
firewall-cmd --add-port=8081/tcp --permanent
firewall-cmd --reload
1.2 安装wget、vim
yum install -y wget vim
1.3 安装git
yum install -y git
安装结束后,确认是否满足官方要求的Git >= 1.7.5
git version
1.4 安装golang
# 通过fedora的epel仓库来安装golang
yum install -y epel-release
yum install -y golang
安装结束后,确认是否满足官方要求的Go >= 1.6
go version
1.5 安装redis
# 通过fedora的epel仓库来安装redis
yum install -y epel-release
yum install -y redis
systemctl start redis
systemctl enable redis
1.6 安装mysql 5.6
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install -y mysql-server
systemctl start mysql
PS.通过这种方式的mysql是默认开机启动的。
1.7 设置临时变量(临时生效的变量,换一个会话(shell终端)这个变量就没有了)
export GOROOT=/usr/lib/golang
export GOPATH=/opt/git
1.8 从github上拉取后端(open-falcon)的源码
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
PS.通过git clone经常龟速,所以可以通过本地获取源码后,将源码文件上传到/opt/git/src/github.com/open-falcon/falcon-plus目录下。
1.9 初始化数据库
cd $GOPATH/src/github.com/open-falcon/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
PS.在运行“mysql -h..................”时会提示“Enter password”,如果mysql的root没有设置密码,回车即可。
1.10 编译后端的源码并打包
cd $GOPATH/src/github.com/open-falcon/falcon-plus
make all
PS.17年部署0.2.0时还需要手动获取rrdtool工具包,现在(19年)的版本(0.2.1)试下来已经不用了.
make pack
打包完成后,/opt/git/src/github.com/open-falcon/falcon-plus/目录下多了刚才打的压缩包“open-falcon-v0.2.1.tar.gz”(因为整理手册的时候版本已经到了0.2.1)。
二、部署后端
v0.2后端分为下面几个服务模块:
功能 | |
---|---|
alarm | alarm模块是处理报警event的,judge产生的报警event写入redis,alarm从redis读取处理,并进行不同渠道的发送。 |
agent | agent用于采集机器负载监控指标,比如cpu.idle、load.1min、disk.io.util等等,每隔60秒push给Transfer。agent与Transfer建立了长连接,数据发送速度比较快,agent提供了一个http接口/v1/push用于接收用户手工push的一些数据,然后通过长连接迅速转发给Transfer |
aggregator | 集群聚合模块。聚合某集群下的所有机器的某个指标的值,提供一种集群视角的监控体验。 |
api | api模块提供统一的restAPI操作接口。比如:api组件接收查询请求,根据一致性哈希算法去相应的graph实例查询不同metric的数据,然后汇总拿到的数据,最后统一返回给用户。 |
gateway | 没有遇到机房分区问题,可以忽略此模块。 |
graph | graph是存储绘图数据的组件。graph组件 接收transfer组件推送上来的监控数据,同时处理api组件的查询请求、返回绘图数据。 |
hbs | HBS(Heartbeat Server)心跳服务器,公司所有agent都会连到HBS,每分钟发一次心跳请求。 |
judge | 用于告警判断,agent将数据push给Transfer,Transfer不但会转发给Graph组件来绘图,还会转发给Judge用于判断是否触发告警。 |
nodata | nodata用于检测监控数据的上报异常。nodata和实时报警judge模块协同工作,过程为: 配置了nodata的采集项超时未上报数据,nodata生成一条默认的模拟数据;用户配置相应的报警策略,收到mock数据就产生报警。采集项上报异常检测,作为judge模块的一个必要补充,能够使judge的实时报警功能更加可靠、完善。 |
task | task是监控系统一个必要的辅助模块。定时任务,实现了如下几个功能:index更新(包括图表索引的全量更新 和 垃圾索引清理)、falcon服务组件的自身状态数据采集(采集了transfer、graph、task这三个服务的内部状态数据)、falcon自检控任务 |
transfer | 数据转发服务。它接收agent上报的数据,然后按照哈希规则进行数据分片、并将分片后的数据分别push给graph&judge等组件。 |
2.1 设置临时变量
export BACKSPACE=/opt/open-falcon/back
2.2 创建目录
mkdir -p $BACKSPACE
2.3 解压包
cd $GOPATH/src/github.com/open-falcon/falcon-plus
tar -xzvf open-falcon-v0.2.1.tar.gz -C $BACKSPACE
2.4 修改配置文件cfg.json
根据本教程的配置,需要修改模块如下:
配置文件所在路径 | |
---|---|
aggregator | /opt/open-falcon/back/aggregator/config/cfg.json |
graph | /opt/open-falcon/back/graph/config/cfg.json |
hbs | /opt/open-falcon/back/hbs/config/cfg.json |
nodata | /opt/open-falcon/back/nodata/config/cfg.json |
api | /opt/open-falcon/back/api/config/cfg.json |
alarm | /opt/open-falcon/back/alarm/config/cfg.json |
vim /opt/open-falcon/back/aggregator/config/cfg.json
PS.我部署mysql的root密码为空,所以不需要填“password”;若mysql的root密码不为空,则用root密码替换“password”。
vim /opt/open-falcon/back/graph/config/cfg.json
PS.我部署mysql的root密码为空,所以不需要填“password”;若mysql的root密码不为空,则用root密码替换“password”。
vim /opt/open-falcon/back/hbs/config/cfg.json
PS.我部署mysql的root密码为空,所以不需要填“password”;若mysql的root密码不为空,则用root密码替换“password”。
vim /opt/open-falcon/back/nodata/config/cfg.json
PS.我部署mysql的root密码为空,所以不需要填“password”;若mysql的root密码不为空,则用root密码替换“password”。
vim /opt/open-falcon/back/api/config/cfg.json
PS.我部署mysql的root密码为空,所以不需要填“password”;若mysql的root密码不为空,则用root密码替换“password”。
vim /opt/open-falcon/back/alarm/config/cfg.json
PS.我部署mysql的root密码为空,所以不需要填“password”;若mysql的root密码不为空,则用root密码替换“password”。
2.5 启动后端
cd /opt/open-falcon/back
./open-falcon start
2.6 设置开机启动
请参考“四、设置开机启动”。
2.7 其他操作命令
open-falcon还提供了下面这些命令:
cd /opt/open-falcon/back
./open-falcon check
cd /opt/open-falcon/back
./open-falcon stop
cd /opt/open-falcon/back
./open-falcon start alarm
cd /opt/open-falcon/back
./open-falcon stop alarm
cd /opt/open-falcon/back
./open-falcon restart alarm
三、部署前端
3.1 设置临时变量
#
export FRONTSPACE=/opt/open-falcon/front
3.2 创建目录
mkdir -p $FRONTSPACE
cd $FRONTSPACE
git clone https://github.com/open-falcon/dashboard.git
PS.通过git clone经常龟速,所以可以通过本地获取源码后,将源码文件上传到/opt/open-falcon/front/dashboard目录下。
3.4 安装依赖
yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall -y "Development tools"
cd $FRONTSPACE/dashboard
virtualenv ./env
./env/bin/pip install -r pip_requirements.txt
PS.官方教程中使用了下面的命令安装依赖包(指定了安装包的源地址)
./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
3.5 修改配置
根据本教程的配置,dashboard的配置文件在/opt/open-falcon/front/dashboard/rrd/config.py
爬坑点:
原本不接入LDAP、数据库root账号密码为空不需要修改配置,但是官方给出的配置文件在这里留了一个坑:PORTAL_DB的用户名/密码初始为falcon/falcon。
这个坑最终会导致dashboard登录后的“HostGroups”、“Templates”、“Expressions”、“Nodata”,下面提供解决方案,也就是将错误的初始配置改过来。
vim /opt/open-falcon/front/dashboard/rrd/config.py +33
将portal的数据库用户名改为root,密码改为空,wq保存。
cd $FRONTSPACE/dashboard
bash control start
cd /opt/open-falcon/front/dashboard
bash control status
cd /opt/open-falcon/front/dashboard
bash control stop
cd /opt/open-falcon/front/dashboard
./env/bin/python wsgi.py
由于open-falcon没有service实现开机启动,所以需要额外找方案来解决这个问题。
这里提供一套方案:通过进程守护服务(Supervisor)实现open-falcon的开机启动。
yum install -y python-setuptools
easy_install supervisor
mkdir -p /etc/supervisor/conf.d
echo_supervisord_conf > /etc/supervisor/supervisord.conf
vim /etc/supervisor/supervisord.conf
将下面的内容添加到supervisord.conf内,wq保存。
[include]
files = conf.d/*.conf
mkdir -p /opt/sh
vim /opt/sh/open-falcon-startup.sh
将下面的内容添加到open-falcon-startup.sh内,wq保存。
#!/bin/bash
sleep 30s && /opt/open-falcon/back/open-falcon start
PS.引入启动脚本(延迟30s启动)的原因:在open-falcon启动时,mysql没有启动完成,将会导致部分服务启动失败,而supervisord又检测不到open-falcon每个服务的进程,结果导致open-falcon部分服务(aggregator、agent、gateway、api、alarm)启动失败。
vim /etc/supervisor/conf.d/open-falcon-back.conf
将下面的内容添加到open-falcon-back.conf内,wq保存。
[program:open-falcon-back]
command=/bin/bash /opt/sh/open-falcon-startup.sh ;运行程序的命令
directory=/opt/open-falcon/back ;命令执行的目录
user=root ; 进程执行的用户身份
autostart=true ;在supervisord启动时运行该程序 autorestart=true ;程序异常退出后自动重启 stdout_logfile=/var/log/open-falcon-back.out.log ;输出日志文件 stdout_logfile_maxbytes=10MB ;输出日志文件大小(10MB) stdout_logfile_backups=5 ;输出日志文件备份数 stderr_logfile=/var/log/open-falcon-back.err.log ;错误日志文件 stderr_logfile_maxbytes=10MB ;错误日志文件大小(10MB) stderr_logfile_backups=5 ;错误日志文件备份数
vim /etc/supervisor/conf.d/open-falcon-front.conf
将下面的内容添加到open-falcon-front.conf内,wq保存。
[program:open-falcon-front]
command=/bin/bash /opt/open-falcon/front/dashboard/control start ;运行程序的命令
directory=/opt/open-falcon/front/dashboard ;命令执行的目录
user=root ; 进程执行的用户身份
autostart=true ;在supervisord启动时运行该程序 autorestart=true ;程序异常退出后自动重启 stdout_logfile=/var/log/open-falcon-front.out.log ;输出日志文件 stdout_logfile_maxbytes=10MB ;输出日志文件大小 stdout_logfile_backups=5 ;输出日志文件备份数 stderr_logfile=/var/log/open-falcon-front.err.log ;错误日志文件 stderr_logfile_maxbytes=10MB ;错误日志文件大小 stderr_logfile_backups=5 ;错误日志文件备份数
vim /usr/lib/systemd/system/supervisord.service
将下面的内容添加到supervisord.service内,wq保存。
[Unit]
Description=Supervisor
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target
systemctl start supervisord
systemctl enable supervisord
supervisorctl status
dashboard没有默认创建任何账号(包括管理员账号),需要通过页面进行注册账号。
注册用户名为root的账号(第一个帐号名称为root的用户,会被自动设置为超级管理员)。
注册账号能够被任何打开dashboard页面的人注册,有时候我们不允许任何人都可以随便访问监控数据。所以当创建完root账号(系统管理员)后,可以关闭注册账号功能。没有接入LDAP的话,可以通过root账号增加用户账号。
配置文件所在路径 | |
---|---|
api | /opt/open-falcon/back/api/config/cfg.json |
vim /opt/open-falcon/back/api/config/cfg.json
将signup_disable配置项修改为true,wq保存。
cd /opt/open-falcon/back
./open-falcon restart api
-
-
没有接入LDAP,不允许用户随意创建账号登录,让管理员用root账号创建用户账号;
-
接入LDAP,直接使用LDAP账号登录;