2019-07-10
一、open-falcon简介
open-falcon是由小米运维团队,从互联网公司角度为出发点,开发出来的一套面向互联网行业的企业级的开源监控系统,截至2019年7月,open-falcon最新稳定版本为v0.2
二、open-falcon特性
- 数据采集方式多样灵活:支持agent、snmp、用户主动push、自定义插件等多种方式进行数据采集
- 高效率报警策略管理
- 人性化的告警设置
- dashboard多维度数据展示
- 模板支持继承的同时支持覆盖策略项
- server端无需做配置,只需要在client端按照agent则可以自动监控
- 引入tag概念,通过tag多维度对数据进行查询展示
三、open-falcon系统架构
四、open-falcon组件功能
- falcon-agent:负责采集监控目标的数据,agent本身有一个http接口,用户可以通过http接口将数据主动push到agent。agent和transfer保持长连接,将采集到的数据上报给transfer。
- transfer:会将数据分别转发给judge和graph,judge和graph使用一致性hash进行数据的分片。
- judge:从heartbeat中获取报警策略,进行策略报警判断,并将判断是否告警的事件放进redis队列。
- alerm:从redis中取出事件,根据配置做告警处理,如发送邮件通知等。
- graph:负责数据的存储和归档以及数据查询功能。
- heartbeat:统计agent上报信息,下发报警策略。
- dashboard: 数据展示,用户配置。
五、open-falcon单机版安装
5.1安装redis
#创建redis工作目录mkdir /home/redis && cd /home/redis #下载redis程序包: wget http://download.redis.io/releases/redis-4.0.9.tar.gz #编译安装 tar -zxvf redis-4.0.9.tar.gz mv redis-4.0.9 redis4.0.9 && cd redis4.0.9 mkdir logs make && make install #修改配置文件 vim redis.conf bind 0.0.0.0 daemonize yes pidfile /var/run/redis_6379.pid logfile "/home/redis/redis4.0.9/logs/redis.log" #启动redis redis-server /home/redis/redis4.0.9/redis.conf #连接测试 redis-cli -h 127.0.0.1 -p 6379
5.2安装mysql
#安装yum-utils yum -y install yum-utils #mysql官网上下载mysql的yum源安装包 wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm #添加yum源 rpm -ivh mysql80-community-release-el7-1.noarch.rpm #开启5.7安装,关闭8.0安装源 yum-config-manager --disable mysql80-community yum-config-manager --enable mysql57-community #yum安装mysql yum -y install mysql-community-server #修改mysql配置文件,关闭复杂密码策略 echo "validate-password=OFF" >> /etc/my.cnf #启动mysql 并加入开机启动项 systemctl start mysqld.service systemctl status mysqld.service systemctl enable mysqld.service #查看默认root密码 grep ‘temporary password‘ /var/log/mysqld.log #登陆mysql后修改root密码 ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘; #root用户授权 GRANT ALL ON *.* TO ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘; GRANT ALL ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘; flush privileges;
5.3初始化表结构
#clone项目至本地git clone https://github.com/open-falcon/falcon-plus.git#导入表结构 cd ./falcon-plus/scripts/mysql/db_schema/ mysql -uroot -p123456 < 1_uic-db-schema.sql mysql -uroot -p123456 < 2_portal-db-schema.sql mysql -uroot -p123456 < 3_dashboard-db-schema.sql mysql -uroot -p123456 < 4_graph-db-schema.sql mysql -uroot -p123456 < 5_alarms-db-schema.sql#删除目录 rm -rf falcon-plus/
5.4安装golang
#下载go安装包 https://dl.google.com/go/go1.12.7.linux-amd64.tar.gz #解压至/home目录下 tar -zxvf go1.12.7.linux-amd64.tar.gz -C /home #声明PATH echo "export PATH=$PATH:/home/go/bin" >> /etc/profile source /etc/profile #查看go版本 go version
5.5创建工作目录
export FALCON_HOME=/home export WORKSPACE=$FALCON_HOME/open-falcon mkdir -p $WORKSPACE
5.6下载安装包
#下载安装包 wget https://github.com/open-falcon/falcon-plus/releases/download/v0.2.0/open-falcon-v0.2.0.tar.gz #解压 cd /home/open-falcon tar -zxvf open-falcon-v0.2.0.tar.gz
5.7后端启动
#修改配置文件为自己设置的mysql用户和密码 grep -Ilr 3306 ./ | xargs -n1 -- sed -i ‘s/root:/real_user:real_password/g‘ #启动服务 /home/open-falcon/open-falcon start /home/open-falcon/open-falcon check #显示如下则全部启动成功
falcon-graph UP 27685
falcon-hbs UP 27697
falcon-judge UP 27707
falcon-transfer UP 27716
falcon-nodata UP 27724
falcon-aggregator UP 27732
falcon-agent UP 27743
falcon-gateway UP 27753
falcon-api UP 27761
falcon-alarm UP 28201
5.8前端启动
#下载dashboard项目至本地 cd $WORKSPACE git clone https://github.com/open-falcon/dashboard.git #安装所需依赖包 yum install -y python-virtualenv yum install -y python-devel yum install -y openldap-devel yum install -y mysql-devel yum groupinstall "Development tools" #创建独立的虚拟环境 cd $WORKSPACE/dashboard/ virtualenv ./env #pip安装依赖 ./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple #修改配置文件 vim rrd/config # TODO: read from api instead of db PORTAL_DB_HOST = os.environ.get("PORTAL_DB_HOST","127.0.0.1") 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","123456") 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","127.0.0.1") 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","123456") ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms") #启动 bash control start bash control status #查看日志 bash control tail
5.9安装agent
#将agent目录及启动命令拷贝至客户端上 scp -r agent/ [email protected]192.168.1.66:/home/open-falcon/ scp open-falcon [email protected]192.168.1.66:/home/open-falcon/ #编辑agent配置文件,修改hostname、transfer、heaetbeat配置项 vim agent/config/cfg.json #启动agent,查看agent状态 ./open-falcon start agent ./open-falcon check agent tailf agent/logs/agent.log #重载配置文件 curl 127.0.0.1:1988/config/reload
5.10访问测试
agent访问地址: http://ip:1988/ dashboard访问地址: http://ip:8081/
六、open-falcon相关资料
中文手册:http://book.open-falcon.com/zh_0_2/项目地址:https://github.com/open-falcon/falcon-plus
原文地址:https://www.cnblogs.com/LAlexH/p/11161943.html
时间: 2024-10-06 15:27:07