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的smtplib和email库构建一个支持图文混排,多附件,多... 目录前言一、基础配置:搭建邮件发送框架1.1 邮箱服务准备1.2 核心库导入1.3 基础发送函数二、

基于Python实现一个图片拆分工具

《基于Python实现一个图片拆分工具》这篇文章主要为大家详细介绍了如何基于Python实现一个图片拆分工具,可以根据需要的行数和列数进行拆分,感兴趣的小伙伴可以跟随小编一起学习一下... 简单介绍先自己选择输入的图片,默认是输出到项目文件夹中,可以自己选择其他的文件夹,选择需要拆分的行数和列数,可以通过

Java操作Word文档的全面指南

《Java操作Word文档的全面指南》在Java开发中,操作Word文档是常见的业务需求,广泛应用于合同生成、报表输出、通知发布、法律文书生成、病历模板填写等场景,本文将全面介绍Java操作Word文... 目录简介段落页头与页脚页码表格图片批注文本框目录图表简介Word编程最重要的类是org.apach

Python使用pip工具实现包自动更新的多种方法

《Python使用pip工具实现包自动更新的多种方法》本文深入探讨了使用Python的pip工具实现包自动更新的各种方法和技术,我们将从基础概念开始,逐步介绍手动更新方法、自动化脚本编写、结合CI/C... 目录1. 背景介绍1.1 目的和范围1.2 预期读者1.3 文档结构概述1.4 术语表1.4.1 核

Python使用OpenCV实现获取视频时长的小工具

《Python使用OpenCV实现获取视频时长的小工具》在处理视频数据时,获取视频的时长是一项常见且基础的需求,本文将详细介绍如何使用Python和OpenCV获取视频时长,并对每一行代码进行深入解析... 目录一、代码实现二、代码解析1. 导入 OpenCV 库2. 定义获取视频时长的函数3. 打开视频文

Linux中压缩、网络传输与系统监控工具的使用完整指南

《Linux中压缩、网络传输与系统监控工具的使用完整指南》在Linux系统管理中,压缩与传输工具是数据备份和远程协作的桥梁,而系统监控工具则是保障服务器稳定运行的眼睛,下面小编就来和大家详细介绍一下它... 目录引言一、压缩与解压:数据存储与传输的优化核心1. zip/unzip:通用压缩格式的便捷操作2.

Python实现对阿里云OSS对象存储的操作详解

《Python实现对阿里云OSS对象存储的操作详解》这篇文章主要为大家详细介绍了Python实现对阿里云OSS对象存储的操作相关知识,包括连接,上传,下载,列举等功能,感兴趣的小伙伴可以了解下... 目录一、直接使用代码二、详细使用1. 环境准备2. 初始化配置3. bucket配置创建4. 文件上传到os

mysql表操作与查询功能详解

《mysql表操作与查询功能详解》本文系统讲解MySQL表操作与查询,涵盖创建、修改、复制表语法,基本查询结构及WHERE、GROUPBY等子句,本文结合实例代码给大家介绍的非常详细,感兴趣的朋友跟随... 目录01.表的操作1.1表操作概览1.2创建表1.3修改表1.4复制表02.基本查询操作2.1 SE

sqlite3 命令行工具使用指南

《sqlite3命令行工具使用指南》本文系统介绍sqlite3CLI的启动、数据库操作、元数据查询、数据导入导出及输出格式化命令,涵盖文件管理、备份恢复、性能统计等实用功能,并说明命令分类、SQL语... 目录一、启动与退出二、数据库与文件操作三、元数据查询四、数据操作与导入导出五、查询输出格式化六、实用功

c++中的set容器介绍及操作大全

《c++中的set容器介绍及操作大全》:本文主要介绍c++中的set容器介绍及操作大全,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录​​一、核心特性​​️ ​​二、基本操作​​​​1. 初始化与赋值​​​​2. 增删查操作​​​​3. 遍历方