小米开源监控 Open-Falcon 3.0 部署

本贴最后更新于 1902 天前,其中的信息可能已经时移世易

一、系统环境准备

目前我这里使用单机版进行部署,也可以前后端进行分离,前端,后端,数据库分别在不同的服务器上进行部署搭建

1、更改主机名

[root@localhost ~]# hostnamectl set-hostname open-falcon

[root@localhost ~]# su

[root@open-falcon ~]#

2、配置阿里源

####备份系统BASE源

[root@open-falcon ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

 

####阿里源####

[root@open-falcon ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

####epel源####

[root@open-falcon ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

####更新缓存####

[root@open-falcon ~]# *yum clean all*

[root@open-falcon ~]# yum makecache

[root@open-falcon ~]# yum repolist

3、安装基础命令

[root@localhost ~]# yum -y install vim net-tools lrzsz ntp wget get curl rsync git

4、时间同步

[root@open-falcon ~]# systemctl start ntpd

[root@open-falcon ~]# systemctl enable ntpd

[root@open-falcon ~]# systemctl status ntpd

[root@open-falcon ~]# date #检查时间

5、关闭防火墙

[root@open-falcon ~]# systemctl stop firewalld

[root@open-falcon ~]# systemctl disable firewalld

[root@open-falcon ~]# setenforce 0

[root@open-falcon ~]# sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

二、软件环境准备

1、部署 go

注意: 官方 yum 和阿里 yum 都没有 go 的安装包,只能通过 fedora 的 epel 仓库来安装

#安装
[root@open-falcon ~]# yum install -y epel-release
[root@open-falcon ~]# yum install golang -y 

#检查
[root@open-falcon ~]# go version
go version go1.11.5 linux/amd64

2、部署 redis

部署新版redis
[root@open-falcon ~]# yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

#安装
[root@open-falcon ~]# yum --enablerepo=remi install redis

#启动
[root@open-falcon ~]# systemctl start redis

#开机自启

[root@open-falcon ~]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.

#检查状态
[root@open-falcon ~]# systemctl status redis

3、部署 MySQL

yum 源为 5.5 版本,我这里安装 5.7 版本

3.1:下载 MySQL 源

[root@open-falcon ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

3.2:安装 yum Repository

[root@open-falcon ~]# rpm -ivh mysql57-community-release-el7-11.noarch.rpm

3.3:安装 MySQL 服务端

#查看mysql server
[root@open-falcon ~]# yum repolist enabled | grep "mysql.*-community.*"

[root@open-falcon ~]# yum repolist all | grep mysql

#安装
[root@open-falcon ~]# yum install mysql-community-server

3.4:启动 mysql 服务

[root@open-falcon ~]# systemctl start mysqld.service
[root@open-falcon ~]# systemctl enable mysqld.service
[root@open-falcon ~]# systemctl status mysqld.service

3.5:登陆数据库

MySQL5.7.6 之后会在启动 mysql 进程的时候生成一个用户密码,首次登陆需要这个密码才行。密码保存在 mysql 进程的日志里,即(/var/log/mysqld.log)

#查看登陆密码
[root@open-falcon ~]#  cat /var/log/mysqld.log | grep 'password'

#登陆
[root@open-falcon ~]#  mysql -uroot -p

5.6:修改 root 密码

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.


以前的 password()函数将会被抛弃,官方建议使用下面的命令来修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

同时,如果你设置的密码过于简单也会报错。
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

解决密码过短问题
mysql> set global validate_password_policy=0;

再次设置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123';

三、部署 open-falcon

1、部署后端

1.1:初始化数据库

[root@open-falcon ~]#  cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git

[root@open-falcon ~]# cd /tmp/falcon-plus/scripts/mysql/db_schema/
 
[root@open-falcon ~]# mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql

[root@open-falcon ~]# mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql

[root@open-falcon ~]# mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql

[root@open-falcon ~]# mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql

[root@open-falcon ~]# mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql

[root@open-falcon ~]# rm -rf /tmp/falcon-plus/

1.2:创建工作目录

[root@open-falcon ~]# vim /etc/profile

export FALCON_HOME=/usr/local/open-falcon

[root@open-falcon ~]# source /etc/profile

[root@open-falcon ~]# mkdir -p $FALCON_HOME

1.3:程序包下载

l 将源码解压到该路径

[root@open-falcon ~]# wget https://github.com/open-falcon/falcon-plus/releases/download/v0.3/open-falcon-v0.3.tar.gz

[root@open-falcon ~]# tar -zxvf open-falcon-v0.3.tar.gz -C $FALCON_HOME

[root@open-falcon ~]# cd $FALCON_HOME

1.4:修改配置文件 cfg.json

[root@open-falcon ~]# vim /usr/local/open-falcon/aggregator/config/cfg.json
%s#root:#root:passwd#g
image.png

[root@open-falcon ~]# vim /usr/local/open-falcon/graph/config/cfg.json
%s#root:#root:passwd#g
image.png

[root@open-falcon ~]# vim /usr/local/open-falcon/hbs/config/cfg.json
image.png

[root@open-falcon ~]# vim /usr/local/open-falcon/nodata/config/cfg.json
image.png

[root@open-falcon ~]# vim /usr/local/open-falcon/api/config/cfg.json
image.png

[root@open-falcon ~]# vim /usr/local/open-falcon/alarm/config/cfg.json
image.png

1.5:启动后端

[root@open-falcon ~]# cd $FALCON_HOME
[root@open-falcon open-falcon]# ./open-falcon start

#检查
[root@open-falcon open-falcon]# ./open-falcon check

2、部署前端

1.2:前端代码下载

[root@open-falcon ~]# cd $FALCON_HOME
[root@open-falcon open-falcon]# git clone https://github.com/open-falcon/dashboard.git

1.3:安装依赖包

[root@open-falcon open-falcon]# yum install -y python-virtualenv
[root@open-falcon open-falcon]# yum install -y python-devel
[root@open-falcon open-falcon]# yum install -y openldap-devel
[root@open-falcon open-falcon]# yum install -y mysql-devel
[root@open-falcon open-falcon]# yum groupinstall "Development tools" -y

1.6:查看需要安装的模块

[root@open-falcon dashboard]# cat pip_requirements.txt
Flask==1.0
Flask-Babel==0.9
Jinja2>=2.10.1
Werkzeug==0.15.3
gunicorn==19.9.0
python-dateutil==2.2
requests==2.3.0
mysql-python
python-ldap

注意:3.0 版本修改 Werkzeug==0.15.4 才可以启动

[root@open-falcon dashboard]# vim pip_requirements.txt
Werkzeug==0.15.4

1.7:安装模块

[root@open-falcon open-falcon]# cd dashboard/
[root@open-falcon dashboard]# virtualenv ./env
[root@open-falcon dashboard]# ./env/bin/pip install -r pip_requirements.txt

1.8:修改配置

配置说明:
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 dashboard]# cp rrd/config.py{,_bak}
[root@open-falcon dashboard]# vim rrd/config.py

image.png

1.9:启动服务

#生产环境启动
[root@open-falcon dashboard]# bash control start

#开发模式启动
[root@open-falcon dashboard]# ./env/bin/python wsgi.py

四、访问网站

默认端口 8081
http://ip:8081
image.png

  • 注意:dashbord 默认没有创建任何账号包括管理账号,需要你通过页面进行注册账号
    image.png
    image.png
    image.png

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...