influxdb-cluster集群部署

一.部署环境

* InfluxDB集群节点数:mate服务至少3个节点,节点数越多,集群性能越高。
* 操作系统:支持的操作系统包括Linux、Windows和MacOS。
* CPU:至少2核4线程,主频越高越好。
* 内存:至少8GB内存,推荐16GB或以上。
* 存储:至少100GB的磁盘空间,推荐使用SSD或NVMe SSD存储

二.集群文件配置修改 

ip地址服务名称
192.168.110.1x0influxdb,meta
192.168.110.1x1influxdb,meta
192.168.110.1x8meta

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

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

hostname = "192.168.110.1x0"

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

hostname = "192.168.110.1x1"

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

hostname = "192.168.110.1x8"

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

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

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

hostname = "192.168.110.1x0"

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

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

hostname = "192.168.110.1x0"
[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.1x1"
[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.1x0:8091 influxd-ctl add-meta 192.168.110.1x1:8091 influxd-ctl add-meta 192.168.110.1x8: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.1x0:8088 influxd-ctl add-data 192.168.10.1x1: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.1x0:8086;
        server 192.168.110.1x1: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.1x0:8181/influx/write?db=test' --data-binary 'mymeasurement,mytag=1 myfield=90'

数据查询

curl -XPOST "http://192.168.10.1x0: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

  • 18
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
好的,下面是一个快速部署 Prometheus 监控 docker 容器、宿主机和 Ceph 集群的 docker-compose.yaml 文件: ```yaml version: '3' services: prometheus: image: prom/prometheus ports: - 9090:9090 volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml command: - '--config.file=/etc/prometheus/prometheus.yml' depends_on: - node-exporter - cadvisor - ceph-exporter node-exporter: image: prom/node-exporter volumes: - /proc:/host/proc:ro - /sys:/host/sys:ro - /:/rootfs:ro command: - '--path.procfs=/host/proc' - '--path.sysfs=/host/sys' - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)' cadvisor: image: google/cadvisor ports: - 8080:8080 volumes: - /:/rootfs:ro - /var/run:/var/run:rw - /sys:/sys:ro - /var/lib/docker/:/var/lib/docker:ro ceph-exporter: image: galexrt/ceph-exporter:latest environment: CLUSTER_NAME: mycluster CEPH_USERNAME: admin CEPH_KEYRING_BASE64: <base64-encoded ceph.client.admin.keyring> ports: - 9128:9128 ``` 其中,Prometheus 监控的配置文件 prometheus.yml 可以参考下面的示例: ```yaml global: scrape_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'docker' metrics_path: '/metrics' static_configs: - targets: ['node-exporter:9100'] labels: group: 'docker' - job_name: 'node' metrics_path: '/metrics' static_configs: - targets: ['node-exporter:9100'] labels: group: 'node' - job_name: 'cadvisor' metrics_path: '/metrics' static_configs: - targets: ['cadvisor:8080'] labels: group: 'docker' - job_name: 'ceph' metrics_path: '/metrics' static_configs: - targets: ['ceph-exporter:9128'] labels: group: 'ceph' ``` 在这个配置文件中,我们定义了四个 job: - prometheus:监控 Prometheus 本身的指标。 - docker:监控 Docker 容器运行时的指标。 - node:监控宿主机的指标。 - ceph:监控 Ceph 集群的指标。 对于 docker 和 node,它们都使用了 node-exporter 来收集指标。而对于 ceph,我们使用了 ceph-exporter 来收集指标。 在部署前,需要将 ceph.client.admin.keyring 文件的内容进行 base64 编码,并将编码后的内容填入 docker-compose.yaml 文件中的 CEHP_KEYRING_BASE64 环境变量中。 部署完成后,可以通过访问 http://localhost:9090 来访问 Prometheus 的 Web 界面。在这里,你可以查看所有收集到的指标,并且可以创建自己的监控规则和仪表盘。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

远方有海,小样不乖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值