01.InfluxDB系统化学习-配置文件

本文详细介绍了InfluxDB的配置文件,包括元数据存储、用户备份与修复服务的地址设置,以及数据存储的路径、WAL刷新策略等。文章还讨论了如何调整配置以优化性能,如报告使用数据的开关、数据安全性、查询日志记录等。此外,涉及了数据引擎的参数,如缓存最大内存大小、快照写入策略、TSM文件的压缩与并发控制等。
摘要由CSDN通过智能技术生成

### Welcome to the InfluxDB configuration file.

# influxdb默认的配置项,如果需要修改则去掉#号,修改后重启即可生效

# The values in this file override the default values used by the system if

# a config option is not specified. The commented out lines are the configuration

# field and the default value used. Uncommenting a line and changing the value

# will change the value used at runtime when the process is restarted.

# Once every 24 hours InfluxDB will report usage data to usage.influxdata.com

# The data includes a random ID, os, arch, version, the number of series and other

# usage data. No data from user databases is ever transmitted.

# Change this option to true to disable reporting.

# reporting-disabled = false

# 设置用户备份与修复(数据)的RPC服务地址

# Bind address to use for the RPC service for backup and restore.

# bind-address = "127.0.0.1:8088"

###

### [meta]

### 存储有关InfluxDB集群元数据的 Raft consensus group 的控制参数将在下面被配置。

### Controls the parameters for the Raft consensus group that stores metadata

### about the InfluxDB cluster.

###

[meta]

# Where the metadata/raft database is stored

# 元数据/raft 数据库被存储的路径 即meta目录

dir = "/var/lib/influxdb/meta"

# Automatically create a default retention policy when creating a database.

# 当创建一个新的数据库时自动为其创建一个默认的rentention policy(保留策略)

# retention-autocreate = true

# If log messages are printed for the meta service

# 是否为meta服务打印日志

# logging-enabled = true

###

### [data]

### 修改InfluxDB的分片数据的具体存放路径,以及这部分数据从WAL(Write Ahead Log)刷新的(策略)

### 根据系统实际情况配置dir路径

### Controls where the actual shard data for InfluxDB lives and how it is

### flushed from the WAL. "dir" may need to be changed to a suitable place

### for your system, but the WAL settings are an advanced configuration. The

### defaults should work for most systems.

###

[data]

# The directory where the TSM storage engine stores TSM files.

# TSM存储引擎存储TSM文件的目录

dir = "/var/lib/influxdb/data"

# The directory where the TSM storage engine stores WAL files.

# TSM存储引擎存储WAL文件的目录

wal-dir = "/var/lib/influxdb/wal"

# The amount of time that a write will wait before fsyncing. A duration

# greater than 0 can be used to batch up multiple fsync calls. This is useful for slower

# disks or when WAL write contention is seen. A value of 0s fsyncs every write to the WAL.

# Values in the range of 0-100ms are recommended for non-SSD disks.

# 这个时间参数是在fsyncing之前一个写入操作将等待的时间。

# fsync解释为:帧同步脉冲 操作 被同步 把文件在内存中的部分写回磁盘

# 大于0的参数可以用来整理多重fsync操作。当系统磁盘读写速度较慢或出现WAL写入延缓时,可以考虑配置该参数

# 对于非固态硬盘,这个参数推荐的配置范围是0~100毫秒

# wal-fsync-delay = "0s"

 

# The type of shard index to use for new shards. The default is an in-memory index that is

# recreated at startup. A value of "tsi1" will use a disk based index that supports higher

# cardinality datasets.

# 对于influxdb新产生的分片索引的类型将在这里被设置。初始默认的索引类型是一种 in-memory 索引,如果你修改成

# tsi1 将会对于高基数数据支持的更好。

#(high-cardinality 是描述tag rentention-policy measurement组合成series规模的度量值)

# 修改该参数可以解决内存不足使用磁盘替换

# index-version = "inmem"

