首页 > 技术文章 > Open-falcon 安装部署手册

itsre 2019-05-05 14:28 原文

搭建环境

OS: RHEL 7.3 
kernel: 3.10.0-514.el7.x86_64

host0: 10.16.112.128 <-> rhel-node01
host1: 10.16.112.253 <-> rhel-node02 
host2: 10.16.112.247 <-> rhel-node03

# 安装epel源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

echo 7 > /etc/yum/vars/releasever

基础环境

安装 go

因为官方yum和阿里yum都没有go的安装包,故只能通过fedora的epel仓库来安装

# yum install -y epel-release
# yum install golang -y

# 验证
# go version
go version go1.8.3 linux/amd64

安装redis

# yum install redis -y

# 开机启动redis
# systemctl enable redis

# 启动redis
# systemctl start redis

# 查看redis状态
# systemctl status redis

安装mysql-server

# 安装mysql源
# 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

# 启动mysql
# systemctl start mysql

# 开机启动mysql
# systemctl enable mysql

# 查看mysql   状态
# systemctl status mysql

这里若没有配置mysql源则会安装mariadb ,故需先卸载yum remove mariadb -y

安装git

# yum install git -y

获取falcon源码

# git clone https://github.com/open-falcon/falcon-plus.git

初始化数据库

# cd /opt/src/falcon-plus-master/scripts/mysql/db_schema

[root@rhel-node01 db_schema]# mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql 
Enter password: 
[root@rhel-node01 db_schema]# mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql 
Enter password: 
[root@rhel-node01 db_schema]# mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql 
Enter password: 
[root@rhel-node01 db_schema]# mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql 
Enter password: 
[root@rhel-node01 db_schema]# mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql 
Enter password: 

# 验证
[root@rhel-node01 db_schema]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.39 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| alarms             |
| dashboard          |
| falcon_portal      |
| graph              |
| mysql              |
| performance_schema |
| uic                |
+--------------------+
8 rows in set (0.00 sec)

mysql> 

安装falcon

编译 falcon

# vim ~/.bash_profile
export GOROOT=/usr/lib/golang
export GOPATH=/opt/pkg

# mkdir -p $GOPATH/src/github.com/open-falcon

# git clone https://github.com/open-falcon/falcon-plus.git
Cloning into 'falcon-plus'...
remote: Counting objects: 8158, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 8158 (delta 7), reused 18 (delta 5), pack-reused 8120
Receiving objects: 100% (8158/8158), 15.46 MiB | 445.00 KiB/s, done.
Resolving deltas: 100% (4221/4221), done.

# cd $GOPATH/src/github.com/open-falcon/falcon-plus/

# make all modules
# make all
go build -o bin/agent/falcon-agent ./modules/agent
go build -o bin/aggregator/falcon-aggregator ./modules/aggregator
go build -o bin/graph/falcon-graph ./modules/graph
go build -o bin/hbs/falcon-hbs ./modules/hbs
go build -o bin/judge/falcon-judge ./modules/judge
go build -o bin/nodata/falcon-nodata ./modules/nodata
go build -o bin/transfer/falcon-transfer ./modules/transfer
go build -o bin/gateway/falcon-gateway ./modules/gateway
go build -o bin/api/falcon-api ./modules/api
go build -o bin/alarm/falcon-alarm ./modules/alarm
go build -ldflags "-X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=0.2.1" -o open-falcon

# make pack
go build -ldflags "-X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=0.2.1" -o open-falcon
tar -C out -zcf open-falcon-v0.2.1.tar.gz .

# ls -l $GOPATH/src/github.com/open-falcon/falcon-plus/ | grep *.tar.gz
-rw-r--r--.  1 root root 40059905 Mar  8 11:43 open-falcon-v0.2.1.tar.gz

部署后端

# cd $GOPATH/src/github.com/open-falcon/falcon-plus/
# tar -xzvf open-falcon-v0.2.1.tar.gz -C $WORKSPACE

# 修改对应mysql的密码, 若无密码则去掉password即可
# find . -name cfg.json
    ./agent/config/cfg.json
    ./aggregator/config/cfg.json
    ./graph/config/cfg.json
    ./hbs/config/cfg.json
    ./judge/config/cfg.json
    ./nodata/config/cfg.json
    ./transfer/config/cfg.json
    ./gateway/config/cfg.json
    ./api/config/cfg.json
    ./alarm/config/cfg.json

##------------- 对应mysql连接 -------------
"database": {
        "addr": "root:[PASSWD]@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true",
        "idle": 10,
        "ids": [1, -1],
        "interval": 55
    }


# 启动falcon
# ./open-falcon start
[falcon-graph] 3639
[falcon-hbs] 3647
[falcon-judge] 3656
[falcon-transfer] 3662
[falcon-nodata] 3668
[falcon-aggregator] 3675
[falcon-agent] 3683
[falcon-gateway] 3690
[falcon-api] 3696
[falcon-alarm] 3708

# 查看状态
# ./open-falcon check
        falcon-graph         UP            3639 
          falcon-hbs         UP            3647 
        falcon-judge         UP            3656 
     falcon-transfer         UP            3662 
       falcon-nodata         UP            3668 
   falcon-aggregator         UP            3675 
        falcon-agent         UP            3683 
      falcon-gateway         UP            3690 
          falcon-api         UP            3696 
        falcon-alarm         UP            3708 

部署前端

# mkdir -p $FRONTSPACE
# cd $FRONTSPACE

# git clone https://github.com/open-falcon/dashboard.git
Cloning into 'dashboard'...
remote: Counting objects: 1044, done.
remote: Total 1044 (delta 0), reused 0 (delta 0), pack-reused 1044
Receiving objects: 100% (1044/1044), 1.43 MiB | 281.00 KiB/s, done.
Resolving deltas: 100% (564/564), done.

# 安装依赖
# 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
falcon-dashboard started..., pid=1654

falcon 登录配置

URL: http://{IP}:8081
falcon无默认用户,可使用页面图形化方式注册用户登录

集成grafana

grafana下载: http://grafana.org

# grafana解压
# tar xvf grafana-5.0.0.linux-x64.tar.gz -C /opt/app/

# 修改grafana配置
# cp sample.ini grafana.ini

# get code
# cd ~
# git clone https://github.com/open-falcon/grafana-openfalcon-datasource.git

# 安装插件
# mv ~/grafana-openfalcon-datasource  /opt/grafana/data/plugins

# 启动grafana
${GRAFANA_PATH_Installed}/bin/grafana-server

参考: https://github.com/open-falcon/grafana-openfalcon-datasource

推荐阅读