Open-falcon 安装与部署
基础环境准备
- Centos 7 系统
- Redis
- Mysql
- Git
如不会 Redis、Mysql安装的,请移步我的Blog
数据库 | Category | 凯撒公猿www.liuwq.com当然也可以直接yum安装:
yum install -y redis
yum install -y mysql-server
yum install -y git
mysql -uroot -p
# 创建用户名及密码并赋权
MySQL [(none)]> grant all privileges on *.* to openfalcon@'%' identified by 'openfalcon';
Query OK, 0 rows affected, 1 warning (0.01 sec)
# 刷新权限
MySQL [(none)]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
安装完成后确保redis、mysql都正常启动
如果OK继续进行。
初始化MySQL表结构
# 下载open-falcon源码
cd /root/ && git clone https://github.com/open-falcon/falcon-plus.git
# 导入表结构
vim /root/into_mysql.sh
SQL_DIR=/root/falcon-plus/scripts/mysql/db_schema/
MYSQL_HOST='127.0.0.1'
MYSQL_USER='openfalcon'
MYSQL_PASSWD='openfalcon'
for i in `ls ${SQL_DIR}`
do
mysql -h ${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASSWD} < ${SQL_DIR}$i
done
# 授权
chmod 755 /root/into_mysql.sh
sh /root/into_mysql.sh
出现如下数据库,创建成功。
后端部署
由于后端使用golang编写,需要go的环境
安装go环境
- 下载go安装包
wget https://dl.google.com/go/go1.14.linux-amd64.tar.gz
- 解压下载go tar包
tar -C /usr/local -xzf go1.14.linux-amd64.tar.gz
- 添加go的环境变量
vim /etc/profile
# 在最后添加如下一行
export PATH=$PATH:/usr/local/go/bin
# 重新加载配置文件
source /etc/profile
- 验证环境变量是否添加成功
[root@VM_0_7_centos ~]# go
Go is a tool for managing Go source code.
Usage:
go <command> [arguments]
The commands are:
bug start a bug report
build compile packages and dependencies
clean remove object files and cached files
doc show documentation for package or symbol
env print Go environment information
fix update packages to use new APIs
如果出现上面信息,证明安装成功。
项目包的编译
还记的我们之前git clone的项目地址吗?
cp -rf /tmp/falcon-plus /root/
cd /root/falcon-plus
- 更改go 源为国内阿里云源
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/
# 检查是否更改成功,出现如下成功
[root@VM_0_7_centos falcon-plus]# go env | grep GOPROXY
GOPROXY="https://mirrors.aliyun.com/goproxy/"
- 执行go包存放地址创建目录
cd /root/falcon-plus
go get
# 等几秒钟,ctrl +c 终止命令
观察是否出现go文件夹
- 项目源代码迁移
cp -rf /root/falcon-plus /root/go/src/github.com/open-falcon
cd /root/go/src/github.com/open-falcon/falcon-plus
# 执行编译
[root@VM_0_7_centos falcon-plus]# make all
# 执行打包
[root@VM_0_7_centos falcon-plus]# 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 .
目录文件出现如下字样,则编译打包成功
创建工作目录
export FALCON_HOME=/home/work
export WORKSPACE=$FALCON_HOME/open-falcon
mkdir -pv $WORKSPACE
解压二进制包
cd /root/go/src/github.com/open-falcon/falcon-plus
tar -xzvf open-falcon-v0.3.x.tar.gz -C $WORKSPACE
启动所有的后端组件
- 首先确认配置文件中数据库账号密码与实际相同,否则需要修改配置文件。
cd $WORKSPACE
grep -Ilr 3306 ./ | xargs -n1 -- sed -i 's/root:/real_user:real_password/g'
注意:real_user为数据库登录名称,real_password为数据登录密码
- 启动
cd $WORKSPACE
[root@VM_0_7_centos open-falcon]# ./open-falcon start
[falcon-graph] 14848
[falcon-hbs] 14856
[falcon-judge] 14864
[falcon-transfer] 14870
[falcon-nodata] 14876
[falcon-aggregator] 14883
[falcon-agent] 14891
[falcon-gateway] 14897
[falcon-api] 14903
[falcon-alarm] 14917
- 检查所有模块的启动状况
[root@VM_0_7_centos open-falcon]# ./open-falcon check
falcon-graph UP 14848
falcon-hbs UP 14856
falcon-judge UP 14864
falcon-transfer UP 14870
falcon-nodata UP 14876
falcon-aggregator UP 14883
falcon-agent UP 14891
falcon-gateway UP 14897
falcon-api UP 14903
falcon-alarm UP 14917
- 更多的命令行工具用法
./open-falcon [start|stop|restart|check|monitor|reload] module
- 启动agent客户端
./open-falcon start agent
./open-falcon check
falcon-graph UP 53007
falcon-hbs UP 53014
falcon-judge UP 53020
falcon-transfer UP 53026
falcon-nodata UP 53032
falcon-aggregator UP 53038
falcon-agent UP 53044
falcon-gateway UP 53050
falcon-api UP 53056
falcon-alarm UP 53063
For debugging , You can check $WorkDir/$moduleName/log/logs/xxx.log
后端部署至此完成。
前端部署
环境准备
- 创建工作目录
export HOME=/home/work
export WORKSPACE=$HOME/open-falcon
mkdir -p $WORKSPACE
cd $WORKSPACE
- 克隆前端组件代码
cd $WORKSPACE
git clone https://github.com/open-falcon/dashboard.git
- 安装依赖包
yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall "Development tools"
- 创建python虚拟环境
cd $WORKSPACE/dashboard/
virtualenv ./env
- 安装python依赖包
./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
# 如果有类似提示
You are using pip version 9.0.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
# 更新pip,然后重新执行上面命令即可
./env/bin/pip install --upgrade pip
- 修改配置
dashboard的配置文件为: 'rrd/config.py',请根据实际情况修改
## API_ADDR 表示后端api组件的地址
API_ADDR = "http://127.0.0.1:8080/api/v1"
## 根据实际情况,修改PORTAL_DB_*, 默认用户名为root,默认密码为""
## 根据实际情况,修改ALARM_DB_*, 默认用户名为root,默认密码为""
- 以开发者模式启动
./env/bin/python wsgi.py
open http://127.0.0.1:8081 in your browser.
- 在生产环境启动
bash control start
open http://127.0.0.1:8081 in your browser.
# 停止dashboard运行
bash control stop
# 查看日志
bash control tail
dashbord用户管理
- dashbord没有默认创建任何账号包括管理账号,需要你通过页面进行注册账号。
想拥有管理全局的超级管理员账号,需要手动注册用户名为root的账号(第一个帐号名称为root的用户会被自动设置为超级管理员)。- 超级管理员可以给普通用户分配权限管理。
小提示:注册账号能够被任何打开dashboard页面的人注册,所以当给相关的人注册完账号后,需要去关闭注册账号功能。 只需要去修改api组件的配置文件cfg.json,将signup_disable配置项修改为true,重启api即可。 当需要给人开账号的时候,再将配置选项改回去,用完再关掉即可。
至此,我们单机版本的安装部署已经完成,最后通过IP:8081 进行访问
- 简单测试
后面再对dashboard详解
各位小伙伴如果觉得还可以,请关注、点赞、收藏。感谢各位!
5551

被折叠的 条评论
为什么被折叠?



