influxdb-cluster集群部署

一.部署环境

* InfluxDB集群节点数:mate服务至少3个节点,节点数越多,集群性能越高。

* 操作系统:支持的操作系统包括Linux、Windows和MacOS。

* CPU:至少2核4线程,主频越高越好。

* 内存:至少8GB内存,推荐16GB或以上。

* 存储:至少100GB的磁盘空间,推荐使用SSD或NVMe SSD存储

二.集群文件配置修改

|-----------------|---------------|
| ip地址 | 服务名称 |
| 192.168.110.110 | influxdb,meta |
| 192.168.110.111 | influxdb,meta |
| 192.168.110.118 | meta |

1.influxdb-meta.conf配置文件修改

meta至少三个节点修改配置比较简单

hostname = "192.168.110.110"

dir = "/data/var/lib/influxdb/meta"

hostname = "192.168.110.111"

dir = "/data/var/lib/influxdb/meta"

hostname = "192.168.110.118"

dir = "/data/var/lib/influxdb/meta"

2.influxdb.conf配置修改:红色为修改参数

influxdb-mate.conf每台只需要修改下面参数

hostname = "192.168.110.110"

meta\]. dir = "/data/var/lib/influxdb/meta"

第一个influx的配置influxdb.conf修改

hostname = "192.168.110.110"

meta

Directory where the cluster metadata is stored.

dir = "/data/var/lib/influxdb/meta"

data

dir = "/data/var/lib/influxdb/data"

wal-dir = "/data/var/lib/influxdb/wal"

wal-fsync-delay = "1ms"

index-version = "tsi1"

cache-max-memory-size = "48g"

cache-snapshot-memory-size = "4096m"

max-concurrent-compactions = 12

series-id-set-cache-size = 100

coordinator

max-select-point = 1000000

max-select-series = 1000000

hinted-handoff

The directory where the hinted handoff queues are stored.

dir = "/data/var/lib/influxdb/hh"

第二个influx的配置influxdb.conf修改

hostname = "192.168.110.111"

meta

Directory where the cluster metadata is stored.

dir = "/data/var/lib/influxdb/meta"

data

dir = "/data/var/lib/influxdb/data"

wal-dir = "/data/var/lib/influxdb/wal"

wal-fsync-delay = "1ms"

index-version = "tsi1"

cache-max-memory-size = "48g"

cache-snapshot-memory-size = "4096m"

max-concurrent-compactions = 12

series-id-set-cache-size = 100

coordinator

max-select-point = 1000000

max-select-series = 1000000

hinted-handoff

The directory where the hinted handoff queues are stored.

dir = "/data/var/lib/influxdb/hh"

三.集群构建启动

1.meta元数据集群的构建

启动meta集群(所有的mate节点上执行)

nohup influxd-meta -config /data/influxdb/etc/influxdb/influxdb-meta.conf > nohup.out 2>&1 &

在其中一个节点上执行

influxd-ctl add-meta 192.168.110.110:8091 influxd-ctl add-meta 192.168.110.111:8091 influxd-ctl add-meta 192.168.110.88:8091

2.influxdb集群服务

启动data服务(所有influx的数据节点上执行)

nohup influxd -config /data/influxdb/etc/influxdb/influxdb.conf > nohup.out 2>&1 &

将data节点加入集群(其中一个data节点上)

influxd-ctl add-data 192.168.10.110:8088 influxd-ctl add-data 192.168.10.111:8088

四.配置负载均衡

nginx配置参数如下

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main 'remote_addr - remote_user [time_local\] "request" '

'status body_bytes_sent "$http_referer" '

'"http_user_agent" "http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

upstream influxdb {

server 192.168.110.110:8086;

server 192.168.110.111:8086;

}

server {

listen 8181;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

proxy_set_header Host $proxy_host;

proxy_pass http://influxdb/;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

}

负载均衡测试

数据测试写入

curl -i -XPOST 'http://192.168.110.110:8181/influx/write?db=test' --data-binary 'mymeasurement,mytag=1 myfield=90'

数据查询

curl -XPOST "http://192.168.10.110:8181/influx/query?db=test" --data-urlencode "q=Select * from mymeasurement" --header "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNjc5NjQyNTEyfQ.7mIPMjB60kFGFQuTSyf7KvYF921MkMmL662_icTfvRQ"

五.命令手册

influxd-meta config 显示所有meta的配置

influxd config 显示所有influxdata的配置

influx-ctl show 显示集群节点

create database iot_env_data

创建用户设置密码

create user iot_admin with password 'xxx1' with all privileges

相关推荐
科技小E2 分钟前
视频设备轨迹回放平台EasyCVR打造水库大坝智慧安防视频监控智能分析方案
大数据·网络·人工智能·音视频·安防监控
zxsz_com_cn33 分钟前
医疗设备预测性维护的合规性挑战与标准化路径研究
大数据·数据库·人工智能
PcVue China2 小时前
PcVue助力立讯:精密制造的智能化管控实践!
大数据·人工智能·制造
Data-Miner2 小时前
158页PPT | 某大型研发制造集团信息化IT规划整体方案
大数据·制造
阿里云大数据AI技术2 小时前
阿里云 Elasticsearch Serverless 检索增强型 8.17 版来袭!
大数据·elasticsearch·serverless
反向跟单策略2 小时前
期货跟单软件云端部署的重要性
大数据·数据分析·区块链
卓豪终端管理2 小时前
如何安全地管理固定功能设备?
java·大数据·开发语言·网络·人工智能·安全
chat2tomorrow3 小时前
如何构建类似云数据仓库 Snowflake 的本地数据仓库?
大数据·数据仓库·低代码·数据治理·snowflake·sql2api
孟意昶4 小时前
大数据面试问答-HBase/ClickHouse
大数据·面试·hbase
atbigapp.com4 小时前
DeepSeek在数据仓库的10大应用场景
大数据·数据库·人工智能