[TOC]

Docker 快速部署 InfluxDB 时序数据库

镜像参考: https://hub.docker.com/_/influxdb

1.部署 InfluxDB 1.x

安装部署

  • 步骤 01.准备InfluxDB 1.x配置文件 influxdb.conf , 温馨提示你可以执行如下命令以获取influxdb 1.x 默认配置文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 文件目录创建
mkdir -vp /storage/database/influxdb/{config,data}
# 缺省配置文件
$ docker run --rm influxdb:1.8.10 influxd config > influxdb.conf
# 自定义配置文件
$ tee /storage/database/influxdb/config/influxdb.conf <<'EOF'
[meta]
dir = "/var/lib/influxdb/meta"
retention-autocreate = true
logging-enabled = true

[data]
dir = "/var/lib/influxdb/data"
index-version = "inmem"
wal-dir = "/var/lib/influxdb/wal"
wal-fsync-delay = "0s"

[coordinator]
write-timeout = "10s"
max-concurrent-queries = 0
query-timeout = "0s"
log-queries-after = "0s"
max-select-point = 0
max-select-series = 0
max-select-buckets = 0

[retention]
enabled = true
check-interval = "30m0s"

[monitor]
store-enabled = true
store-database = "_internal"
store-interval = "10s"

[subscriber]
enabled = true
http-timeout = "30s"
insecure-skip-verify = false
ca-certs = ""
write-concurrency = 40
write-buffer-size = 1000

[shard-precreation]
enabled = true
check-interval = "10m0s"
advance-period = "30m0s"

[http]
enabled = true
bind-address = ":8086"

[logging]
format = "auto"
level = "info"
suppress-logo = false

[[graphite]]
enabled = true
bind-address = ":2003"
database = "jmeter"
retention-policy = ""
protocol = "tcp"
batch-size = 5000
batch-pending = 10
batch-timeout = "1s"
consistency-level = "one"
separator = "."
udp-read-buffer = 0

[continuous_queries]
log-enabled = true
enabled = true
query-stats-enabled = false
run-interval = "1s"
EOF

温馨提示: 更多 InfluxDB 配置参数讲述请参考 (https://docs.influxdata.com/influxdb/v1.8/administration/config/)


  • 步骤 02.使用InfluxDB 1.x图像运行容器,InfluxDB 镜像暴露了一个共享卷 /var/lib/influxdb,因此您可以将主机目录挂载到该点以访问持久的容器数据。
1
2
3
4
5
docker run -p 8086:8086 \
-p 2003:2003 \
-v /storage/database/influxdb/config/influxdb.conf:/etc/influxdb/influxdb.conf:ro
-v /storage/database/influxdb/data:/var/lib/influxdb \
influxdb:1.8.10 -config /etc/influxdb/influxdb.conf

温馨提示: 上述容器中暴露了以下端口(8086 HTTP API 端口、2003 Graphite 支持(如果已启用))很重要,由 InfluxDB 使用。