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正则表达式匹配和替换的操作指南

《Python正则表达式匹配和替换的操作指南》正则表达式是处理文本的强大工具,Python通过re模块提供了完整的正则表达式功能,本文将通过代码示例详细介绍Python中的正则匹配和替换操作,需要的朋... 目录基础语法导入re模块基本元字符常用匹配方法1. re.match() - 从字符串开头匹配2.

Java实现在Word文档中添加文本水印和图片水印的操作指南

《Java实现在Word文档中添加文本水印和图片水印的操作指南》在当今数字时代,文档的自动化处理与安全防护变得尤为重要,无论是为了保护版权、推广品牌,还是为了在文档中加入特定的标识,为Word文档添加... 目录引言Spire.Doc for Java:高效Word文档处理的利器代码实战:使用Java为Wo

sysmain服务可以禁用吗? 电脑sysmain服务关闭后的影响与操作指南

《sysmain服务可以禁用吗?电脑sysmain服务关闭后的影响与操作指南》在Windows系统中,SysMain服务(原名Superfetch)作为一个旨在提升系统性能的关键组件,一直备受用户关... 在使用 Windows 系统时,有时候真有点像在「开盲盒」。全新安装系统后的「默认设置」,往往并不尽编

Python自动化处理PDF文档的操作完整指南

《Python自动化处理PDF文档的操作完整指南》在办公自动化中,PDF文档处理是一项常见需求,本文将介绍如何使用Python实现PDF文档的自动化处理,感兴趣的小伙伴可以跟随小编一起学习一下... 目录使用pymupdf读写PDF文件基本概念安装pymupdf提取文本内容提取图像添加水印使用pdfplum

Python从Word文档中提取图片并生成PPT的操作代码

《Python从Word文档中提取图片并生成PPT的操作代码》在日常办公场景中,我们经常需要从Word文档中提取图片,并将这些图片整理到PowerPoint幻灯片中,手动完成这一任务既耗时又容易出错,... 目录引言背景与需求解决方案概述代码解析代码核心逻辑说明总结引言在日常办公场景中,我们经常需要从 W

Python实战之SEO优化自动化工具开发指南

《Python实战之SEO优化自动化工具开发指南》在数字化营销时代,搜索引擎优化(SEO)已成为网站获取流量的重要手段,本文将带您使用Python开发一套完整的SEO自动化工具,需要的可以了解下... 目录前言项目概述技术栈选择核心模块实现1. 关键词研究模块2. 网站技术seo检测模块3. 内容优化分析模

使用Python的requests库来发送HTTP请求的操作指南

《使用Python的requests库来发送HTTP请求的操作指南》使用Python的requests库发送HTTP请求是非常简单和直观的,requests库提供了丰富的API,可以发送各种类型的HT... 目录前言1. 安装 requests 库2. 发送 GET 请求3. 发送 POST 请求4. 发送

使用SpringBoot+InfluxDB实现高效数据存储与查询

《使用SpringBoot+InfluxDB实现高效数据存储与查询》InfluxDB是一个开源的时间序列数据库,特别适合处理带有时间戳的监控数据、指标数据等,下面详细介绍如何在SpringBoot项目... 目录1、项目介绍2、 InfluxDB 介绍3、Spring Boot 配置 InfluxDB4、I

Python使用python-pptx自动化操作和生成PPT

《Python使用python-pptx自动化操作和生成PPT》这篇文章主要为大家详细介绍了如何使用python-pptx库实现PPT自动化,并提供实用的代码示例和应用场景,感兴趣的小伙伴可以跟随小编... 目录使用python-pptx操作PPT文档安装python-pptx基础概念创建新的PPT文档查看

MySQL 数据库表操作完全指南:创建、读取、更新与删除实战

《MySQL数据库表操作完全指南:创建、读取、更新与删除实战》本文系统讲解MySQL表的增删查改(CURD)操作,涵盖创建、更新、查询、删除及插入查询结果,也是贯穿各类项目开发全流程的基础数据交互原... 目录mysql系列前言一、Create(创建)并插入数据1.1 单行数据 + 全列插入1.2 多行数据