首页 > 数据库 >windows环境部署influx2.7 (时序数据库)

windows环境部署influx2.7 (时序数据库)

时间:2025-01-15 11:56:45浏览次数:1  
标签:http windows max influxd storage 时序 vault false influx2.7

官方文档:https://docs.influxdata.com/influxdb/v2/

 

1.下载

需要下载两样东西:influxd.exe和influx.exe

influxd:influx数据库的服务端。下载地址:https://dl.influxdata.com/influxdb/releases/influxdb2-2.7.5-windows.zip
influx:连接influx数据库用的cli工具。下载地址:https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.7.3-windows-amd64.zip
下载后解压,都放到一个文件夹里:

2.启动

2.1 默认配置启动

  在该目录下打开命令窗口,输入influxd.exe即可启动 :

打开网址:http://localhost:8086

 点击GET STARTED,然后输入一些基本信息,点击Continue

 

上面那个token需要记录下来,连接数据库的时候会使用到

2.2 自定义配置启动

可以直接从默认配置直接复制文件到自定义配置文件夹,然后更改配置文件路径

使用influx(cli)连接默认配置的influxd

step1:设置influx的连接,打开Power shell,输入如下命令

.\influx config create --config-name test `
--host-url "http://localhost:8086" `
--org "manager" `
--token "TH5iC0E9q8KeUcBHipEf4yGh83lapZRKst-PjxMHLcEySFa-sIbM9V_edGrSR2tKeMqgAQ9ST1HwTbc95cUznw==" `
--active

step2:导出数据库服务端的运行配置 

.\influx server-config > config.json

 可以看到在目录下生成了一个config.json的文件

 可以看到在目录下生成了一个config.json的文件

step3:编辑配置文件

{
  "assets-path": "",
  "bolt-path": "D:\\Tools\\influxdb2-2.7.5-windows\\influxdbv2\\influxd.bolt",
  "e2e-testing": false,
  "engine-path": "D:\\Tools\\influxdb2-2.7.5-windows\\influxdbv2\\engine",
  "feature-flags": null,
  "flux-log-enabled": false,
  "hardening-enabled": false,
  "http-bind-address": ":8086",
  "http-idle-timeout": 180000000000,
  "http-read-header-timeout": 10000000000,
  "http-read-timeout": 0,
  "http-write-timeout": 0,
  "influxql-max-select-buckets": 0,
  "influxql-max-select-point": 0,
  "influxql-max-select-series": 0,
  "instance-id": "",
  "log-level": "info",
  "metrics-disabled": false,
  "nats-max-payload-bytes": 0,
  "nats-port": 0,
  "no-tasks": false,
  "pprof-disabled": false,
  "query-concurrency": 1024,
  "query-initial-memory-bytes": 0,
  "query-max-memory-bytes": 0,
  "query-memory-bytes": 0,
  "query-queue-size": 1024,
  "reporting-disabled": false,
  "secret-store": "bolt",
  "session-length": 60,
  "session-renew-disabled": false,
  "sqlite-path": "D:\\Tools\\influxdb2-2.7.5-windows\\influxdbv2\\influxd.sqlite",
  "storage-cache-max-memory-size": 1073741824,
  "storage-cache-snapshot-memory-size": 26214400,
  "storage-cache-snapshot-write-cold-duration": "10m0s",
  "storage-compact-full-write-cold-duration": "4h0m0s",
  "storage-compact-throughput-burst": 50331648,
  "storage-max-concurrent-compactions": 0,
  "storage-max-index-log-file-size": 1048576,
  "storage-no-validate-field-size": false,
  "storage-retention-check-interval": "30m0s",
  "storage-series-file-max-concurrent-snapshot-compactions": 0,
  "storage-series-id-set-cache-size": 0,
  "storage-shard-precreator-advance-period": "30m0s",
  "storage-shard-precreator-check-interval": "10m0s",
  "storage-tsm-use-madv-willneed": false,
  "storage-validate-keys": false,
  "storage-wal-fsync-delay": "0s",
  "storage-wal-max-concurrent-writes": 0,
  "storage-wal-max-write-delay": 600000000000,
  "storage-write-timeout": 10000000000,
  "store": "disk",
  "testing-always-allow-setup": false,
  "tls-cert": "",
  "tls-key": "",
  "tls-min-version": "1.2",
  "tls-strict-ciphers": false,
  "tracing-type": "",
  "ui-disabled": false,
  "vault-addr": "",
  "vault-cacert": "",
  "vault-capath": "",
  "vault-client-cert": "",
  "vault-client-key": "",
  "vault-client-timeout": 0,
  "vault-max-retries": 0,
  "vault-skip-verify": false,
  "vault-tls-server-name": "",
  "vault-token": ""
}

