open-falcon搭建

发布时间:2020-07-12 19:08:23 作者:沐子先生
来源:网络 阅读:9360

环境准备

yum install -y redis

yum install -y mysql-server
###安装并开机自启###
 
export HOME=/home/work
export WORKSPACE=$HOME/open-falcon
mkdir -p $WORKSPACE
cd $WORKSPACE
git clone https://github.com/open-falcon/scripts.git
cd ./scripts/
mysql -h localhost -u root --password="" < db_schema/graph-db-schema.sql
mysql -h localhost -u root --password="" < db_schema/dashboard-db-schema.sql
 
mysql -h localhost -u root --password="" < db_schema/portal-db-schema.sql
mysql -h localhost -u root --password="" < db_schema/links-db-schema.sql
mysql -h localhost -u root --password="" < db_schema/uic-db-schema.sql

####数据库密码为空####

mkdir ./tmp

导入安装包open-falcon-v0.1.0.tar.gz

Shell脚本执行

        tar -zxf open-falcon-latest.tar.gz -C ./tmp/
for x in `find ./tmp/ -name "*.tar.gz"`;do \
    app=`echo $x|cut -d '-' -f2`; \
    mkdir -p $app; \
tar -zxf $x -C $app; \
done
 

安装go环境

cd ~
wget http://dinp.qiniudn.com/go1.4.1.linux-amd64.tar.gz
tar zxf go1.4.1.linux-amd64.tar.gz
mkdir -p workspace/src
echo "" >> .bashrc
echo 'export GOROOT=$HOME/go' >> .bashrc
echo 'export GOPATH=$HOME/workspace' >> .bashrc
echo 'export PATH=$GOROOT/bin:$GOPATH/bin:$PATH' >> .bashrc
echo "" >> .bashrc
source .bashrc

接下来clone代码,以备后用

cd $GOPATH/src
mkdir github.com
cd github.com
git clone --recursive https://github.com/open-falcon/of-release.git

安装agent(采集机器监控指标)

cd $GOPATH/src/github.com/open-falcon/agent

###所有组件配置文件必须叫cfg.json,可以基于cfg.example.json修改

open-falcon搭建

./control start 启动进程
./control stop 停止进程
./control restart 重启进程
./control status 查看进程状态
./control tail 用tail -f的方式查看var/app.log
./falcon-agent –check检查是否可以正常跑在当前机器
 
 
安装Transfer(数据转发服务)
Cd transfer
vim cfg.json
 
{
    "debug": false,
    "minStep": 30,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6060"
    },
    "rpc": {
        "enabled": true,
        "listen": "0.0.0.0:8433"
    },
    "socket": {
        "enabled": false,
        "listen": "0.0.0.0:4444",
        "timeout": 3600
    },
    "judge": {
        "enabled": true,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "replicas": 500,
        "cluster": {
            "judge-00" : "127.0.0.1:6080"
        }
    },
    "graph": {
        "enabled": true,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "replicas": 500,
        "cluster": {
            "graph-00" : "127.0.0.1:6070"
        }
    },
    "tsdb": {
        "enabled": true,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "retry": 3,
        "address": "127.0.0.1:8088"
    }
}
 
启动
./control start
curl -s "127.0.0.1:6060/health"  校验
 
cd graph
mv cfg.example.json cfg.json
vim cfg.json
{
        "debug": false,
        "http": {
                "enabled": true,
                "listen": "0.0.0.0:6071"
        },
        "rpc": {
                "enabled": true,
                "listen": "0.0.0.0:6070"
        },
        "rrd": {
                "storage": "/home/work/data/6070"
        },
        "db": {
                "dsn": "root:@tcp(127.0.0.1:3306)/graph?loc=Local&parseTime=true",
                "maxIdle": 4
        },
        "callTimeout": 5000,
        "migrate": {
                "enabled": false,
                "concurrency": 2,
                "replicas": 500,
                "cluster": {
                        "graph-00" : "127.0.0.1:6070"
                }
        }
}
 
