influxdbcluster安装部署 [数据库教程]

database

参考资料

Influx Proxy 是一个基于高可用、一致性哈希的 InfluxDB 集群代理服务,实现了 InfluxDB 高可用集群的部署方案,具有动态扩/缩容、故障恢复、数据同步等能力。

相关文档:https://github.com/chengshiwen/influx-proxy

下载地址:https://golang.org/dl/

架构

所需资源:

  • 3台服务器
  • 系统:centos 7.x

软件版本:

  • influxdb-proxy 2.5.5
  • go 1.15.7
  • influxdb 1.8.2

部署

influxdb-node12运行

#下载influxdb软件

wget -c https://dl.influxdata.com/influxdb/releases/influxdb-1.8.2.x86_64.rpm

#安装influxdb

yum install -y influxdb-1.8.2.x86_64.rpm

#创建influxdb所使用的的目录

mkdir -p /data/influxdb/{meta,data,wal}

#配置系统启动命令

# cat influxdb-cluster@.service

[Unit]

Description=influx-cluster

After=network.target

[Service]

Type=simple

ExecStart=/usr/bin/influxd -config /etc/influxdb/influxdb.conf.%i

Restart=on-failure

[Install]

WantedBy=multi-user.target

#将文件influxdb-cluster@.service复制到/etc/systemd/system/

cp influxdb-cluster@.service /etc/systemd/system/

编辑配置文件

  • influxdb-node1操作

# cat influxdb.conf.1

reporting-disabled = true # 禁用报告,默认为 false

bind-address = ":8088"

[meta]

dir = "/data/influxdb/meta" # 元信息目录

[data]

dir = "/data/influxdb/data" # 数据目录

wal-dir = "/data/influxdb/wal" # 预写目录

wal-fsync-delay = "10ms" # SSD 设置为 0s,非 SSD 推荐设置为 0ms-100ms

index-version = "tsi1" # tsi1 磁盘索引,inmem 内存索引需要大量内存

query-log-enabled = true # 查询的日志,默认是 true

[coordinator]

write-timeout = "20s" # 写入请求超时时间,默认为 10s

[http]

enabled = true

bind-address = ":8086"

auth-enabled = true

log-enabled = true # http 请求日志,默认是 true

[logging]

level = "info" # 日志等级,error、warn、info(默认)、debug

# cat influxdb.conf.2

reporting-disabled = true # 禁用报告,默认为 false

bind-address = ":8089"

[meta]

dir = "/data/influxdb/meta" # 元信息目录

[data]

dir = "/data/influxdb/data" # 数据目录

wal-dir = "/data/influxdb/wal" # 预写目录

wal-fsync-delay = "10ms" # SSD 设置为 0s,非 SSD 推荐设置为 0ms-100ms

index-version = "tsi1" # tsi1 磁盘索引,inmem 内存索引需要大量内存

query-log-enabled = true # 查询的日志,默认是 true

[coordinator]

write-timeout = "20s" # 写入请求超时时间,默认为 10s

[http]

enabled = true

bind-address = ":8087"

auth-enabled = true

log-enabled = true # http 请求日志,默认是 true

[logging]

level = "info" # 日志等级,error、warn、info(默认)、debug

  • influxdb-node2节点操作

# cat influxdb.conf.3

reporting-disabled = true # 禁用报告,默认为 false

bind-address = ":8088"

[meta]

dir = "/data/influxdb/meta" # 元信息目录

[data]

dir = "/data/influxdb/data" # 数据目录

wal-dir = "/data/influxdb/wal" # 预写目录

wal-fsync-delay = "10ms" # SSD 设置为 0s,非 SSD 推荐设置为 0ms-100ms

index-version = "tsi1" # tsi1 磁盘索引,inmem 内存索引需要大量内存

query-log-enabled = true # 查询的日志,默认是 true

[coordinator]

write-timeout = "20s" # 写入请求超时时间,默认为 10s

[http]

enabled = true

bind-address = ":8086"

auth-enabled = true

log-enabled = true # http 请求日志,默认是 true

[logging]

level = "info" # 日志等级,error、warn、info(默认)、debug

# cat influxdb.conf.4

reporting-disabled = true # 禁用报告,默认为 false

bind-address = ":8089"

[meta]

dir = "/data/influxdb/meta" # 元信息目录

[data]

dir = "/data/influxdb/data" # 数据目录

wal-dir = "/data/influxdb/wal" # 预写目录

wal-fsync-delay = "10ms" # SSD 设置为 0s,非 SSD 推荐设置为 0ms-100ms

index-version = "tsi1" # tsi1 磁盘索引,inmem 内存索引需要大量内存

query-log-enabled = true # 查询的日志,默认是 true

[coordinator]