配置说明

# 绑定IP端口
http-bind-address: ip:port
#存储engine
engine-path: /data/soft/influxdb2.7.4/data
# 用户数据和元数据存储地址(元数据不单独配置则使用此项)
bolt-path: /data/soft/influxdb2.7.4/influx.bolt
#证书地址
vault-capath: /data/soft/influxdb2.7.4/certs
#http相关配置
http-idle-timeout: 3m0s
http-read-header-timeout: 90s
http-read-timeout: 90s
http-write-timeout: 180s
#最大桶数
influxql-max-select-buckets: 0
#最大数据数量
influxql-max-select-point: 0
#最大字段数
influxql-max-select-series: 0
#日志相关
log-level: info
# 无需评测数据
pprof-disabled: true
#查询并发数
query-concurrency: 512
# 查询最大内存数 5G
query-max-memory-bytes: 5368709120
# 查询队列
query-queue-size: 1024
#会话超时 min
session-length: 60
#多大内存写一次,内存大则可开大些
storage-cache-snapshot-memory-size: 26214400
#写文件的最大线程数 高写操作,建议限制为机器的总核数
storage-max-concurrent-compactions: 4
#过期检查频率
storage-retention-check-interval: 1d0h0m0s
#写并发数
storage-wal-max-concurrent-writes: 0

 

step4:重新启动influxd.exe

出现这个错误表示编码格式不正确,通过vs进行UTF-8 编码格式保存

3.注册服务

step1:新增环境变量

 

step2:创建服务

 

@echo.服务启动......  
@echo off  
@sc create influxd  binpath="D:\Tools\influxdb2-2.7.5-windows\influxd.exe" 
@net start  influxd 
@sc config influxd start= AUTO  
@echo.influxd start is OK......success
@pause

 

4.数据库操作

4.1 查询数据

4.2 编程代码

using InfluxDB.Client;
using InfluxDB.Client.Api.Domain;
using InfluxDB.Client.Writes;
using System.Diagnostics;