./control start
curl -s "127.0.0.1:6071/health"
 
cd ../queph
mv cfg.example.json cfg.json
vim cfg.json
{
    "debug": "false",
    "http": {
        "enabled":  true,
        "listen":   "0.0.0.0:9966"
    },
    "graph": {
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "replicas": 500,
        "cluster": {
            "graph-00": "127.0.0.1:6070"
        }
    },
    "api": {
        "query": "http://127.0.0.1:9966",
        "dashboard": "http://127.0.0.1:8081",
        "max": 500
服务启动后,可以通过日志查看服务的运行状态,日志文件地址为./var/app.log。可以通过查询脚本./scripts/query读取绘图数据,如 运行 bash ./scripts/query "ur.endpoint" "ur.counter"可以查询Endpoint="ur.endpoint" & Counter="ur.counter"对应的绘图数据。
 
注意: 请确保 graph.replicas和graph.cluster 的内容与transfer的配置完全一致
 
 
安装dashboard
yum install -y python-virtualenv
cd /path/to/dashboard/
virtualenv ./env
./env/bin/pip install -r pip_requirements.txt
###这里MySQL-Python会出错。在pip_requirements.txt里去掉MySQL-Python单独安装。参考地址:http://blog.csdn.net/winsonyuan/article/details/65447796
 
vim ./gunicorn.conf
vim ./rrd/config.py
 
workers = 4
bind = ':8081'
proc_name = 'falcon-dashboard-opensource'
pidfile = '/tmp/falcon-dashboard-opensource.pid'
limit_request_field_size = 0
limit_request_line = 0
 
#-*-coding:utf8-*-
import os
 
#-- dashboard db config --
DASHBOARD_DB_HOST = "127.0.0.1"
DASHBOARD_DB_PORT = 3306
DASHBOARD_DB_USER = "root"
DASHBOARD_DB_PASSWD = ""
DASHBOARD_DB_NAME = "dashboard"
 
#-- graph db config --
GRAPH_DB_HOST = "127.0.0.1"
GRAPH_DB_PORT = 3306
GRAPH_DB_USER = "root"
GRAPH_DB_PASSWD = ""
GRAPH_DB_NAME = "graph"
 
#-- app config --
DEBUG = True
SECRET_KEY = "secret-key"
SESSION_COOKIE_NAME = "open-falcon"
PERMANENT_SESSION_LIFETIME = 3600 * 24 * 30
SITE_COOKIE = "open-falcon-ck"
 
#-- query config --
QUERY_ADDR = "http://127.0.0.1:9966"
 
BASE_DIR = "/home/work/open-falcon/dashboard/"
LOG_PATH = os.path.join(BASE_DIR,"log/")
 
try:
    from rrd.local_config import *
except:
pass
 
邮件短信接口这里需要单独安装falcon-mail-provider的安装包
{
    "debug": true,
    "http": {
        "listen": "10.0.0.60:4000",
        "token": ""
    },
    "smtp": {
        "addr": "smtp.qq.com:587",
        "username": "XXXX@qq.com",
        "password": "eahqkylmljenbfge",==》这里有个授权码问题。
        "from": "XXXX@qq.com"
    }
}
~  ./control start
 
发送一份测试邮件:curl http://10.0.0.60:4000/sender/mail -d tos=XXXX@qq.com&subject=helloworld&content=test
 
安装sender(调用公司提供的邮件、短信接口)
Cd sender
Vi cfg.json
{
    "debug": true,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6066"
    },
    "redis": {
        "addr": "127.0.0.1:6379",
        "maxIdle": 5
    },
    "queue": {
        "sms": "/sms",
        "mail": "/mail"
    },
    "worker": {
        "sms": 10,
        "mail": 50
    },
    "api": {
        "sms": "http://10.0.0.60:8000/sms",
        "mail": "http://10.0.0.60:4000/sender/mail"
    }
}
 
curl 127.0.0.1:6066/health
 
安装FE(UIC  web入口)
Cd fe
Vi cfg.json
{
    "log": "debug",
    "company": "PJwuliu",        ==》这里是公司名称用于生成二维码
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:1234"
    },
    "cache": {
        "enabled": true,
        "redis": "127.0.0.1:6379",
        "idle": 10,
        "max": 1000,
        "timeout": {
            "conn": 10000,
            "read": 5000,
            "write": 5000
        }
    },
    "salt": "fdfdfdsfsdfsfdsfs",
    "canRegister": true,
    "ldap": {
        "enabled": false,
        "addr": "ldap.example.com:389",
        "baseDN": "dc=example,dc=com",
        "bindDN": "cn=mananger,dc=example,dc=com",
        "bindPasswd": "12345678",
        "userField": "uid",
        "attributes": ["sn","mail","telephoneNumber"]
    },
    "uic": {
        "addr": "root:@tcp(127.0.0.1:3306)/uic?charset=utf8&loc=Asia%2FChongqing",
        "idle": 10,
        "max": 100
    },
    "shortcut": {
        "falconPortal": "http://10.0.0.60:5050/",
        "falconDashboard": "http://10.0.0.60:8081/",
        "falconAlarm": "http://10.0.0.60:9912/"
}
 
安装portal(配置报警策略)
# yum install -y python-virtualenv
 
$ cd /path/to/portal/
$ virtualenv ./env
 
$ ./env/bin/pip install -r pip_requirements.txt
vi ../portal/frame/config.py
# -*- coding:utf-8 -*-
__author__ = 'Ulric Qin'
 
# -- app config --
DEBUG = True
 
# -- db config --
DB_HOST = "127.0.0.1"
DB_PORT = 3306
DB_USER = "root"
DB_PASS = ""
DB_NAME = "falcon_portal"
 
# -- cookie config --
SECRET_KEY = "4e.5tyg8-u9iojds"
SESSION_COOKIE_NAME = "falcon-portal"
PERMANENT_SESSION_LIFETIME = 3600 * 24 * 30
 
UIC_ADDRESS = {
    'internal': 'http://10.0.0.60:1234',
    'external': 'http://10.0.0.60:1234',
}
 
UIC_TOKEN = ''
 
MAINTAINERS = ['root']
CONTACT = 'ulric.qin@gmail.com'
 
COMMUNITY = True
 
try:
    from frame.local_config import *
except Exception, e:
    print "[warning] %s" % e
 
cd hbs
 
{
    "debug": true,
    "database": "root:@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true",
    "hosts": "",
    "maxIdle": 100,
    "listen": ":6030",
    "trustable": [""],
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6031"
    }
}
 
