open-falcon 搭建

本文详细介绍在Ubuntu18.04系统上搭建OpenFalcon监控系统的全过程,包括环境准备、依赖安装、编译运行、前端部署及常见问题解决。通过具体步骤指导,帮助读者快速上手OpenFalcon,实现系统资源和应用性能的有效监控。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,open-falcon 搭建

  • 系统
# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic
  • git 安装
# apt install -y git
# git --version
git version 2.17.1
  • go 安装
# wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz
# tar -zxvf go1.13.4.linux-amd64.tar.gz -C /usr/local/
# ln -s /usr/local/go/bin/* /usr/bin/
# go version
go version go1.13.4 linux/amd64
  • go环境变量
# go env | grep GOROOT
GOROOT="/usr/local/go"
# go env | grep GOPATH
GOPATH="/root/go"

# pwd
/root
# mkdir mygo
# cd mygo/
# mkdir src pkg bin

# vim /root/.bashr
# tail /root/.bashrc
export GOROOT=/usr/local/go
export GOPATH=/root/mygo
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

# source /root/.bashr
# go env | grep GOPATH
GOPATH="/root/mygo"

2,安装依赖

  • redis安装
# apt-get install redis-server -y
  • redis-server运行redis
# redis-server
18635:C 27 Nov 22:56:46.506 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18635:C 27 Nov 22:56:46.506 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=18635, just started
18635:C 27 Nov 22:56:46.506 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
18635:M 27 Nov 22:56:46.508 * Increased maximum number of open files to 10032 (it was originally set to 1024).
18635:M 27 Nov 22:56:46.509 # Creating Server TCP listening socket *:6379: bind: Address already in use
  • redis成功启动
# redis-cli
127.0.0.1:6379> ping
PONG
  • mysql安装
# apt-get install mysql-server -y
  • mysql服务运行
# systemctl status mysql.service
# mysql -u root
mysql> show databases;
mysql> use mysql;
mysql> show tables;
mysql> select User,Host,plugin from user;
+------------------+-----------+-----------------------+
| User             | Host      | plugin                |
+------------------+-----------+-----------------------+
| root             | localhost | auth_socket           |
| mysql.session    | localhost | mysql_native_password |
| mysql.sys        | localhost | mysql_native_password |
| debian-sys-maint | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
mysql> update user set plugin='mysql_native_password' where User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit
# mkdir -p $GOPATH/src/github.com/open-falcon
# cd $GOPATH/src/github.com/open-falcon
# git clone git@github.com:open-falcon/falcon-plus.git

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

# cd falcon-plus/scripts/mysql/db_schema/
  • 不用设置密码回车就行
# mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql
Enter password:
# mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql
Enter password:
 mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql
Enter password:
# mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql
Enter password:
 mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql
Enter password:

3,编译

# cd $GOPATH/src/github.com/open-falcon/falcon-plus/
# apt install make -y
# apt install gcc -y
# make all
# make agent
go build -ldflags "-X main.BinaryName=agent -X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=0.3.x" -o bin/agent/falcon-agent ./modules/agent
 make pack
go build -ldflags "-X main.BinaryName=Open-Falcon -X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=0.3.x" -o open-falcon
tar -C out -zcf open-falcon-v0.3.x.tar.gz .
# mkdir /root/open-falcon
# tar -zxvf open-falcon-v0.3.x.tar.gz -C /root/open-falcon/

3,运行

  • 启动所有的后端组件./open-falcon start
# ./open-falcon start
[falcon-graph] 9065
[falcon-hbs] 9081
[falcon-judge] 9095
[falcon-transfer] 9105
[falcon-nodata] 9116
[falcon-aggregator] 9127
[falcon-agent] 9140
[falcon-gateway] 9155
[falcon-api] 9165
[falcon-alarm] 9181
  • 检查模块启动情况
# ./open-falcon check
        falcon-graph         UP            9065
          falcon-hbs         UP            9081
        falcon-judge         UP            9095
     falcon-transfer         UP            9105
       falcon-nodata         UP            9116
   falcon-aggregator         UP            9127
        falcon-agent         UP            9140
      falcon-gateway         UP            9155
          falcon-api         UP            9165
        falcon-alarm         UP            9181