Console.WriteLine("Hello, World!");
var familyNames = new List<string>{
   "赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈",
   "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许",
   "何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏",
   "陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章",
   "云", "苏", "潘", "葛", "奚", "范", "彭", "郎", "鲁", "韦",
   "昌", "马", "苗", "凤", "花", "方", "俞", "任", "袁", "柳",
   "酆", "鲍", "史", "唐", "费", "廉", "岑", "薛", "雷", "贺",
   "倪", "汤", "滕", "殷", "罗", "毕", "郝", "邬", "安", "常",
   "乐", "于", "时", "傅", "皮", "卞", "齐", "康", "伍", "余",
   "元", "卜", "顾", "孟", "平", "黄", "和", "穆", "萧", "尹"
};
var givenNames = new List<string>{
  "子璇", "淼", "国栋", "夫子", "瑞堂", "甜", "敏", "尚", "国贤", "贺祥", "晨涛",
  "昊轩", "易轩", "益辰", "益帆", "益冉", "瑾春", "瑾昆", "春齐", "杨", "文昊",
  "东东", "雄霖", "浩晨", "熙涵", "溶溶", "冰枫", "欣欣", "宜豪", "欣慧", "建政",
  "美欣", "淑慧", "文轩", "文杰", "欣源", "忠林", "榕润", "欣汝", "慧嘉", "新建",
  "建林", "亦菲", "林", "冰洁", "佳欣", "涵涵", "禹辰", "淳美", "泽惠", "伟洋",
  "涵越", "润丽", "翔", "淑华", "晶莹", "凌晶", "苒溪", "雨涵", "嘉怡", "佳毅",
  "子辰", "佳琪", "紫轩", "瑞辰", "昕蕊", "萌", "明远", "欣宜", "泽远", "欣怡",
  "佳怡", "佳惠", "晨茜", "晨璐", "运昊", "汝鑫", "淑君", "晶滢", "润莎", "榕汕",
  "佳钰", "佳玉", "晓庆", "一鸣", "语晨", "添池", "添昊", "雨泽", "雅晗", "雅涵",
  "清妍", "诗悦", "嘉乐", "晨涵", "天赫", "傲", "佳昊", "天昊", "萌萌", "若萌"
};
const string token = "MSGEFXnKGhrb6EPxDmlCoeGMeU1yKTI0S66tokl3Z9AcC9vM6RLJV8H5DCfP-7NoXh8A14ntOIuCalO8QKANBA==";  // influxdb生成的token
const string url = "http://localhost:8086";
const string org = "manager";//用户组
const string bucket = "test";//数据实例
const string measurement = "mem";//表
var stopwatch = Stopwatch.StartNew();
using var client = new InfluxDBClient("http://localhost:8086", token);
//const string data = "mem,host=host1 used_percent=23.43234543";
//using (var writeApi = client.GetWriteApi())
//{
//    writeApi.WriteRecord(data,WritePrecision.Ns, bucket,org);
//}
//1.增加
using (var writeApi = client.GetWriteApi())
{
    for (int i = 0; i <= 1000; i++)
    {
        var point = PointData.Measurement(measurement)
            .Tag("host", "local")
            .Field("Name", $"{familyNames[new Random().Next(0, familyNames.Count - 1)]}{givenNames[new Random().Next(0, givenNames.Count - 1)]}")
            .Field("Age", new Random().Next(0, 100))
            .Timestamp(DateTime.UtcNow, WritePrecision.Ns);
        writeApi.WritePoint(point, bucket, org);
        Thread.Sleep(10);
    }
}


//2.删除数据
//var delete = client.GetDeleteApi();
//await delete.Delete(DateTime.UtcNow.AddHours(-12), DateTime.UtcNow, "", bucket, org);


//3.查询数据
Console.WriteLine("*** Query Points ***");
const string start = "-3600s";
const string stop = "-1h";
var query = @$"
from(bucket: ""{bucket}"") 
|> range(start:{start})
|> filter(fn: (r) => r[""_measurement""] == ""{measurement}"")
|> filter(fn: (r) => r[""_field""] == ""Name"" or r[""_field""] == ""Age"" )
|> pivot(rowKey: [""_time""], columnKey: [""_field""], valueColumn: ""_value"")";
var tables = await client.GetQueryApi().QueryAsync(query, "manager");
tables.ForEach(table =>
{
    for (int j = 0; j < table.Records.Count; j++)
    {
        var record = table.Records[j];
        Console.WriteLine($"序号{j}:{record.GetTime()} {record.GetMeasurement()}: {record.Values["Name"]} {record.Values["Age"]}");
    }
});

stopwatch.Stop();

// 输出方法运行时间
Console.WriteLine("方法运行时间:{0}", stopwatch.Elapsed);

//Console.WriteLine("Hello, World 2 !");

//Console.ReadLine();
View Code

标签:http,windows,max,influxd,storage,时序,vault,false,influx2.7
From: https://www.cnblogs.com/xm123/p/18663411

