Influxdb系列(二)influx Cli工具操作influxdb

2024-01-26 20:52

本文主要是介绍Influxdb系列(二)influx Cli工具操作influxdb,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、安装并使用 influx CLI

客户端下载地址:https://docs.influxdata.com/influxdb/v2/tools/influx-cli/

[root@192 bin]# tar -xvzf influxdb2-client-2.7.3-linux-amd64.tar.gz
[root@192 bin]# cp influx /usr/local/bin/

image.png

二、客户端方式创建用户

相关的官网地址可直接查看如下地址:
https://docs.influxdata.com/influxdb/v2/install/?t=Set+up+with+the+CLI
https://docs.influxdata.com/influxdb/v2/admin/tokens/create-token/#create-a-token-using-the-influx-cli


[root@localhost influxdb2-2.7.3]# ./influx setup \--username dameng \--password dameng123. \--token dameng123 \--org dameng \--bucket sqllog \--retention 3d \--force
User	Organization	Bucket
dameng	dameng		sqllog## 创建token
[root@localhost influxdb2-2.7.3]# ./influx auth create -o dameng  --all-access
ID			Description	Token												User Name	User ID			Permissions
0c1df02480e81000			7oIcg9OPYU31GS6Tu9oUklBSJx5iEM63iJU0AXXPbqXFfGe-zZ9p6mGLFtctteGVLJcFk9TvMePFQjqvk26rkQ==	dameng		0c1def88b1281000	[read:orgs/6a10c0d35d75074f/authorizations write:orgs/6a10c0d35d75074f/authorizations read:orgs/6a10c0d35d75074f/buckets write:orgs/6a10c0d35d75074f/buckets read:orgs/6a10c0d35d75074f/dashboards write:orgs/6a10c0d35d75074f/dashboards read:/orgs/6a10c0d35d75074f read:orgs/6a10c0d35d75074f/sources write:orgs/6a10c0d35d75074f/sources read:orgs/6a10c0d35d75074f/tasks write:orgs/6a10c0d35d75074f/tasks read:orgs/6a10c0d35d75074f/telegrafs write:orgs/6a10c0d35d75074f/telegrafs read:/users/0c1def88b1281000 write:/users/0c1def88b1281000 read:orgs/6a10c0d35d75074f/variables write:orgs/6a10c0d35d75074f/variables read:orgs/6a10c0d35d75074f/scrapers write:orgs/6a10c0d35d75074f/scrapers read:orgs/6a10c0d35d75074f/secrets write:orgs/6a10c0d35d75074f/secrets read:orgs/6a10c0d35d75074f/labels write:orgs/6a10c0d35d75074f/labels read:orgs/6a10c0d35d75074f/views write:orgs/6a10c0d35d75074f/views read:orgs/6a10c0d35d75074f/documents write:orgs/6a10c0d35d75074f/documents read:orgs/6a10c0d35d75074f/notificationRules write:orgs/6a10c0d35d75074f/notificationRules read:orgs/6a10c0d35d75074f/notificationEndpoints write:orgs/6a10c0d35d75074f/notificationEndpoints read:orgs/6a10c0d35d75074f/checks write:orgs/6a10c0d35d75074f/checks read:orgs/6a10c0d35d75074f/dbrp write:orgs/6a10c0d35d75074f/dbrp read:orgs/6a10c0d35d75074f/notebooks write:orgs/6a10c0d35d75074f/notebooks read:orgs/6a10c0d35d75074f/annotations write:orgs/6a10c0d35d75074f/annotations read:orgs/6a10c0d35d75074f/remotes write:orgs/6a10c0d35d75074f/remotes read:orgs/6a10c0d35d75074f/replications write:orgs/6a10c0d35d75074f/replications]## 创建bucket
https://docs.influxdata.com/influxdb/v2/admin/buckets/create-bucket/?t=influx+CLIinflux bucket create \--name my-bucket \--org my-org \--retention 72h

三、创建配置文件_token认证

https://docs.influxdata.com/influxdb/v2/tools/influx-cli/

[root@192 bin]# ./influx config create --config-name influx.conf --host-url http://localhost:8086 --org dameng  --token PMDQZts55MPX8LVnM7tr9dbA3_3_qwdyWnM0dBiLHzmNyjWOi1hIFJQFXFbssvUc2yJ8fpdQhDut4FUBzvN3qg== --active
Active	Name		URL			Org
*	influx.conf	http://localhost:8086	dameng## 配置文件
[root@192 bin]# ll /root/.influxdbv2/configs 
-rw-------. 1 root root 505 11月  4 20:33 /root/.influxdbv2/configs

image.png

四、InfluxQL语法

(一)DBRP映射

https://docs.influxdata.com/influxdb/v2/query-data/influxql/dbrp/
查询实体与DB的映射

  • InfluxQL 需要数据库和保留策略 (DBRP) 组合才能查询数据。在 InfluxDB 2.7中,数据库和保留策略已合并并被 InfluxDB存储桶取代。要使用 InfluxQL 查询 InfluxDB 2.7,指定的 DBRP 组合必须映射到存储桶。
  • InfluxDB 2.7将在以下操作过程中自动创建 DBRP 映射