4,安装前端

# pwd
/root/open-falcon
# git clone git@github.com:open-falcon/dashboard.git

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

# apt install -y python-virtualenv slapd ldap-utils libmysqld-dev build-essential python-dev libldap2-dev libsasl2-dev libssl-dev
# pwd
/root/open-falcon/dashboard
# virtualenv ./env
Running virtualenv with interpreter /usr/bin/python2
New python executable in /root/open-falcon/dashboard/env/bin/python2
Also creating executable in /root/open-falcon/dashboard/env/bin/python

# ./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
# ./env/bin/pip install -r pip_requirements.txt
  • 配置文件
# cat rrd/config.py
  • 生产环境启动bash control start
# bash control start
falcon-dashboard started..., pid=15164
# bash control stop

  • 查看日志bash control tail
# bash control tail
[2019-11-28 17:21:25 +0000] [15164] [INFO] Starting gunicorn 19.9.0
[2019-11-28 17:21:25 +0000] [15164] [INFO] Listening at: http://0.0.0.0:8081 (15164)
[2019-11-28 17:21:25 +0000] [15164] [INFO] Using worker: sync
[2019-11-28 17:21:25 +0000] [15169] [INFO] Booting worker with pid: 15169
[2019-11-28 17:21:25 +0000] [15170] [INFO] Booting worker with pid: 15170
[2019-11-28 17:21:25 +0000] [15171] [INFO] Booting worker with pid: 15171
[2019-11-28 17:21:25 +0000] [15172] [INFO] Booting worker with pid: 15172

5,数据库连接报错

  • 查看日志
# tail /root/open-falcon/nodata/logs/nodata.log
db.go:38: config.InitDB error Error 1045: Access denied for user 'real_user'@'localhost' (using password: YES)
  • real_user:real_password替换为root:
  • 服务器登陆用户名为root,密码为空
grep -ilr real_user:real_password | xargs -n1 -- sed -i 's/real_user:real_password/root:/g'

6,设置环境变量

# echo 'export PATH=$PATH:/root/open-falcon' >> .bashrc
# source .bashrc
# which open-falcon
/root/open-falcon/open-falcon
# open-falcon check
        falcon-graph         UP            3769
          falcon-hbs         UP            3784
        falcon-judge         UP            3797
     falcon-transfer         UP            3807
       falcon-nodata         UP            3818
   falcon-aggregator         UP            3828
        falcon-agent         UP            3840
      falcon-gateway         UP            3855
          falcon-api         UP            3866
        falcon-alarm         UP            3883

7,安装问题,不要安装编译版本,要安装二进制版本

# ./open-falcon check
        falcon-graph       DOWN               -
          falcon-hbs       DOWN               -
        falcon-judge       DOWN               -
     falcon-transfer       DOWN               -
       falcon-nodata       DOWN               -
   falcon-aggregator       DOWN               -
        falcon-agent       DOWN               -
      falcon-gateway       DOWN               -
          falcon-api       DOWN               -
        falcon-alarm       DOWN               -
  • ERROR
# ./open-falcon start
expect config file: graph/config/cfg.json
# pwd
/root/go/src/github.com/open-falcon/falcon-plus/modules/graph
# cp cfg.example.json cfg.json
  • cfg.example.json 配置文件都改为 cfg.json
pwd
/root/go/src/github.com/open-falcon/falcon-plus/modules
# ls
agent  aggregator  alarm  api  gateway  graph  hbs  judge  nodata  transfer

8,设置环境变量

# echo 'export PATH=$PATH:/root/go/src/github.com/open-falcon/falcon-plus' >> /root/.bashrc
# source /root/.bashrc
# which open-falcon
/root/go/src/github.com/open-falcon/falcon-plus/open-falcon

参考:

  1. open-falcon github
  2. open-falcon 中文指导文档
  3. go Downloads
  4. Linux下Go的安装、配置 、升级和卸载
  5. Redis 安装
  6. macOS git 连接 github
  7. centos7 部署 open-falcon 0.2.1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值