Cd judge~(告警判断)
{
    "debug": true,
    "debugHost": "nil",
    "remain": 11,
    "http": {
        "enabled": true,
        "listen": "10.0.0.60:6081"
    },
    "rpc": {
        "enabled": true,
        "listen": "0.0.0.0:6080"
    },
    "hbs": {
        "servers": ["10.0.0.60:6030"],
        "timeout": 300,
        "interval": 60
    },
    "alarm": {
        "enabled": true,
        "minInterval": 300,
        "queuePattern": "event:p%v",
        "redis": {
            "dsn": "127.0.0.1:6379",
            "maxIdle": 5,
            "connTimeout": 5000,
            "readTimeout": 5000,
            "writeTimeout": 5000
        }
    }
}
 
curl 127.0.0.1:6081/health
 
cd links
virtualenv ./env
 
./env/bin/pip install -r pip_requirements.txt
 
# -*- coding:utf-8 -*-
__author__ = 'Ulric Qin'
 
# -- app config --
DEBUG = True
 
# -- db config --
DB_HOST = "10.0.0.60"
DB_PORT = 3306
DB_USER = "root"
DB_PASS = ""
DB_NAME = "falcon_links"
 
# -- cookie config --
SECRET_KEY = "4e.5tyg8-u9ioj"
SESSION_COOKIE_NAME = "falcon-links"
PERMANENT_SESSION_LIFETIME = 3600 * 24 * 30
 
