一、单机安装Open-Falcon

下载地址:https://github.com/open-falcon/falcon-plus/releases

官方文档:http://book.open-falcon.org/zh_0_2/

[准备环境]()

[安装epel源]()

[root@localhost ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm

[安装redis]()

[root@localhost ~]# yum -y install redis
[root@localhost ~]# systemctl start redis
[root@localhost ~]# systemctl enable redis

[安装mariadb]()

[root@localhost ~]# yum -y install mariadb-server mariadb-devel
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl enable mariadb
[root@localhost ~]# mysqladmin -uroot password 123456

[初始化MySQL表结构]()

[root@localhost ~]# yum -y install git
[root@localhost ~]# git clone https://github.com/open-falcon/falcon-plus.git
[root@localhost ~]# cd falcon-plus/scripts/mysql/db_schema/
[root@localhost db_schema]# mysql -h 127.0.0.1 -uroot -p123456 < 1_uic-db-schema.sql
[root@localhost db_schema]# mysql -h 127.0.0.1 -uroot -p123456 < 2_portal-db-schema.sql
[root@localhost db_schema]# mysql -h 127.0.0.1 -uroot -p123456 < 3_dashboard-db-schema.sql
[root@localhost db_schema]# mysql -h 127.0.0.1 -uroot -p123456 < 4_graph-db-schema.sql
[root@localhost db_schema]# mysql -h 127.0.0.1 -uroot -p123456 < 5_alarms-db-schema.sql
[root@localhost db_schema]# cd 
[root@localhost ~]# rm -rf falcon-plus/

如果是0.1.0升级到0.2.0则只需执行

mysql -h 127.0.0.1 -uroot -p123456 < 5_alarms-db-schema.sql

[启动后端]()

[二进制安装]()

[root@localhost ~]# wget https://github.com/open-falcon/falcon-plus/releases/download/v0.2.1/open-falcon-v0.2.1.tar.gz
[root@localhost ~]# mkdir /usr/local/open-falcon
[root@localhost ~]# tar zxf open-falcon-v0.2.1.tar.gz -C /usr/local/open-falcon/
[root@localhost open-falcon]# grep -Ilr 3306  ./ | xargs -n1 -- sed -i 's/root:@/root:123456@/g'

[查看修改结果]()

[root@localhost open-falcon]# grep -I1r 3306 ./
./aggregator/config/cfg.json-    "database": {
./aggregator/config/cfg.json:        "addr": "root:123456@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true",
./aggregator/config/cfg.json-        "idle": 10,
--
./hbs/config/cfg.json-    "debug": true,
./hbs/config/cfg.json:    "database": "root:123456@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true",
./hbs/config/cfg.json-    "hosts": "",
--
./api/config/cfg.json-    "db": {
./api/config/cfg.json:        "falcon_portal": "root:123456@tcp(127.0.0.1:3306)/falcon_portal?charset=utf8&parseTime=True&loc=Local",
./api/config/cfg.json:        "graph": "root:123456@tcp(127.0.0.1:3306)/graph?charset=utf8&parseTime=True&loc=Local",
./api/config/cfg.json:        "uic": "root:123456@tcp(127.0.0.1:3306)/uic?charset=utf8&parseTime=True&loc=Local",
./api/config/cfg.json:        "dashboard": "root:123456@tcp(127.0.0.1:3306)/dashboard?charset=utf8&parseTime=True&loc=Local",
./api/config/cfg.json:        "alarms": "root:123456@tcp(127.0.0.1:3306)/alarms?charset=utf8&parseTime=True&loc=Local",
./api/config/cfg.json-        "db_bug": true
--
./graph/config/cfg.json-    "db": {
./graph/config/cfg.json:        "dsn": "root:123456@tcp(127.0.0.1:3306)/graph?loc=Local&parseTime=true",
./graph/config/cfg.json-        "maxIdle": 4
--
./alarm/config/cfg.json-    "falcon_portal": {
./alarm/config/cfg.json:        "addr": "root:123456@tcp(127.0.0.1:3306)/alarms?charset=utf8&loc=Asia%2FChongqing",
./alarm/config/cfg.json-        "idle": 10,
--
./nodata/config/cfg.json-        "enabled": true,
./nodata/config/cfg.json:        "dsn": "root:123456@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true&wait_timeout=604800",
./nodata/config/cfg.json-        "maxIdle": 4

[启动]()

[root@localhost open-falcon]# ./open-falcon start
[falcon-graph] 6199
[falcon-hbs] 6208
[falcon-judge] 6217
[falcon-transfer] 6223
[falcon-nodata] 6229
[falcon-aggregator] 6236
[falcon-agent] 6244
[falcon-gateway] 6251
[falcon-api] 6257
[falcon-alarm] 6269

[查看所有模块启动情况]()

[root@localhost open-falcon]# ./open-falcon check
        falcon-graph         UP            6199 
          falcon-hbs         UP            6208 
        falcon-judge         UP            6217 
     falcon-transfer         UP            6223 
       falcon-nodata         UP            6229 
   falcon-aggregator         UP            6236 
        falcon-agent         UP            6244 
      falcon-gateway         UP            6251 
          falcon-api         UP            6257 
        falcon-alarm         UP            6269

[安装前端]()

[安装依赖]()

[root@master ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@master ~]# rpm -ivh epel-release-latest-7.noarch.rpm
[root@master ~]# yum -y install python-virtualenv python-devel openldap-devel mariadb-devel
[root@master ~]# yum -y groupinstall "Development tools"

[克隆前端组建代码]()

[root@master ~]# git clone https://github.com/open-falcon/dashboard.git

[新建虚拟环境]()

[root@master ~]# cd dashboard/
[root@master dashboard]# virtualenv ./env
New python executable in /root/dashboard/env/bin/python
Installing setuptools, pip, wheel...done.

[安装python依赖]()

[root@master dashboard]# ./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
#以下信息忽略即可
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

[修改默认配置]()

[root@master dashboard]# vim rrd/config.py
 32 PORTAL_DB_PASS = os.environ.get("PORTAL_DB_PASS","123456")
 40 ALARM_DB_PASS = os.environ.get("ALARM_DB_PASS","123456")

[启动方式]()

在生产环境启动

[root@master dashboard]# sh control start
falcon-dashboard started..., pid=73082

开发者模式启动

./env/bin/python wsgi.py

停止

bash control stop

查看日志

bash control tail

[dashbord]()用户管理

第一个注册的用户为root用户

#### [关闭注册]()

[root@master open-falcon]# vim /usr/local/open-falcon/api/config/cfg.json
 24         "signup_disable": true,
 #将false改成true即可禁止注册
[root@master open-falcon]# ./open-falcon restart

### [查看监控]()

# [二、分布式安装Open-Falcon]()

[Agent]()

[关闭防火墙]()

[root@agent ~]# systemctl disable firewalld
[root@agent ~]# systemctl stop firewalld
[root@agent ~]# sed -i 's#\(SELINUX=\).*#\1disabled#g' /etc/sysconfig/selinux

[配置epel源]()

[root@agent ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@agent ~]# rpm -ivh epel-release-latest-7.noarch.rpm

[安装后端]()

[root@agent ~]# mkdir /usr/local/open-falcon
[root@agent ~]# wget https://github.com/open-falcon/falcon-plus/releases/download/v0.2.1/open-falcon-v0.2.1.tar.gz
[root@agent ~]# tar zxf open-falcon-v0.2.1.tar.gz -C /usr/local/open-falcon/
[root@agent ~]# cd /usr/local/open-falcon/

[修改配置文件]()

将默认mysql配置改为最新

[root@agent open-falcon]# grep -Ilr 3306  ./ | xargs -n1 -- sed -i 's/root:@tcp(127.0.0.1/root:123456@tcp(
[root@agent open-falcon]# grep -I1r 3306 ./
./aggregator/config/cfg.json-    "database": {
./aggregator/config/cfg.json:        "addr": "root:123456@tcp(192.168.230.201:3306)/falcon_portal?loc=Loca
./aggregator/config/cfg.json-        "idle": 10,
--
./hbs/config/cfg.json-    "debug": true,
./hbs/config/cfg.json:    "database": "root:123456@tcp(192.168.230.201:3306)/falcon_portal?loc=Local&parse
./hbs/config/cfg.json-    "hosts": "",
--
./api/config/cfg.json-    "db": {
./api/config/cfg.json:        "falcon_portal": "root:123456@tcp(192.168.230.201:3306)/falcon_portal?char
./api/config/cfg.json:        "graph": "root:123456@tcp(192.168.230.201:3306)/graph?charset=utf8&parseTi
./api/config/cfg.json:        "uic": "root:123456@tcp(192.168.230.201:3306)/uic?charset=utf8&parseTime=T
./api/config/cfg.json:        "dashboard": "root:123456@tcp(192.168.230.201:3306)/dashboard?charset=utf8
./api/config/cfg.json:        "alarms": "root:123456@tcp(192.168.230.201:3306)/alarms?charset=utf8&parse
./api/config/cfg.json-        "db_bug": true
--
./graph/config/cfg.json-    "db": {
./graph/config/cfg.json:        "dsn": "root:123456@tcp(192.168.230.201:3306)/graph?loc=Local&parseTime=tr
./graph/config/cfg.json-        "maxIdle": 4
--
./alarm/config/cfg.json-    "falcon_portal": {
./alarm/config/cfg.json:        "addr": "root:123456@tcp(192.168.230.201:3306)/alarms?charset=utf8&loc=Asi
./alarm/config/cfg.json-        "idle": 10,
--
./nodata/config/cfg.json-        "enabled": true,
./nodata/config/cfg.json:        "dsn": "root:123456@tcp(192.168.230.201:3306)/falcon_portal?loc=Local&par
./nodata/config/cfg.json-        "maxIdle": 4
[root@agent open-falcon]# yum -y install mariadb
[root@agent open-falcon]# vim /usr/local/open-falcon/agent/config/cfg.json
 13         "addr": "192.168.230.201:6030",
 20             "192.168.230.201:8433"

[启动agent]()

[root@agent open-falcon]# ./open-falcon start agent 
[falcon-agent] 68039

[查看启动结果]()

[root@agent open-falcon]# ./open-falcon monitor agent

### [Transfer]()端授权数据库访问权限

[root@master dashboard]# mysql -uroot -p123456
MariaDB [(none)]> grant all on *.* to root@'192.168.230.%' identified by '123456';
grant all on *.* to root@'192.168.230.%' identified by '123456';
[root@agent ~]# cat /usr/local/open-falcon/agent/config/cfg.json 
{
    "debug": true,    #控制一些debug信息的输出,生产环境通常设置为false
    "hostname": "",    #agent采集了数据发给transfer,endpoint就设置为了hostname,默认通过`hostname`获取,如果配置中配置了hostname,就用配置中的
    "ip": "",    #agent与hbs心跳的时候会把自己的ip地址发给hbs,agent会自动探测本机ip,如果不想让agent自动探测,可以手工修改该配置
    "plugin": {
        "enabled": false,    #默认不开启插件机制
        "dir": "./plugin",    #把放置插件脚本的git repo clone到这个目录
        "git": "https://github.com/open-falcon/plugin.git",        #放置插件脚本的git repo地址
        "logs": "./logs"        #插件执行的log,如果插件执行有问题,可以去这个目录看log
    },
    "heartbeat": {
        "enabled": true,    #此处enabled要设置为true
        "addr": "192.168.230.201:6030",        #hbs的地址,端口是hbs的rpc端口
        "interval": 60,        #心跳周期,单位是秒
        "timeout": 1000        #连接hbs的超时时间,单位是毫秒
    },
    "transfer": {
        "enabled": true,
        "addrs": [
            "192.168.230.201:8433"
        ],    #transfer的地址,端口是transfer的rpc端口, 可以支持写多个transfer的地址,agent会保证HA
        "interval": 60,    #采集周期,单位是秒,即agent一分钟采集一次数据发给transfer
        "timeout": 1000    #连接transfer的超时时间,单位是毫秒
    },
    "http": {
        "enabled": true,    #是否要监听http端口
        "listen": ":1988",
        "backdoor": false
    },
    "collector": {
        "ifacePrefix": ["eth", "em"],    #默认配置只会采集网卡名称前缀是eth、em的网卡流量,配置为空就会采集所有的,lo的也会采集。可以从/proc/net/dev看到各个网卡的流量信息
        "mountPoint": []
    },
    "default_tags": {
    },
    "ignore": {    #默认采集了200多个metric,可以通过ignore设置为不采集
        "cpu.busy": true,
        "df.bytes.free": true,
        "df.bytes.total": true,
        "df.bytes.used": true,
        "df.bytes.used.percent": true,
        "df.inodes.total": true,
        "df.inodes.free": true,
        "df.inodes.used": true,
        "df.inodes.used.percent": true,
        "mem.memtotal": true,
        "mem.memused": true,
        "mem.memused.percent": true,
        "mem.memfree": true,
        "mem.swaptotal": true,
        "mem.swapused": true,
        "mem.swapfree": true
    }
}

[Transfer]()

transfer是数据转发服务。它接收agent上报的数据,然后按照哈希规则进行数据分片、并将分片后的数据分别push给graph&judge等组件。
[root@master open-falcon]# cat /usr/local/open-falcon/transfer/config/cfg.json
{
    "debug": true,    #如果为true,日志中会打印debug信息
    "minStep": 30,    #允许上报的数据最小间隔,默认为30秒
    "http": {
        "enabled": true,    #表示是否开启该http端口,该端口为控制端口,主要用来对transfer发送控制命令、统计命令、debug命令等
        "listen": "0.0.0.0:6060"    #表示监听的http端口
    },
    "rpc": {
        "enabled": true,    #表示是否开启该jsonrpc数据接收端口, Agent发送数据使用的就是该端口
        "listen": "0.0.0.0:8433"    #表示监听的http端口
    },
    "socket": {        #即将被废弃,请避免使用
        "enabled": false,    #表示是否开启该telnet方式的数据接收端口,这是为了方便用户一行行的发送数据给transfer
        "listen": "0.0.0.0:4444",    #表示监听的http端口
        "timeout": 3600
    },
    "judge": {
        "enabled": true,    #表示是否开启向judge发送数据
        "batch": 200,        #数据转发的批量大小,可以加快发送速度,建议保持默认值
        "connTimeout": 1000,    #单位是毫秒,与后端建立连接的超时时间,可以根据网络质量微调,建议保持默认
        "callTimeout": 5000,    #单位是毫秒,发送数据给后端的超时时间,可以根据网络质量微调,建议保持默认
        "maxConns": 32,        #连接池相关配置,最大连接数,建议保持默认
        "maxIdle": 32,        #连接池相关配置,最大空闲连接数,建议保持默认
        "replicas": 500,    #这是一致性hash算法需要的节点副本数量,建议不要变更,保持默认即可
        "cluster": {        #key-value形式的字典,表示后端的judge列表,其中key代表后端judge名字,value代表的是具体的ip:port
            "judge-00" : "0.0.0.0:6080"        #表示监听的http端口
        }
    },
    "graph": {
        "enabled": true,    #表示是否开启向graph发送数据
        "batch": 200,    #数据转发的批量大小,可以加快发送速度,建议保持默认值
        "connTimeout": 1000,     #单位是毫秒,与后端建立连接的超时时间,可以根据网络质量微调,建议保持默认
        "callTimeout": 5000,     #单位是毫秒,发送数据给后端的超时时间,可以根据网络质量微调,建议保持默认
        "maxConns": 32,     #连接池相关配置,最大连接数,建议保持默认
        "maxIdle": 32,      #连接池相关配置,最大空闲连接数,建议保持默认
        "replicas": 500,    #这是一致性hash算法需要的节点副本数量,建议不要变更,保持默认即可
        "cluster": {    #key-value形式的字典,表示后端的graph列表,其中key代表后端graph名字,value代表的是具体的ip:port(多个地址用逗号隔开, transfer会将同一份数据发送至各个地址,利用这个特性可以实现数据的多重备份)
            "graph-00" : "0.0.0.0:6070"
        }
    },
    "tsdb": {
        "enabled": false,    #表示是否开启向open tsdb发送数据
        "batch": 200,        #数据转发的批量大小,可以加快发送速度
        "connTimeout": 1000,    #单位是毫秒,与后端建立连接的超时时间,可以根据网络质量微调,建议保持默认
        "callTimeout": 5000,    #单位是毫秒,发送数据给后端的超时时间,可以根据网络质量微调,建议保持默认
        "maxConns": 32,        #连接池相关配置,最大连接数,建议保持默认
        "maxIdle": 32,        #连接池相关配置,最大空闲连接数,建议保持默认
        "retry": 3,        #连接后端的重试次数和发送数据的重试次数
        "address": "127.0.0.1:8088"        #tsdb地址或者tsdb集群vip地址, 通过tcp连接tsdb.
    }
}

[管理方式]()

# 启动服务
./open-falcon start transfer

# 校验服务,这里假定服务开启了6060的http监听端口。检验结果为ok表明服务正常启动。
curl -s "127.0.0.1:6060/health"

# 停止服务
./open-falcon stop transfer

# 查看日志
./open-falcon monitor transfer

[Heartbeat Server]()

心跳服务器,公司所有agent都会连到HBS,每分钟发一次心跳请求。
[root@master open-falcon]# cat /usr/local/open-falcon/hbs/config/cfg.json
{
    "debug": true,
    "database": "root:123456@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true",    #Portal的数据库地址
    "hosts": "",    #portal数据库中有个host表,如果表中数据是从其他系统同步过来的,此处配置为sync,否则就维持默认,留空即可
    "maxConns": 20,
    "maxIdle": 15,
    "listen": ":6030",    #hbs监听的rpc地址
    "trustable": [""],
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6031"    #hbs监听的http地址
    }
}

[管理方式]()

# 启动
./open-falcon start hbs

# 停止
./open-falcon stop hbs

# 查看日志
./open-falcon monitor hbs

[API]()

<strong>api</strong>`组件,提供统一的restAPI操作接口。比如:api组件接收查询请求,根据一致性哈希算法去相应的graph实例查询不同metric的数据,然后汇总拿到的数据,最后统一返回给用户。`

[root@master open-falcon]# cat /usr/local/open-falcon/api/config/cfg.json
{
    "log_level": "debug",
    "db": {        #数据库相关的连接配置信息
        "falcon_portal": "root:123456@tcp(127.0.0.1:3306)/falcon_portal?charset=utf8&parseTime=True&loc=Local",
        "graph": "root:123456@tcp(127.0.0.1:3306)/graph?charset=utf8&parseTime=True&loc=Local",
        "uic": "root:123456@tcp(127.0.0.1:3306)/uic?charset=utf8&parseTime=True&loc=Local",
        "dashboard": "root:123456@tcp(127.0.0.1:3306)/dashboard?charset=utf8&parseTime=True&loc=Local",
        "alarms": "root:123456@tcp(127.0.0.1:3306)/alarms?charset=utf8&parseTime=True&loc=Local",
        "db_bug": true
    },
    "graphs": {        #graph模块的部署列表信息
        "cluster": {
            "graph-00": "127.0.0.1:6070"
        },
        "max_conns": 100,
        "max_idle": 100,
        "conn_timeout": 1000,
        "call_timeout": 5000,
        "numberOfReplicas": 500
    },
    "metric_list_file": "./api/data/metric",
    "web_port": "0.0.0.0:8080",        #http监听端口
    "access_control": true,        #如果设置为false,那么任何用户都可以具备管理员权限
    "signup_disable": false,
    "salt": "",        #数据库加密密码的时候的salt
    "skip_auth": false,        #如果设置为true,那么访问api就不需要经过认证
    "default_token": "default-token-used-in-server-side",        #用于服务端各模块间的访问授权
    "gen_doc": false,
    "gen_doc_path": "doc/module.html"
}

[管理方式]()

# 启动服务
./open-falcon start api

# 停止服务
./open-falcon stop api

# 查看日志
./open-falcon monitor api

[Graph]()

graph是存储绘图数据的组件。graph组件 接收transfer组件推送上来的监控数据,同时处理api组件的查询请求、返回绘图数据。

[root@master open-falcon]# cat /usr/local/open-falcon/graph/config/cfg.json
{
    "debug": false,        #是否开启debug日志
    "http": {
        "enabled": true,    #表示是否开启该http端口,该端口为控制端口,主要用来对graph发送控制命令、统计命令、debug命令
        "listen": "0.0.0.0:6071"    #表示监听的http端口
    },
    "rpc": {
        "enabled": true,    #表示是否开启该rpc端口,该端口为数据接收端口
        "listen": "0.0.0.0:6070"    #表示监听的rpc端口
    },
    "rrd": {
        "storage": "./data/6070"    #历史数据的文件存储路径(如有必要,请修改为合适的路)
    },
    "db": {
        "dsn": "root:123456@tcp(127.0.0.1:3306)/graph?loc=Local&parseTime=true",    #MySQL的连接信息,默认用户名是root,密码为空,host为127.0.0.1,database为graph(如有必要,请修改)
        "maxIdle": 4    #MySQL连接池配置,连接池允许的最大连接数,保持默认即可
    },
    "callTimeout": 5000,    #RPC调用超时时间,单位m
    "migrate": {    #扩容graph时历史数据自动迁移
            "enabled": false,    #true or false, 表示graph是否处于数据迁移状态
            "concurrency": 2,    #数据迁移时的并发连接数,建议保持默认
            "replicas": 500,    #这是一致性hash算法需要的节点副本数量,建议不要变更,保持默认即可(必须和transfer的配置中保持一致)
            "cluster": {    #未扩容前老的graph实例列表
                    "graph-00" : "127.0.0.1:6070"
            }
    }
}

[管理方式]()

# 启动服务
./open-falcon start graph

# 停止服务
./open-falcon stop graph

# 查看日志
./open-falcon monitor graph

[开启后端]()

[root@master open-falcon]# ./open-falcon start transfer hbs api graph judge
[falcon-transfer] 74054
[falcon-hbs] 74061
[falcon-api] 74069

<strong>如需全部服务可以</strong>

[root@master open-falcon]# ./open-falcon start
END

本文标题:Open-Falcon安装部署

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/monitor_server/20211514.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归作者 (宇宙最帅的男人) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2023 年 07 月 23 日
如果觉得我的文章对你有用,请随意赞赏