[root@192 bin]# influx v1 dbrp list
ID	Database	Bucket ID	Retention Policy	Default	Organization IDVIRTUAL DBRP MAPPINGS (READ-ONLY)
----------------------------------
ID			Database	Bucket ID		Retention Policy	Default	Organization ID
07f41697d8ea4b1b	_monitoring	07f41697d8ea4b1b	autogen			true	ecaa1a71e66f91c3
7f9d57076f240d08	_tasks		7f9d57076f240d08	autogen			true	ecaa1a71e66f91c3
cdbb8518f3289a64	sqllog_20231104	cdbb8518f3289a64	autogen			true	ecaa1a71e66f91c3

(二)查询表数据

https://docs.influxdata.com/influxdb/v2/query-data/influxql/explore-data/

# 进入数据库
[root@192 bin]# influx v1 shell
# 使用数据库
> use "sqllog"
select execSqlStr from SqlEntity LIMIT 1;select execSqlStr from SqlEntity where entityType =3 LIMIT 5;## 计算条数

五、其他的命令

https://docs.influxdata.com/influxdb/v2/reference/cli/influx/auth/list/

influx auth list

这篇关于Influxdb系列(二)influx Cli工具操作influxdb的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/648033

相关文章

基于Python开发Windows屏幕控制工具

《基于Python开发Windows屏幕控制工具》在数字化办公时代,屏幕管理已成为提升工作效率和保护眼睛健康的重要环节,本文将分享一个基于Python和PySide6开发的Windows屏幕控制工具,... 目录概述功能亮点界面展示实现步骤详解1. 环境准备2. 亮度控制模块3. 息屏功能实现4. 息屏时间

SQLite3命令行工具最佳实践指南

《SQLite3命令行工具最佳实践指南》SQLite3是轻量级嵌入式数据库,无需服务器支持,具备ACID事务与跨平台特性,适用于小型项目和学习,sqlite3.exe作为命令行工具,支持SQL执行、数... 目录1. SQLite3简介和特点2. sqlite3.exe使用概述2.1 sqlite3.exe

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1

使用jenv工具管理多个JDK版本的方法步骤

《使用jenv工具管理多个JDK版本的方法步骤》jenv是一个开源的Java环境管理工具,旨在帮助开发者在同一台机器上轻松管理和切换多个Java版本,:本文主要介绍使用jenv工具管理多个JD... 目录一、jenv到底是干啥的?二、jenv的核心功能(一)管理多个Java版本(二)支持插件扩展(三)环境隔

SQL中JOIN操作的条件使用总结与实践

《SQL中JOIN操作的条件使用总结与实践》在SQL查询中,JOIN操作是多表关联的核心工具,本文将从原理,场景和最佳实践三个方面总结JOIN条件的使用规则,希望可以帮助开发者精准控制查询逻辑... 目录一、ON与WHERE的本质区别二、场景化条件使用规则三、最佳实践建议1.优先使用ON条件2.WHERE用

Linux链表操作方式

《Linux链表操作方式》:本文主要介绍Linux链表操作方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、链表基础概念与内核链表优势二、内核链表结构与宏解析三、内核链表的优点四、用户态链表示例五、双向循环链表在内核中的实现优势六、典型应用场景七、调试技巧与

Python使用smtplib库开发一个邮件自动发送工具

《Python使用smtplib库开发一个邮件自动发送工具》在现代软件开发中,自动化邮件发送是一个非常实用的功能,无论是系统通知、营销邮件、还是日常工作报告,Python的smtplib库都能帮助我们... 目录代码实现与知识点解析1. 导入必要的库2. 配置邮件服务器参数3. 创建邮件发送类4. 实现邮件

Java Multimap实现类与操作的具体示例

《JavaMultimap实现类与操作的具体示例》Multimap出现在Google的Guava库中,它为Java提供了更加灵活的集合操作,:本文主要介绍JavaMultimap实现类与操作的... 目录一、Multimap 概述Multimap 主要特点:二、Multimap 实现类1. ListMult

CnPlugin是PL/SQL Developer工具插件使用教程

《CnPlugin是PL/SQLDeveloper工具插件使用教程》:本文主要介绍CnPlugin是PL/SQLDeveloper工具插件使用教程,具有很好的参考价值,希望对大家有所帮助,如有错... 目录PL/SQL Developer工具插件使用安装拷贝文件配置总结PL/SQL Developer工具插

Python中文件读取操作漏洞深度解析与防护指南

《Python中文件读取操作漏洞深度解析与防护指南》在Web应用开发中,文件操作是最基础也最危险的功能之一,这篇文章将全面剖析Python环境中常见的文件读取漏洞类型,成因及防护方案,感兴趣的小伙伴可... 目录引言一、静态资源处理中的路径穿越漏洞1.1 典型漏洞场景1.2 os.path.join()的陷