一、背景
#
二、操作步骤
1.配置yum源
yum install epel-release -y
yum clean all
yum makecache
2.安装git
yum install git -y
[root@wushengtest-agent1 ~]# git version
git version 1.8.3.1
3.下载redis和mysql-server
yum install -y redis mysql-server
[root@wushengtest-agent2 ~]
[root@wushengtest-agent2 ~]
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
[root@wushengtest-agent1 ~]
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: active (running) since Sun 2018-09-02 12:40:34 CST; 10s ago
Main PID: 1606 (redis-server)
CGroup: /system.slice/redis.service
└─1606 /usr/bin/redis-server 127.0.0.1:6379
Sep 02 12:40:34 wushengtest-agent1 systemd[1]: Starting Redis persistent key-value database...
Sep 02 12:40:34 wushengtest-agent1 systemd[1]: Started Redis persistent key-value database.
[root@wushengtest-agent2 ~]
[root@wushengtest-agent2 ~]
Unknown operation 'enables'.
[root@wushengtest-agent2 ~]
[root@wushengtest-agent2 ~]
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2018-08-30 16:45:03 CST; 2 days ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 1421 (mysqld)
CGroup: /system.slice/mysqld.service
└─1421 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
4.后端安装
mkdir -p /home/src/github.com/open-falcon/
cd /home/src/github.com/open-falcon/
git clone https://github.com/open-falcon/falcon-plus.git
5.初始化MySQL表结构(请确保redis和MySQL已启动)
[root@wushengtest-agent2 db_schema]
[root@wushengtest-agent2 db_schema]
[root@wushengtest-agent2 db_schema]
Enter password:
[root@wushengtest-agent2 db_schema]
Enter password:
[root@wushengtest-agent2 db_schema]
Enter password:
[root@wushengtest-agent2 db_schema]
Enter password:
[root@wushengtest-agent2 db_schema]
Enter password:
6.编译源码打包
[root@wushengtest-agent2 falcon-plus]# cd /home/src/github.com/open-falcon/falcon-plus
[root@wushengtest-agent2 falcon-plus]# go get github.com/open-falcon/rrdlite
[root@wushengtest-agent2 falcon-plus]# 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
[root@wushengtest-agent2 falcon-plus]# 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 .
#由以上可知,在改路径下生成了open-falcon-v0.2.1.tar.gz,也可以直接访问https:
7.部署后端
[root@wushengtest-agent2 falcon-plus]# mkdir -p /home/work
[root@wushengtest-agent2 falcon-plus]# cd /home/src/github.com/open-falcon/falcon-plus
[root@wushengtest-agent2 falcon-plus]# tar -xzvf open-falcon-v0.2.1.tar.gz -C /home/work/
#修改配置
aggregator /home/work/aggregator/config/cfg.json
graph /home/work/graph/config/cfg.json
hbs /home/work/hbs/config/cfg.json
nodata /home/work/nodata/config/cfg.json
api /home/work/api/config/cfg.json
alarm /home/work/alarm/config/cfg.json
[root@wushengtest-agent2 work]# grep -Ilr 3306 ./
./aggregator/config/cfg.json
./graph/config/cfg.json
./hbs/config/cfg.json
./nodata/config/cfg.json
./api/config/cfg.json
./alarm/config/cfg.json
其他几个配置文件与之相同
8.启动后端
[root@wushengtest-agent2 work]# ./open-falcon start
[falcon-graph] 84620
[falcon-hbs] 84630
[falcon-judge] 84637
[falcon-transfer] 84643
[falcon-nodata] 84649
[falcon-aggregator] 84657
[falcon-agent] 84665
[falcon-gateway] 84672
[falcon-api] 84678
[falcon-alarm] 84686
9.部署前端
[root@wushengtest-agent2 work]# mkdir -p /home/front/open-falcon
[root@wushengtest-agent2 work]# git clone https:
Cloning into 'dashboard'...
remote: Counting objects: 1093, done.
remote: Compressing objects: 100% (39/39), done.
remote: Total 1093 (delta 16), reused 25 (delta 8), pack-reused 1044
Receiving objects: 100% (1093/1093), 1.45 MiB | 327.00 KiB/s, done.
Resolving deltas: 100% (582/582), done.
[root@wushengtest-agent2 work]# yum install -y python-virtualenv python-devel openldap-devel mysql-devel
[root@wushengtest-agent2 work]# yum groupinstall "Development tools" -y
#安装dashboard
[root@wushengtest-agent2 open-falcon]# cd /home/front/open-falcon/dashboard/
[root@wushengtest-agent2 dashboard]# virtualenv ./env
New python executable in /home/front/open-falcon/dashboard/env/bin/python
Installing setuptools, pip, wheel...done.
[root@wushengtest-agent2 dashboard]# ls
babel.cfg control Dockerfile entrypoint.sh env gunicorn.conf i18n.md LICENSE NOTICE pip_requirements.txt README.md rrd screenshots scripts wsgi.py
[root@wushengtest-agent2 dashboard]# ./env/bin/pip install -r pip_requirements.txt
#pip_requirement.txt内容如下
Flask==0.10.1
Flask-Babel==0.9
Jinja2==2.7.2
Werkzeug==0.9.4
gunicorn==19.9.0
python-dateutil==2.2
requests==2.3.0
mysql-python
python-ldap
10.启动open-falcon
[root@wushengtest-agent2 falcon-plus]
[root@wushengtest-agent2 dashboard]
falcon-dashboard started..., pid=100002
[root@wushengtest-agent2 dashboard]
falcon-dashboard now is running, pid=100002
11.通过浏览器,输入http://192.168.10.137:8081/auth/login 访问
12.dashbord没有默认创建任何账号包括管理账号,需要你通过页面进行注册账号。
想拥有管理全局的超级管理员账号,需要手动注册用户名为root的账号(第一个帐号名称为root的用户会被自动设置为超级管理员)。
超级管理员可以给普通用户分配权限管理。
小提示:注册账号能够被任何打开dashboard页面的人注册,所以当给相关的人注册完账号后,需要去关闭注册账号功能。只需要去修改api组件的配置文件cfg.json,将signup_disable配置项修改为true,重启api即可。当需要给人开账号的时候,再将配置选项改回去,用完再关掉即可。
13.安装open-falcon agent
通过scp命令把open-falcon 服务端/home/work/目录下的agent和open-falcon脚本以及public,plugins发送到需要监控的服务器上即可。(网上很多教程表示只需将agent目录和open-falcon脚本远程传输到相应服务器上即可,但是我复制过去,启动agent后端口1988已生成,并且日志中已正常无报错但是ip:端口访问显示404.经调试,应将agent同级public和plugins也复制过去后正常。)修改一下/home/work/agent/config/cfg.json中heartbeats的addr和transfer的addr改为服务端的ip:端口。
./open-falcon start agent
./falcon-agent --check
/home/work/agent/config/cfg.json
{
"debug": true,
"hostname": "",
"ip": "",
"plugin": {
"enabled": false,
"dir": "./plugin",
"git": "https://github.com/open-falcon/plugin.git",
"logs": "./logs"
},
"heartbeat": {
"enabled": true,
"addr": "127.0.0.1:6030",
"interval": 60,
"timeout": 1000
},
"transfer": {
"enabled": true,
"addrs": [
"127.0.0.1:18433"
],
"interval": 60,
"timeout": 1000
},
"http": {
"enabled": true,
"listen": ":1988",
"backdoor": false
},
"collector": {
"ifacePrefix": ["eth", "em"],
"mountPoint": []
},
"default_tags": {
},
"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
}
}
客户端目录展示
14.访问客户端,查看数据。http:客户端ip:1988
三、问题总结
1.go: cannot find GOROOT directory: /usr/lib/go
解决方法:在/etc/profile中定义go的路径,不然之后的go get配置会报错
export GOROOT=/usr/lib/golang GOPATH=/home
PATH="$PATH":/usr/bin/mysql:$GOROOT/bin
source /etc/profile
2.Error: HTTPConnectionPool(host=’127.0.0.1’, port=8080): Max retries exceeded with url: /api/v1/user/create (Caused by : [Errno 111] Connection refused)
解决方法:数据库./aggregator/config/cfg.json,./graph/config/cfg.json,./hbs/config/cfg.json,./nodata/config/cfg.json,./api/config/cfg.json,./alarm/config/cfg.json这几个文件配置账号密码的地方多注意,原本应该是root:root(mysql密码)@xxx,我写成root:@root导致数据库连不上
3.配置go指令环境变量否则make all报错
解决方法:同问题1中解决方法,配置go环境变量。
4.部署客户端后,修改cfg.json后日志中没有报错,访问ip:端口显示404.
解决方法:因为我把服务端的服务器也作为客户端监控,因此可以对比服务端中agent和客户端中agent的差异。将agent同级目录plugin和public复制到客户端agent同级,重启客户端即可。