# Trace logging provides more verbose output around the tsm engine. Turning

# this on can provide more useful output for debugging tsm engine issues.

# 打印追踪日志,也就是打印debug日志。如果打开的话会创建大量冗长的、有关tsm存储引擎工作细节的日志。

# trace-logging-enabled = false

# Whether queries should be logged before execution. Very useful for troubleshooting, but will

# log any sensitive data contained within a query.

# 这个配置决定在执行query查询动作前是否记录为日志。对于解决问题很有帮助

# 但是会把所有含有query的敏感数据都记录下来

# query-log-enabled = true

# Validates incoming writes to ensure keys only have valid unicode characters.

# This setting will incur a small overhead because every key must be checked.

# validate-keys = false

# Settings for the TSM engine(有关TSM存储引擎的设置)

# CacheMaxMemorySize is the maximum size a shard's cache can

# reach before it starts rejecting writes.

# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).

# Values without a size suffix are in bytes.

# 一个分片在拒接写入之前的最大容量(换言之就是一个分片的最大容量)

# 这里的体积单位可以是 k m 或者g 并且不区分大小写,如果不写单位就表示byte

# cache-max-memory-size = "1g"

# CacheSnapshotMemorySize is the size at which the engine will

# snapshot the cache and write it to a TSM file, freeing up memory

# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).

# Values without a size suffix are in bytes.

# 引擎向TSM文件写入时,快照缓存数据的大小,单位参考cache-max-memory-size

# cache-snapshot-memory-size = "25m"

# CacheSnapshotWriteColdDuration is the length of time at

# which the engine will snapshot the cache and write it to

# a new TSM file if the shard hasn't received writes or deletes

# 如果分片(shard)没有接收到写入或删除(请求),引擎向TSM文件写入时候产生的快照缓存文件的时间

# cache-snapshot-write-cold-duration = "10m"

# CompactFullWriteColdDuration is the duration at which the engine

# will compact all TSM files in a shard if it hasn't received a

# write or delete

# 若分片没有收到写入或者删除(请求),则在这个参数表示的时间间隔后压缩这个分片中的所有TSM文件

# compact-full-write-cold-duration = "4h"

# The maximum number of concurrent full and level compactions that can run at one time. A

Spring Boot 集成 InfluxDB 客户端(influxdb-client-java)主要是为了将时序数据存储到 InfluxDB 这种时间序列数据库中。InfluxDB 是一个开源的分布式时序数据库,特别适合用于存储和分析时间序列数据,比如监控系统、物联网、DevOps 等场景。 要集成 InfluxDB 客户端到 Spring Boot 应用程序,首先需要添加 influxdb-client-java 的依赖到项目中。在 Maven 的 `pom.xml` 文件中添加以下依赖: ```xml <dependency> <groupId>org.influxdb</groupId> <artifactId>influxdb-java</artifactId> <version>2.15</version> <!-- 请使用最新的版本号 --> </dependency> ``` 接下来,在 Spring Boot 应用中进行配置。可以通过配置文件(如 `application.properties` 或 `application.yml`)来配置 InfluxDB 的连接信息,例如: ```properties # application.properties influx.url=http://localhost:8086 influx.token=my-token influx.bucket=my-bucket influx.organization=my-org ``` 然后,创建一个配置类来初始化 InfluxDB 客户端,并将其注册为一个 Spring Bean,以便在应用程序中注入使用: ```java @Configuration public class InfluxDBConfig { @Value("${influx.url}") private String influxUrl; @Value("${influx.token}") private String token; @Value("${influx.bucket}") private String bucket; @Value("${influx.organization}") private String organization; @Bean public InfluxDBClient influxDBClient() { return InfluxDBClientFactory.create(influxUrl, token.toCharArray(), bucket, organization); } } ``` 现在,你可以在任何需要的地方注入 `InfluxDBClient` 并开始与 InfluxDB 进行交互了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值