相关文章

  • 软件运维 --- jar如何在windows作为服务开机自启运行
    步骤1:准备工作下载并安装Java:OracleJDK或OpenJDK。确保你已经构建好若依的JAR文件(如ruoyi-admin.jar)。访问NSSM官网下载最新版本。 步骤2:安装若依JAR文件为Windows服务以管理员身份运行CMD。进入NSSM的解压目录nssminstall自定义一个服务名称,这会打开......
  • GIMP 3.0.0 (Linux, macOS, Windows) - 免费开源图像编辑器
    GIMP3.0.0(Linux,macOS,Windows)-免费开源图像编辑器GNUImageManipulationProgram(GIMP)请访问原文链接:https://sysin.org/blog/gimp/查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgGIMPGNUIMAGEMANIPULATIONPROGRAM免费且开源的图像编辑器GIMP......
  • digiKam 8.5 (Linux, macOS, Windows) - 开源照片管理软件
    digiKam8.5(Linux,macOS,Windows)-开源照片管理软件ProfessionalPhotoManagementwiththePowerofOpenSource请访问原文链接:https://sysin.org/blog/digikam/查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgdigiKam开源驱动的专业照片管理什么是dig......
  • 你平时开发是用mac还是windows系统?至少举三个例子说明两者的区别?
    在前端开发中,我通常会选择使用Mac系统进行开发,但我也了解Windows系统,并且能够根据需要使用它。以下是Mac和Windows系统在前端开发方面的三个主要区别:用户界面与体验:Mac:Mac系统以其优雅的用户界面和流畅的操作体验著称。对于追求设计感和美感的开发者来说,Mac提供了一个更加整......
  • Windows 行为测试 删除 FileStream 正在读写文件可以继续读写
    测试结论:使用FileShare带Delete的共享方式打开的FileStream正在对文件进行读写过程中,可以对正在读写的文件进行删除。文件删除之后,不影响已经打开的FileStream的读写。且此时使用File.Exists方法判断文件是否存在,返回的是不存在如果删除之后,再次在外部新建同名文件,则......
  • windows server2016搭建AD域服务器
    @目录一、背景二、搭建AD域服务器步骤三、生成可供java程序使用的keystore文件四、导出某用户的keytab文件五、主机配置hosts文件六、主机确认是否能ping通本人其他相关文章链接一、背景亲测可用,之前搜索了很多博客,啥样的都有,就是不介绍报错以及配置用处,根本不懂照抄那些配置......
  • 玩机党的福音,Windows超级管理器!
    前言:        今天,我要向大家隆重推荐一款堪称“神器”的软件——Windows超级管理器。这是一款完全免费且功能强大的系统管理软件,其出色的表现甚至超越了广为人知的鲁大师。Windows超级管理器        这款软件的体积十分小巧,仅有5兆大小,下载后无需安装,打开即......
  • 数电-时序电路分析与设计
    目录一、时序电路分析二、时序电路设计一、时序电路分析答题步骤:时钟方程激励方程状态方程有输出,列输出方程状态真值表状态图波形图写逻辑功能 自启动:指电路的所有状态都能直接或间接地进入有效状态。二、时序电路设计......
  • Windows下Git Bash的tar命令使用
    Administrator@WIN-5B2ST4S1K5HMINGW64~/Documents/spark$lsspark-3.5.4-bin-hadoop3.tgzspark-3.5.4-bin-without-hadoop.tgzAdministrator@WIN-5B2ST4S1K5HMINGW64~/Documents/spark$tar-xspark-3.5.4-bin-hadoop3.tgz./tar:Refusingtoreadarchivecon......
  • 一段读取Windows激活信息的vbscript
    直接上代码:OptionExplicitDimobjshell,Path,DigitalID,ResultSetobjshell=CreateObject("WScript.Shell")'SetregistrykeypathPath="HKLM\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\"'RegistrykeyvalueDigitalID......