influxdb 的简单安装/配置/使用

本文介绍了如何在Debian 9上安装最新版的InfluxDB,详细讲解了配置过程,包括开启认证。接着阐述了数据保留规则、连续查询的设定,以及在实际应用中如何使用连续查询进行30分钟频率的数据采样。还提到了CLI操作及时间格式化,最后提及了数据库的备份方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

数据源是通过influxdb-python写入到influxdb的,展示用的是grafana。

安装

for debian 9 strech version,这样才能是最新版本:

curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/os-release
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

sudo apt-get update && sudo apt-get install influxdb
sudo service influxdb start

配置

将默认配置导出到文件,influxd -config /etc/influxdb/influxdb.conf在创建数据库后用户后再打开认证,修改配置信息,打开认证。

[http]
  enabled = true
  bind-address = ":8086"
  auth-enabled = true # ✨

规则

Downsampling and data retention

retention policy

保留多久的数据

continuous query

按什么频率采样

4. Create the CQ

Now that we’ve set up our RPs, we want to create a CQ that will automatically and periodically downsample the ten-second resolution data to the 30-minute resolution, and store those results in a different measurement with a different retention policy.

Use the CREATE CONTINUOUS QUERY statement to generate a CQ:

> CREATE CONTINUOUS QUERY "cq_30m" ON "food_data" BEGIN
  SELECT mean("website") AS "mean_website",mean("phone") AS "mean_phone"
  INTO "a_year"."downsampled_orders"
  FROM "orders"
  GROUP BY time(30m)
END

That query creates a CQ called cq_30m in the database food_data. cq_30m tells InfluxDB to calculate the 30-minute average of the two fields website and phone in the measurement orders and in the DEFAULT RP two_hours. It also tells InfluxDB to write those results to the measurement downsampled_orders in the retention policy a_year with the field keys mean_website and mean_phone. InfluxDB will run this query every 30 minutes for the previous 30 minutes.

    Note: Notice that we fully qualify (that is, we use the syntax "<retention_policy>"."<measurement>") the measurement in the INTO clause. InfluxDB requires that syntax to write data to an RP other than the DEFAULT RP. 

实际使用说明

continuous query

CREATE CONTINUOUS QUERY org_stream_30m ON testdb BEGIN SELECT sum(value) INTO org_stream_30m FROM org_stream GROUP BY time(30m) END

org_stream按照30m分钟的频率采样插入org_stream_30m,group by time(30m),每30分钟执行一次。

select * from org_stream where time >= ‘2017-11-01T00:00:00Z’

CLI

时间 pretty

进入influx后,输入precision rfc3339

备份

backing and restore

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值