Open-Falcon部署分为前端(客户端)和后端(服务端)
参考官方文档:https://book.open-falcon.org/zh_0_2/quick_install/prepare.html
一 后端(服务端)部署
1、系统环境
[root@open-falcon-server ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
2、软件环境准备
2.1 安装 redis
#安装
yum install redis -y
#redis常用命令
redis-server redis 服务端
redis-cli redis 命令行客户端
redis-benchmark redis 性能测试工具
redis-check-aof AOF文件修复工具
redis-check-dump RDB文件修复工具
redis-sentinel Sentinel 服务端
#启动redis
[root@open-falcon-server ~]# redis-server
2.2 安装mysql
#安装mysql
[root@open-falcon-server ~]#wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@open-falcon-server ~]# ll
[root@open-falcon-server ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
[root@open-falcon-server ~]# ll /etc/yum.repos.d/
[root@open-falcon-server ~]#yum install -y mysql-serve
#启动mysql并设置开机自启动
[root@open-falcon-server ~]# systemctl start mysqld.service
[root@open-falcon-server ~]# systemctl enable mysqld.service
[root@open-falcon-server ~]# mysql -uroot -p
(没有密码)
mysql> exit
#检查服务
netstat -lntup
#初始化MySQL表结构(备注:导入表结构后,注意检查)
cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git
cd /tmp/falcon-plus/scripts/mysql/db_schema/
mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql
rm -rf /tmp/falcon-plus/
#设置数据库密码 (备注:用户名:root ,密码: password )
[root@open-falcon-server open-falcon]# mysqladmin -uroot password "password"
#检查导入的数据库表
[root@open-falcon-server open-falcon]# mysql -uroot -p
mysql> show databases;
information_schema | | alarms | | dashboard | | falcon_portal | | graph | | mysql | | performance_schema | | uicmysql> exit
2.3配置Go语言开发环境
#安装go语言开发包(备注:安装需要epel源)
yum install golang -y
补充:epel源
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
ll
rpm -ivh epel-release-latest-7.noarch.rpm
#检查版本
[root@open-falcon-server ~]# go version
#查看go的安装路径
[root@open-falcon-server ~]# find / -name go
/etc/alternatives/go
/var/lib/alternatives/go
/usr/bin/go
/usr/lib/golang/src/cmd/go #需要的是这个路径
/usr/lib/golang/src/go
/usr/lib/golang/bin/go
/usr/lib/golang/pkg/linux_amd64/go
#设置环境变量GOROOT和GOPATH
vi /etc/profile
export GOROOT=/usr/lib/golang
export GOPATH=/home
source /etc/profile
3.下载编译好的二进制版本
直接下载官方编译好的二进制版本(x86 64位平台)。
https://github.com/open-falcon/falcon-plus/releases
#开始安装open-falcon
[root@open-falcon-server ~]# export FALCON_HOME=/home/work
[root@open-falcon-server ~]# export WORKSPACE=$FALCON_HOME/open-falcon
[root@open-falcon-server ~]# mkdir -p $WORKSPACE
#上传软件
[root@open-falcon-server ~]# ll
-rw-r--r--. 1 root root 40031472 Oct 29 2017 open-falcon-v0.2.1.tar.gz
#解压
[root@open-falcon-server ~]# tar -xf open-falcon-v0.2.1.tar.gz -C $WORKSPACE
[root@open-falcon-server ~]# cd $WORKSPACE
#查看解压结果
[root@open-falcon-server open-falcon]# ll
total 3896
drwxrwxr-x. 7 501 501 67 Aug 15 19:16 agent
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 aggregator
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 alarm
drwxrwxr-x. 6 501 501 51 Aug 15 19:16 api
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 gateway
drwxrwxr-x. 6 501 501 51 Aug 15 19:16 graph
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 hbs
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 judge
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 nodata
-rwxrwxr-x. 1 501 501 3987469 Aug 15 19:16 open-falcon
lrwxrwxrwx. 1 501 501 16 Aug 15 19:16 plugins -> ./agent/plugins/
lrwxrwxrwx. 1 501 501 15 Aug 15 19:16 public -> ./agent/public/
drwxrwxr-x. 5 501 501 40 Aug 15 19:16 transfer
4.修改配置文件cfg.json
部分模块依赖连接数据库,因为如果不修改配置文件,aggregator模块会出现无法启动,graph、hbs、nodata、api、alarm模块会出现开启不报错但是状态为开启失败的情况。
如果需要每个模块都能正常启动,需要将上面模块的cfg.json的数据库信息进行修改。需要修改配置文件所在的目录:
1)修改aggregator的配置文件
vim /home/work/aggregator/config/cfg.json
2)修改graph的配置文件
vim /home/work/graph/config/cfg.json
3)修改hbs的配置文件
vim /home/work/hbs/config/cfg.json
4)修改nodata的配置文件
vim /home/work/nodata/config/cfg.json
5)修改api的配置文件
vim /home/work/api/config/cfg.json
6)修改alarm的配置文件
vim /home/work/alarm/config/cfg.json
5.启动后端模块
[root@open-falcon-server open-falcon]# cd /home/work/open-falcon
#启动服务
[root@open-falcon-server open-falcon]# ./open-falcon start
#检查服务启动状态
[root@open-falcon-server open-falcon]# ./open-falcon check
#更多的命令行工具用法
# ./open-falcon [start|stop|restart|check|monitor|reload] module
./open-falcon start agent
#For debugging , You can check $WorkDir/$moduleName/log/logs/xxx.log
6.其它用法
#重载配置(备注:修改vi cfg.json配置文件后,可以用下面命令重载配置)
curl 127.0.0.1:1988/config/reload
二 前端部署 (备注:在另外一台服务器上面操作)
1、创建工作目录
export HOME=/home/work
export WORKSPACE=$HOME/open-falcon
mkdir -p $WORKSPACE
cd $WORKSPACE
2、克隆前端组件代码
git clone https://github.com/open-falcon/dashboard.git
3、安装依赖包
yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall "Development tools" -y
cd $WORKSPACE/dashboard/
virtualenv ./env
./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
#配置说明:
dashboard的配置文件为: 'rrd/config.py',请根据实际情况修改
## API_ADDR 表示后端api组件的地址
API_ADDR = "http://127.0.0.1:8080/api/v1"
## 根据实际情况,修改PORTAL_DB_*, 默认用户名为root,默认密码为""
## 根据实际情况,修改ALARM_DB_*, 默认用户名为root,默认密码为""
#修改方法
[root@Open-Falcon-client]#cd /home/work/open-falcon/dashboard/rrd
[root@Open-Falcon-client rrd]# cp config.py config.py.bak
(env)[root@Open-Falcon-client rrd]# vi config.py
#-*-coding:utf8-*-
# Copyright 2017 Xiaomi, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# app config
import os
LOG_LEVEL = os.environ.get("LOG_LEVEL",'DEBUG')
SECRET_KEY = os.environ.get("SECRET_KEY","secret-key")
PERMANENT_SESSION_LIFETIME = os.environ.get("PERMANENT_SESSION_LIFETIME",3600 * 24 * 30)
SITE_COOKIE = os.environ.get("SITE_COOKIE","open-falcon-ck")
# Falcon+ API
API_ADDR = os.environ.get("API_ADDR","http://192.168.1.180:8080/api/v1")
# portal database
# TODO: read from api instead of db
PORTAL_DB_HOST = os.environ.get("PORTAL_DB_HOST","192.168.1.180")
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","password")
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","192.168.1.180")
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","password")
ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms")
# ldap config
LDAP_ENABLED = os.environ.get("LDAP_ENABLED",False)
LDAP_SERVER = os.environ.get("LDAP_SERVER","ldap.forumsys.com:389")
LDAP_BASE_DN = os.environ.get("LDAP_BASE_DN","dc=example,dc=com")
LDAP_BINDDN_FMT = os.environ.get("LDAP_BINDDN_FMT","uid=%s,dc=example,dc=com")
LDAP_SEARCH_FMT = os.environ.get("LDAP_SEARCH_FMT","uid=%s")
LDAP_ATTRS = ["cn","mail","telephoneNumber"]
LDAP_TLS_START_TLS = False
LDAP_TLS_CACERTDIR = ""
LDAP_TLS_CACERTFILE = "/etc/openldap/certs/ca.crt"
LDAP_TLS_CERTFILE = ""
LDAP_TLS_KEYFILE = ""
LDAP_TLS_REQUIRE_CERT = True
LDAP_TLS_CIPHER_SUITE = ""
# i18n
BABEL_DEFAULT_LOCALE = 'zh_CN'
BABEL_DEFAULT_TIMEZONE = 'Asia/Shanghai'
# aviliable translations
LANGUAGES = {
'en': 'English',
'zh_CN': 'Chinese-Simplified',
}
# portal site config
MAINTAINERS = ['root']
CONTACT = 'root@open-falcon.org'
try:
from rrd.local_config import *
except:
print "[warning] no local config file"
原文章地址:
有疑问加站长微信联系(非本文作者)