Open-Falcon部署分为前端(客户端)/后端(服务端) 和监控机器(agent部署)的安装
注:机器量很小(<100量级)时,前后端可以装在一台机器上
参考官方文档:https://book.open-falcon.org/zh_0_2/distributed_install/agent.html
一 后端(服务端)部署
1、系统环境
[root@open-falcon-server ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
2、软件环境准备
2.1 安装 redis
#安装
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum install redis -y
#redis常用命令
redis-server redis 服务端
redis-cli redis 命令行客户端
redis-benchmark redis 性能测试工具
redis-check-aof AOF文件修复工具
redis-check-dump RDB文件修复工具
redis-sentinel Sentinel 服务端
#启动redis
[root@open-falcon-server ~]# redis-server
2.2 安装mysql
#安装mysql
[root@open-falcon-server ~]#wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@open-falcon-server ~]# ll
[root@open-falcon-server ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
[root@open-falcon-server ~]# cd /etc/yum.repos.d/
[root@open-falcon-server ~]#yum install -y mysql-server
#启动mysql并设置开机自启动
[root@open-falcon-server ~]# systemctl start mysqld.service
[root@open-falcon-server ~]# systemctl enable mysqld.service
[root@open-falcon-server ~]# mysql -uroot -p
(没有密码)
mysql> exit
#检查服务
netstat -lntup
显示tcp6 0 0 :::3306 :::* LISTEN 12813/mysqld
#初始化MySQL表结构(备注:导入表结构后,注意检查)
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
rm -rf /tmp/falcon-plus/
#设置数据库密码 (备注:用户名:root ,密码: password )
[root@open-falcon-server open-falcon]# mysqladmin -uroot password "password"
#检查导入的数据库表
[root@open-falcon-server open-falcon]# mysql -uroot -p
mysql> show databases;
information_schema || alarms || dashboard || falcon_portal || graph || mysql || performance_schema || uicmysql> exit
2.3配置Go语言开发环境
#安装go语言开发包(备注:安装需要epel源)
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
ll
rpm -ivh epel-release-latest-7.noarch.rpmyum install golang -y
#检查版本
[root@open-falcon-server ~]# go version
#查看go的安装路径
[root@open-falcon-server ~]# find / -name go
/etc/alternatives/go
/var/lib/alternatives/go
/usr/bin/go
/usr/lib/golang/src/cmd/go #需要的是这个路径
/usr/lib/golang/src/go
/usr/lib/golang/bin/go
/usr/lib/golang/pkg/linux_amd64/go
#设置环境变量GOROOT和GOPATH
vi /etc/profile
export GOROOT=/usr/lib/golang
export GOPATH=/home
source /etc/profile
3.下载编译好的二进制版本
直接下载官方编译好的二进制版本(x86 64位平台)。
https://github.com/open-falcon/falcon-plus/releases
#开始安装open-falcon
[root@open-falcon-server ~]# export FALCON_HOME=/home/work
[root@open-falcon-server ~]# export WORKSPACE=$FALCON_HOME/open-falcon
[root@open-falcon-server ~]# mkdir -p $WORKSPACE
#上传软件
[root@open-falcon-server ~]# ll
-rw-r--r--. 1 root root 40031472 Oct 29 2017 open-falcon-v0.2.1.tar.gz
#解压
[root@open-falcon-server ~]# tar -xf open-falcon-v0.3.tar.gz -C $WORKSPACE
[root@open-falcon-server ~]# cd $WORKSPACE
#查看解压结果
[root@open-falcon-server open-falcon]# ll
total 3896
drwxrwxr-x. 7 501 501 67 Aug 15 19:16 agent
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 aggregator
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 alarm
drwxrwxr-x. 6 501 501 51 Aug 15 19:16 api
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 gateway
drwxrwxr-x. 6 501 501 51 Aug 15 19:16 graph
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 hbs
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 judge
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 nodata
-rwxrwxr-x. 1 501 501 3987469 Aug 15 19:16 open-falcon
lrwxrwxrwx. 1 501 501 16 Aug 15 19:16 plugins -> ./agent/plugins/
lrwxrwxrwx. 1 501 501 15 Aug 15 19:16 public -> ./agent/public/
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 transfer
4.修改配置文件cfg.json
部分模块依赖连接数据库,因为如果不修改配置文件,aggregator模块会出现无法启动,graph、hbs、nodata、api、alarm模块会出现开启不报错但是状态为开启失败的情况。
如果需要每个模块都能正常启动,需要将上面模块的cfg.json的数据库信息进行修改。需要修改配置文件所在的目录:
1)修改aggregator的配置文件
vim /home/work/aggregator/config/cfg.json
2)修改graph的配置文件
vim /home/work/graph/config/cfg.json
3)修改hbs的配置文件
vim /home/work/hbs/config/cfg.json
4)修改nodata的配置文件
vim /home/work/nodata/config/cfg.json
5)修改api的配置文件
vim /home/work/api/config/cfg.json
6)修改alarm的配置文件
vim /home/work/alarm/config/cfg.json
5.启动后端模块
[root@open-falcon-server open-falcon]# cd /home/work/open-falcon
#启动服务
[root@open-falcon-server open-falcon]# ./open-falcon start
#检查服务启动状态
[root@open-falcon-server open-falcon]# ./open-falcon check
#更多的命令行工具用法
# ./open-falcon [start|stop|restart|check|monitor|reload] module
./open-falcon start agent
#For debugging , You can check $WorkDir/$moduleName/log/logs/xxx.log
6.其它用法
#重载配置(备注:修改vi cfg.json配置文件后,可以用下面命令重载配置)
curl 127.0.0.1:1988/config/reload
二 前端部署
注:机器量很小(<100量级)时,前后端可以装在一台机器上
1、创建工作目录
export HOME=/home/work
export WORKSPACE=$HOME/open-falcon
mkdir -p $WORKSPACE
cd $WORKSPACE
2、克隆前端组件代码
git clone https://github.com/open-falcon/dashboard.git
3、安装依赖包
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 $WORKSPACE/dashboard/
virtualenv ./env
./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
#配置说明:
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-client]#cd /home/work/open-falcon/dashboard/rrd
[root@Open-Falcon-client rrd]# cp config.py config.py.bak
(env)[root@Open-Falcon-client rrd]# vi config.py
#-*-coding:utf8-*-
# Copyright 2017 Xiaomi, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# app config
import os
LOG_LEVEL = os.environ.get("LOG_LEVEL",'DEBUG')
SECRET_KEY = os.environ.get("SECRET_KEY","secret-key")
PERMANENT_SESSION_LIFETIME = os.environ.get("PERMANENT_SESSION_LIFETIME",3600 * 24 * 30)
SITE_COOKIE = os.environ.get("SITE_COOKIE","open-falcon-ck")
# Falcon+ API
API_ADDR = os.environ.get("API_ADDR","http://192.168.1.180:8080/api/v1")
# portal database
# TODO: read from api instead of db
PORTAL_DB_HOST = os.environ.get("PORTAL_DB_HOST","192.168.1.180")
PORTAL_DB_PORT = int(os.environ.get("PORTAL_DB_PORT",3306))
PORTAL_DB_USER = os.environ.get("PORTAL_DB_USER","root")
PORTAL_DB_PASS = os.environ.get("PORTAL_DB_PASS","password")
PORTAL_DB_NAME = os.environ.get("PORTAL_DB_NAME","falcon_portal")
# alarm database
# TODO: read from api instead of db
ALARM_DB_HOST = os.environ.get("ALARM_DB_HOST","192.168.1.180")
ALARM_DB_PORT = int(os.environ.get("ALARM_DB_PORT",3306))
ALARM_DB_USER = os.environ.get("ALARM_DB_USER","root")
ALARM_DB_PASS = os.environ.get("ALARM_DB_PASS","password")
ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms")
# ldap config
LDAP_ENABLED = os.environ.get("LDAP_ENABLED",False)
LDAP_SERVER = os.environ.get("LDAP_SERVER","ldap.forumsys.com:389")
LDAP_BASE_DN = os.environ.get("LDAP_BASE_DN","dc=example,dc=com")
LDAP_BINDDN_FMT = os.environ.get("LDAP_BINDDN_FMT","uid=%s,dc=example,dc=com")
LDAP_SEARCH_FMT = os.environ.get("LDAP_SEARCH_FMT","uid=%s")
LDAP_ATTRS = ["cn","mail","telephoneNumber"]
LDAP_TLS_START_TLS = False
LDAP_TLS_CACERTDIR = ""
LDAP_TLS_CACERTFILE = "/etc/openldap/certs/ca.crt"
LDAP_TLS_CERTFILE = ""
LDAP_TLS_KEYFILE = ""
LDAP_TLS_REQUIRE_CERT = True
LDAP_TLS_CIPHER_SUITE = ""
# i18n
BABEL_DEFAULT_LOCALE = 'zh_CN'
BABEL_DEFAULT_TIMEZONE = 'Asia/Shanghai'
# aviliable translations
LANGUAGES = {
'en': 'English',
'zh_CN': 'Chinese-Simplified',
}
# portal site config
MAINTAINERS = ['root']
CONTACT = '[email protected]'
try:
from rrd.local_config import *
except:
print "[warning] no local config file"
#启动服务
有两种方法:
法一:
(env)[root@Open-Falcon-client dashboard]# bash control start
falcon-dashboard started..., pid=40853
法二:
(env)[root@Open-Falcon-client dashboard]# ./control start
falcon-dashboard started..., pid=40853
#查看日志
(env)[root@Open-Falcon-client dashboard]# ./control tail
#退出env环境
(env)[root@Open-Falcon-client dashboard]# deactivate
[root@Open-Falcon-client dashboard]#
#访问网站,在本地浏览器中访问
http://
192.168.1.181
:8081
三 agent部署
agent用于采集机器负载监控指标,比如cpu.idle、load.1min、disk.io.util等等,每隔60秒push给Transfer。agent与Transfer建立了长连接,数据发送速度比较快,agent提供了一个http接口/v1/push用于接收用户手工push的一些数据,然后通过长连接迅速转发给Transfer。
1.创建工作目录
cd home
mkdir work
cd work
mkdir open-falcon
2.下载二进制安装包
直接下载官方编译好的二进制版本(x86 64位平台)。
https://github.com/open-falcon/falcon-plus/releases
将下载的文件放到work目录下
3.解压:
[root@open-falcon-server ~]# tar -xf open-falcon-v0.3.tar.gz
[root@open-falcon-server ~]# ll
4.赋予文件夹权限
chmod -R 777 /home/work/open-falcon
5.修改配置文件
cd /home/test/open-falcon/agent/config/
vim cfg.json
"hostname":中,IP配置成目标机器IP (e.g., "hostname": "10.4.65.97"),
"heartbeat":中 "addr": "10.4.65.112:6030",
"transfer": 中"addrs": "10.4.65.112:18433"
6.启动和检查
./open-falcon start agent 启动进程
./open-falcon stop agent 停止进程
./open-falcon monitor agent 查看日志
看var目录下的log是否正常,或者浏览器访问其1988端口。另外agent提供了一个--check参数,可以检查agent是否可以正常跑在当前机器上
./falcon-agent --check
7.查看单个agent负载
在浏览器的URL栏中输入 [目标机器IP]:1988
可以查看目标机器的数据情况