try:
    from frame.local_config import *
except Exception, e:
print "[warning] %s" % e
 
安装alarm(处理报警event),judge产生的报警event写入redis,alarm从redis读取处理
 
{
    "debug": true,
    "uicToken": "",
    "http": {
        "enabled": true,
        "listen": "10.0.0.60:9912"
    },
    "queue": {
        "sms": "/sms",
        "mail": "/mail"
    },
    "redis": {
        "addr": "127.0.0.1:6379",
        "maxIdle": 5,
        "highQueues": [
            "event:p0",
            "event:p1",
            "event:p2",
            "event:p3",
            "event:p4",
            "event:p5"
        ],
        "lowQueues": [
            "event:p6"
        ],
        "userSmsQueue": "/queue/user/sms",
        "userMailQueue": "/queue/user/mail"
    },
    "api": {
        "portal": "http://10.0.0.60:5050",
        "uic": "http://10.0.0.60:1234",
        "links": "http://10.0.0.60:5090"
    }
}
 
安装task(定时任务)
{
    "debug": false,
    "http": {
        "enable": true,
        "listen": "0.0.0.0:8002"
    },
    "index": {
        "enable": false,
        "dsn": "root:root@tcp(127.0.0.1:3306)/graph?loc=Local&parseTime=true",
        "maxIdle": 4,
        "autoDelete": false,
        "cluster":{
            "test.hostname01:6071" : "0 0 0 ? * 0-5",
            "test.hostname02:6071" : "0 30 0 ? * 0-5"
        }
    },
    "collector" : {
        "enable": true,
        "destUrl" : "http://127.0.0.1:1988/v1/push",
        "srcUrlFmt" : "http://%s/statistics/all",
        "cluster" : [
            "transfer,open-falcon.te:6060",
            "graph,open-falcon.te:6071",
            "task,open-falcon.te:8001"
        ]
    }
}
 
安装nodata(监测监控数据的上报异常)
{
    "debug": true,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6090"
    },
    "query":{
        "connectTimeout": 5000,
        "requestTimeout": 30000,
        "queryAddr": "127.0.0.1:9966"
    },
    "config": {
        "enabled": true,
        "dsn": "root:@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true&wait_timeout=604800",
        "maxIdle": 4
    },
    "collector":{
        "enabled": true,
        "batch": 200,
        "concurrent": 10
    },
    "sender":{
        "enabled": true,
        "connectTimeout": 5000,
        "requestTimeout": 30000,
        "transferAddr": "127.0.0.1:6060",
        "batch": 500,
        "block": {
            "enabled": false,
            "threshold": 32
        }
    }
}
 
安装aggregator  (集群聚合模块)
{
    "debug": true,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6055"
    },
    "database": {
        "addr": "root:@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true",
        "idle": 10,
        "ids": [1, -1],
        "interval": 55
    },
    "api": {
        "hostnames": "http://127.0.0.1:5050/api/group/%s/hosts.json",
        "push": "http://127.0.0.1:6060/api/push",
        "graphLast": "http://127.0.0.1:9966/graph/last"
    }
}


至此open-falcon已经搭建完成。现在open-falcon刚发布不久plus版,有时间再去看看吧!
            祝玩的开心!!!
            
    官网地址:
                https://github.com/open-falcon-archive/of-release
推荐阅读:
  1. 使用open-falcon监控vSphere
  2. open-falcon架构介绍

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

open-falcon falco con

上一篇:《CLR Via C#》Visual Studio编译之后的.pdb文件

下一篇:如何防止u盘中毒

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》