Open-Falcon是做什么的这里就不多描述了,可以参考一下官方的解释,(http://book.open-falcon.org/zh_0_2/intro/)这里是2.0的版本,本人在本地做了一些测试,单价安装和分布式安装的区别在这里说一下,单机安装只是把所有组件安装在一台机器上,分布式安装时组件分别安装在不同的机器上,这里不建议一个组件安装在一台机器上,如果想选择高可用,可以进行交叉安装,只是在组件的端口需要自己修改一下,记得一定要在做之前规划好,组件多端口也多,不然容易混淆。下面是我的单机安装实验:
环境准备
[root@localhost ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm [root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm [root@localhost ~]# yum install -y redis [root@localhost ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm [root@localhost ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm [root@open-falcon-server ~]# yum install -y mysql-server [root@open-falcon-server ~]# cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git [root@open-falcon-server tmp]# cd /tmp/falcon-plus/scripts/mysql/db_schema/
安装后一定要启动,!!!!!
[root@open-falcon-server ~]# systemctl status mysql ● mysqld.service - MySQL Community Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since 四 2019-12-26 17:21:52 CST; 6s ago Process: 30494 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS) Process: 30434 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 30493 (mysqld_safe) CGroup: /system.slice/mysqld.service ├─30493 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─30659 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock 12月 26 17:21:51 open-falcon-server mysql-systemd-start[30434]: Support MySQL by buying support/licenses at http://shop.mysql.com 12月 26 17:21:51 open-falcon-server mysql-systemd-start[30434]: Note: new default config file not created. 12月 26 17:21:51 open-falcon-server mysql-systemd-start[30434]: Please make sure your config file is current 12月 26 17:21:51 open-falcon-server mysql-systemd-start[30434]: WARNING: Default config file /etc/my.cnf exists on the system 12月 26 17:21:51 open-falcon-server mysql-systemd-start[30434]: This file will be read by default by the MySQL server 12月 26 17:21:51 open-falcon-server mysql-systemd-start[30434]: If you do not want to use this, either remove it, or use the 12月 26 17:21:51 open-falcon-server mysql-systemd-start[30434]: --defaults-file argument to mysqld_safe when starting the server 12月 26 17:21:51 open-falcon-server mysqld_safe[30493]: 191226 17:21:51 mysqld_safe Logging to '/var/log/mysqld.log'. 12月 26 17:21:51 open-falcon-server mysqld_safe[30493]: 191226 17:21:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 12月 26 17:21:52 open-falcon-server systemd[1]: Started MySQL Community Server. [root@open-falcon-server ~]# systemctl start redis [root@open-falcon-server ~]# systemctl status redis ● redis.service - Redis persistent key-value database Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/redis.service.d └─limit.conf Active: active (running) since 四 2019-12-26 17:20:36 CST; 6s ago Main PID: 30378 (redis-server) CGroup: /system.slice/redis.service └─30378 /usr/bin/redis-server 127.0.0.1:6379 12月 26 17:20:36 open-falcon-server systemd[1]: Starting Redis persistent key-value database... 12月 26 17:20:36 open-falcon-server systemd[1]: Started Redis persistent key-value database.
默认mysql是没有密码的,所以需要给mysql的管理员设置一个密码,让后把open-falcon的数据导入到mysql中。
[root@open-falcon-server db_schema]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.46 MySQL Community Server (GPL) Copyright (c) 2000, 2019, 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 | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.00 sec) mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set password=password('root') where user='root' and host='localhost'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0
重启一下mysql,然后从新使用密码登录进去,并把需要使用的mysql导入进去,这里应用和mysql使用的是一台机器,就不设置mysql客户端授权,如果不同需要设置授权连接账号和密码。
[root@open-falcon-server db_schema]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.46 MySQL Community Server (GPL) Copyright (c) 2000, 2019, 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> source 1_uic-db-schema.sql mysql> source 2_portal-db-schema.sql mysql> source 3_dashboard-db-schema.sql mysql> source 4_graph-db-schema.sql mysql> source 5_alarms-db-schema.sql mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | alarms | #5 | dashboard | #3 | falcon_portal | #2 | graph | #4 | mysql | | performance_schema | | uic | #1 +--------------------+ 8 rows in set (0.00 sec)
导入的库已经完成,这里要记住如果是从v0.1.0升级到v0.2.0只需要到入5_alarms-db-schema.sql即可,因为其他库已经存在了。
安装依赖go
因为open-falcon依赖go进行编译,所以需要使用go环境,下面是安装go的方法:
下载源码包
[root@open-falcon-server ~]# wget https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz [root@open-falcon-server ~]# tar -zxf go1.13.5.linux-amd64.tar.gz [root@open-falcon-server ~]# mv go /usr/local/ [root@open-falcon-server ~]# mkdir /opt/go
设置环境变量
[root@open-falcon-server ~]# vim /etc/profile ........................................... export GOROOT=/usr/local/go export GOBIN=$GOROOT/bin export GOPKG=$GOROOT/pkg/tool/linux_amd64 export GOARCH=amd64 export GOOS=linux export GOPATH=/opt/go export PATH=$PATH:$GOBIN:$GOPKG:$GOPATH/bin [root@open-falcon-server ~]# source /etc/profile
测试一下
[root@open-falcon-server ~]# go version go version go1.13.3 linux/amd64
下载open-falcon源码包,然后进行编译
[root@open-falcon-server ~]# mkdir -p $GOPATH/src/github.com/open-falcon [root@open-falcon-server ~]# cd $GOPATH/src/github.com/open-falcon [root@open-falcon-server open-falcon]# git clone https://github.com/open-falcon/falcon-plus.git [root@open-falcon-server falcon-plus]# make all [root@open-falcon-server falcon-plus]# make pack [root@open-falcon-server falcon-plus]# ls api-standard.md cmd common CONTRIBUTING.md Dockerfile docs LICENSE logos Makefile NOTICE open-falcon-v0.3.x.tar.gz scripts vagrant VERSION bin CODE_OF_CONDUCT.md config docker docker_test.sh g logo.png main.go modules open-falcon README.md test vendor version.go [root@open-falcon-server falcon-plus]# export FALCON_HOME=/home/work [root@open-falcon-server falcon-plus]# export WORKSPACE=$FALCON_HOME/open-falcon [root@open-falcon-server falcon-plus]# mkdir -p $WORKSPACE [root@open-falcon-server opt]# tar -xzvf open-falcon-v0.3.x.tar.gz -C $WORKSPACE [root@open-falcon-server opt]# cd $WORKSPACE [root@open-falcon-server open-falcon]# grep -Ilr 3306 ./ | xargs -n1 -- sed -i 's/root:/root:root/g' root@open-falcon-server open-falcon]# cd $WORKSPACE [root@open-falcon-server open-falcon]# ./open-falcon start [falcon-graph] 27078 [falcon-hbs] 27089 [falcon-judge] 27097 [falcon-transfer] 27105 [falcon-nodata] 27112 [falcon-aggregator] 27124 [falcon-agent] 27136 [falcon-gateway] 27146 [falcon-api] 27155 [falcon-alarm] 27164 [root@open-falcon-server open-falcon]# ./open-falcon check #检查所有模块的启动状态 falcon-graph UP 27078 falcon-hbs UP 27089 falcon-judge UP 27097 falcon-transfer UP 27105 falcon-nodata UP 27112 falcon-aggregator UP 27124 falcon-agent UP 27136 falcon-gateway UP 27146 falcon-api UP 27155 falcon-alarm UP 27164
安装前端
设置一下基本环境
[root@open-falcon-server alarm]# export HOME=/home/work [root@open-falcon-server alarm]# export WORKSPACE=$HOME/open-falcon [root@open-falcon-server alarm]# mkdir -p $WORKSPACE [root@open-falcon-server alarm]# cd $WORKSPACE [root@open-falcon-server open-falcon]# cd $WORKSPACE [root@open-falcon-server open-falcon]# git clone https://github.com/open-falcon/dashboard.git
安装依赖包
安装前端服务器之前先安装一下依赖包,因为是python开发的,所以需要安装pip的模块。
[root@open-falcon-server open-falcon]# yum install -y python-virtualenv [root@open-falcon-server open-falcon]# yum install -y python-devel [root@open-falcon-server open-falcon]# yum install -y openldap-devel [root@open-falcon-server open-falcon]# yum install -y mysql-devel [root@open-falcon-server open-falcon]# yum groupinstall "Development tools" [root@open-falcon-server open-falcon]# cd $WORKSPACE/dashboard/ [root@open-falcon-server dashboard]# virtualenv ./env New python executable in /home/work/open-falcon/dashboard/env/bin/python Installing setuptools, pip, wheel...done. [root@open-falcon-server dashboard]# ./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
配置客户端连接数据库信息:
[root@open-falcon-server dashboard]# vim rrd/config.py ..................................................... # portal database # 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","root") 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","root") ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms") ............................................................
启动前端服务
以开发者模式启动
./env/bin/python wsgi.py
生产环境启动
bash control start bash control stop bash control tail #查看日志
客户端部署
open-falcon服务端已经安装完成,下面我们安装客户端,这里提示一下服务端安装之后已经自带了客户端,为了方便,我们把客户端的agent拷贝到其他机器上即可,然后配置一下指定到服务端启动一下即可。
[root@open-falcon-server open-falcon]# pwd /home/work/open-falcon [root@open-falcon-server open-falcon]# cp open-falcon agent/ [root@open-falcon-server open-falcon]# scp -r agent root@10.211.55.140:/home/work
首先需要把启动的文件copy到客户端目录下,方便客户端启动,然后在把数据传输到客户端上了,我们在客户端上配置一下,指向server,然后启动。
[root@open-falcon-agent config]# pwd /home/work/agent/config [root@open-falcon-agent config]# vim 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": "10.211.55.141:6030", "interval": 60, "timeout": 1000 }, "transfer": { "enabled": true, "addrs": [ "10.211.55.141:8433" ], "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 } } [root@open-falcon-agent config]# cd ../.. [root@open-falcon-agent work]# ./agent/open-falcon start agent
启动成功,下面看一下前端是否有接受到新的客户端。到此,Open-Falcon的部署已经完成,下一章就是前端报警的设置了。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