Files
blog-press/docs/Web/Others/InfluxDB.md
2026-05-20 11:26:38 +08:00

83 lines
2.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: InfluxDB简介和使用
date: 2026-05-11
---
# 一、简介
  InfluxDB 是一个开源的时序数据库Time Series Database, TSDB由 InfluxData 公司开发专门用于存储、查询和处理时间序列数据按时间顺序记录的数据点。它在监控、物联网IoT、实时分析等场景中广泛应用是时序数据领域的流行解决方案之一。
  InfluxDB 3.0 是一次底层的彻底重构(内核代号 IOx核心代码从 Go 改写为 Rust并从自研的 TSM 引擎转向基于 Apache Arrow 生态的开放架构。
# 二、特点
1. Rust 全新重写:更快、更省内存、更稳
2. 支持无限标签基数:不再怕设备 ID、用户 ID 这类高基数场景
3. 原生支持标准 SQL不用只学 InfluxQL普通 SQL 直接查
4. 底层基于 Arrow + Parquet列式存储、压缩率高、查询快
5. 原生对接对象存储:支持 S3/OSS冷热数据自动分层可存海量历史数据
# 三、概念
1. 库 Database相当于 MySQL 的库,隔离业务数据
2. 测量 Measurement相当于 MySQL 的表(比如 cpu、温度传感器
3. 标签 Tag维度、索引字段字符串如设备 id、地区用来筛选分组
4. 字段 Field实际指标值数值如温度、CPU 使用率,不做索引)
5. 时间 Time自带时间戳时序数据唯一主键、按时间排序
# 四、安装
## 4.1 Docker安装
```yml
services:
influxdb3-core:
image: influxdb:3.9.1-core
container_name: influxdb3-core
restart: unless-stopped
networks:
- influx-network
ports:
- "8181:8181"
volumes:
- ./influxdb3/data:/var/lib/influxdb3/data
- ./influxdb3/plugins:/var/lib/influxdb3/plugins
user: root
environment:
- TZ=Asia/Shanghai
command: >
influxdb3 serve
--node-id=node0
--object-store=file
--data-dir=/var/lib/influxdb3/data
--plugin-dir=/var/lib/influxdb3/plugins
influxdb3-explorer:
image: influxdata/influxdb3-ui:1.6.3
container_name: influxdb3-explorer
restart: unless-stopped
networks:
- influx-network
ports:
- "8600:80"
- "8888:8888"
volumes:
- ./config:/app-root/config:ro
- ./db:/db:rw
- ./ssl:/etc/nginx/ssl:ro
environment:
- TZ=Asia/Shanghai
command: --mode=admin
networks:
influx-network:
driver: bridge
```
## 4.2 token生成
  进入influxdb3-core容器输入命令获取token
```bash
influxdb3 create token --admin
```
## 4.3 可视化页面
  打开ip:8600具体端口看docker的配置选择`Configure->Servers`,点击`Connect Your First Server`输入InfluxDB服务器信息进行配置。
  `Query Data->Data Explorer`中查看数据。
# 五、使用
## 5.1 SpringBoot使用