依赖时序数据库服务 GreptimeDB 安装初始化(可选)
Apache HertzBeat 的历史数据存储依赖时序数据库,任选其一安装初始化即可,也可不安装(注意⚠️但强烈建议生产环境配置)
我们推荐使用并长期支持 VictoriaMetrics 作为存储。
GreptimeDB is an open-source time-series database with a special focus on scalability, analytical capabilities and efficiency. It's designed to work on infrastructure of the cloud era, and users benefit from its elasticity and commodity storage.
⚠️ 若不配置时序数据库,则只会留最近一小时历史数据
通过Docker方式安装GreptimeDB
下载安装Docker环境 Docker 工具自身的下载请参考 Docker官网文档。 安装完毕后终端查看Docker版本是否正常输出。
$ docker -v
Docker version 20.10.12, build e91ed57Docker安装GreptimeDB
$ docker run -d -p 127.0.0.1:4000-4003:4000-4003 \
-v "$(pwd)/greptimedb:/tmp/greptimedb" \
--name greptime \
greptime/greptimedb:latest standalone start \
--http-addr 0.0.0.0:4000 \
--rpc-addr 0.0.0.0:4001 \
--mysql-addr 0.0.0.0:4002 \
--postgres-addr 0.0.0.0:4003-v "$(pwd)/greptimedb:/tmp/greptimedb为 greptimedb 数据目录本地持久化挂载,需将$(pwd)/greptimedb替换为实际本地存在的目录,默认使用执行命令的当前目录下的greptimedb目录作为数据目录。使用
$ docker ps查看数据库是否启动成功
在hertzbeat的application.yml配置文件配置此数据库连接
配置HertzBeat的配置文件 修改位于
hertzbeat/config/application.yml的配置文件 /script/application.yml 注意⚠️docker容器方式需要将application.yml文件挂载到主机本地,安装包方式解压修改位于hertzbeat/config/application.yml即可修改里面的
warehouse.store.jpa.enabled参数为false, 配置里面的warehouse.store.greptime数据源参数,URL账户密码,并启用enabled为truewarehouse:
store:
jpa:
enabled: false
greptime:
enabled: true
grpc-endpoints: localhost:4001
http-endpoint: http://localhost:4000
database: public
username: greptime
password: greptime默认数据库是内置的
public,若制定其它数据库名称,需要在greptimeDB提前创建。
eg: 创建名称为hertzbeat数据有效期90天的数据库 SQL:CREATE DATABASE IF NOT EXISTS hertzbeat WITH(ttl='90d')重启 HertzBeat
常见问题
时序数据库 GreptimeDB 或者 IoTDB 或者 TDengine 是否都需要配置,能不能都用
不需要都配置,任选其一即可,用enable参数控制其是否使用,也可都不安装配置,只影响历史图表数据。