write-timeout = "20s" # 写入请求超时时间,默认为 10s

[http]

enabled = true

bind-address = ":8087"

auth-enabled = true

log-enabled = true # http 请求日志,默认是 true

[logging]

level = "info" # 日志等级,error、warn、info(默认)、debug

启动influxdb--node1节点操作

systemctl start influxdb-cluster@1 influxdb-cluster@2

systemctl status influxdb-cluster@1 influxdb-cluster@2

systemctl enable influxdb-cluster@1 influxdb-cluster@2

启动influxdb--node2节点操作

systemctl start influxdb-cluster@3 influxdb-cluster@4

systemctl status influxdb-cluster@3 influxdb-cluster@4

systemctl enable influxdb-cluster@3 influxdb-cluster@4

所有节点创建用户

influx -port 8086

CREATE USER admin with PASSWORD ‘****‘ WITH ALL PRIVILEGES

influx -port 8087

CREATE USER admin with PASSWORD ‘*****‘ WITH ALL PRIVILEGES

以下操作请在influxdb-master1节点上操作

配置go环境

wget -c https://dl.google.com/go/go1.15.7.linux-amd64.tar.gz

tar -C /usr/local -xf go1.15.7.linux-amd64.tar.gz

export PATH=$PATH:/usr/local/go/bin

go version

#vim /etc/profile

export PATH=$PATH:/usr/local/go/bin

export GOPROXY=https://goproxy.io

配置influxdb-proxy服务

  • 配置文件

# cat proxy.json

{

"circles": [

{

"name": "circle-1",

"backends": [

{

"name": "influxdb-1-1",

"url": "http://172.*.*.*:8086",

"username": "admin",

"password": "123456",

"auth_secure": false

},

{

"name": "influxdb-1-2",

"url": "http://172.*.*.*:8087",

"username": "admin",

"password": "123456",

"auth_secure": false

}

]

},

{

"name": "circle-2",

"backends": [

{

"name": "influxdb-2-1",

"url": "http://172.*.*.*:8086",

"username": "admin",

"password": "****",

"auth_secure": false

},

{

"name": "influxdb-2-2",

"url": "http://172.*.*.*:8087",

"username": "admin",

"password": "****",

"auth_secure": false

}

]

}

],

"listen_addr": ":7076",

"db_list": [],

"data_dir": "/data/influx-pr/data",

"tlog_dir": "/data/influx-pr/log",

"hash_key": "idx",

"flush_size": 10000,

"flush_time": 1,

"check_interval": 1,

"rewrite_interval": 10,

"conn_pool_size": 20,

"write_timeout": 10,

"idle_timeout": 10,

"username": "admin",

"password": "*****",

"auth_secure": false,

"write_tracing": false,

"query_tracing": false,

"https_enabled": false,

"https_cert": "",

"https_key": ""

}

  • 下载influx-proxy

wget -c https://github.com/chengshiwen/influx-proxy/releases/download/v2.5.5/influx-proxy-2.5.5.tar.gz

#解压

tar xf influx-proxy-2.5.5.tar.gz

#cp

cp influx-proxy-2.5.5/influx-proxy /usr/local/bin/

  • 系统启动服务

# cat influx-proxy.service

[Unit]

Description=influx-proxy

After=network.target

[Service]

Type=simple

ExecStart=/usr/local/bin/influx-proxy -config /usr/local/influx-proxy/proxy.json

KillSignal=SIGTERM

[Install]

WantedBy=multi-user.target

cp influx-proxy.service /etc/systemd/system/

启动influx-proxy

# 启动集群(三种都可以)

① influx-proxy -config /opt/influx-proxy/proxy.json

② systemctl start influx-proxy

③ nohup influx-proxy -config /opt/influx-proxy/proxy.json > /dev/null 2>&1 &

#配置开机启动

systemctl enable influx-proxy

查看集群状态

curl http://127.0.0.1:7076/health -u admin:***** 

[{"circle":{"id":0,"name":"circle-1","active":true,"write_only":false},"backends":[{"name":"influxdb-1-1","url":"http://172.*.*.*:8086","active":true,"backlog":false,"rewrite":false},{"name":"influxdb-1-2","url":"http://172.*.*.*:8087","active":true,"backlog":false,"rewrite":false}]},{"circle":{"id":1,"name":"circle-2","active":true,"write_only":false},"backends":[{"name":"influxdb-2-1","url":"http://172.*.*.*:8086","active":true,"backlog":false,"rewrite":false},{"name":"influxdb-2-2","url":"http://172.*.*.*:8087","active":true,"backlog":false,"rewrite":false}]}]

influxdb-cluster安装部署

以上是 influxdbcluster安装部署 [数据库教程] 的全部内容, 来源链接: utcz.com/z/535356.html

回到顶部