Influxdb:
定义:
InfluxDB 开源的分布式时序、时间和指标数据库,使用go语言编写,无需外部依赖 ,用于处理海量写入与负载查询。其中几乎所有的数据都可以打上一个Timestamp字段。时间序列数据的更重要的一个属性是如何去查询它,包括数据的过滤,计算等等。
三大特性:
- 时序性(Time Series): 与时间相关的函数的灵活使用(诸如最大、最小、求和等)
- 度量(Metrics):对实时大量数据进行计算
- 事件(Event):支持任意的事件数据,换句话说,任意事件的数据我们都可以做操作
几大特点:
- schemaless(无结构),可以是任意数量的列;
- min, max, sum, count, mean, median 一系列函数,方便统计;
- Native HTTP API, 内置http支持,使用http读写;
- Powerful Query Language 类似sql;
- Built-in Explorer 自带管理工具。
目前流行的TSDB:
下载解压:
influx.exe 命令行客户端
influxd.exe 服务器
influxdb.conf 配置文件
可修改配置:
含义 | 注释 | 配置 |
---|---|---|
元数据存放位置 | #Where the metadata/raft database is stored | dir = “/var/lib/influxdb/meta” |
创建数据库时自动创建默认保留策略。 | #Automatically create a default retention policy when creating a database. | #retention-autocreate = true |
是否为元数据打印日志 | #If log messages are printed for the meta service | #logging-enabled = true |
TSM存储引擎存储TSM文件的目录。 | #The directory where the TSM storage engine stores TSM files. | dir = “/var/lib/influxdb/data” |
TSM存储引擎存储WAL文件的目录。 | #The directory where the TSM storage engine stores WAL files. | wal-dir = “/var/lib/influxdb/wal” |
#query-log-enabled = true | ||
确定是否启用保留策略强制。 | #Determines whether retention policy enforcement enabled. | #enabled = true |
运行保留策略强制检查的时间间隔。 | #The interval of time when retention policy enforcement checks run. | #check-interval = “30m” |
确定是否启用碎片预创建服务。 | #Determines whether shard pre-creation service is enabled. | #enabled = true |
#预创建新碎片的检查运行的时间间隔。 | #The interval of time when the check to pre-create new shards runs. | #check-interval = “10m” |
#在创建其后续组的碎片组的结束时间之前的默认时间段。 | #The default period ahead of the endtime of a shard group that its successor group is created. | #advance-period = “30m” |
是否内部记录统计数据。 | #Whether to record statistics internally. | #store-enabled = true |
用于记录统计信息的目标数据库 | #The destination database for recorded statistics | #store-database = “_internal” |
记录统计数据的间隔 | #The interval at which to record statistics | #store-interval = “10s” |
admin部分 | ||
确定是否启用HTTP终结点 | #Determines whether HTTP endpoint is enabled. | # enabled = true |
HTTP服务使用的绑定地址 | #The bind address used by the HTTP service. | # bind-address = “:8086” |
初次启动:
进入到influxdb目录,执行命令:influx.exe -config influxdb.conf
即可开启influxdb服务,同时按照上面配置文件产生相应的文件。
新建文件夹存放数据:
修改配置为新建文件夹路径:
#Where the metadata/raft database is stored.
dir = "E:\influxDB\influxdb-1.7.3_windows_amd64\influxdb-1.7.3-1\meta"
#The directory where the TSM storage engine stores TSM files.
dir = "E:\influxDB\influxdb-1.7.3_windows_amd64\influxdb-1.7.3-1\data"
#The directory where the TSM storage engine stores WAL files.
wal-dir = "E:\influxDB\influxdb-1.7.3_windows_amd64\influxdb-1.7.3-1\wal"
path环境变量新增一条:
E:\influxDB\influxdb-1.7.3_windows_amd64\influxdb-1.7.3-1
启动与使用:
-
cmd 运行
influxd
命令启动服务器:
-
再打开一个cmd 运行
influx
命令启动客户端:
-
尝试以下命令:
这里要注意单双引号:
删除用户mzf,重新创建 一个有所有权限的用户:
- 再打开一个cmd,使用新创建的用户: