influxdb install

influxdb 简介

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
InfluxDB是用Go语言编写的一个开源分布式时序,事件和指标数据库,无需外部依赖.类似的数据库有Elasticsearch,Graphite等.

特色:
1.基于时间序列,支持与时间有关的相关函数(如最大,最小,求和等)
2.可度量性:你可以实时对大量数据进行计算
3.基于事件:它支持任意的事件数据

特点:
1.无结构(无模式):可以是任意数量的列
2.可拓展的
3.支持min, max, sum, count, mean, median 等一系列函数,方便统计
4.原生的HTTP支持,内置HTTP API
5.强大的类SQL语法
6.自带管理界面,方便使用

By default, InfluxDB uses the following network ports:
TCP port 8083 is used for InfluxDB’s Admin panel
TCP port 8086 is used for client-server communication over InfluxDB’s HTTP API
  1. influxdb 安装

    1
    2
    3
    4
    [root@xxx ~]# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.1.1_linux_amd64.tar.gz
    [root@xxx ~]# tar xzf influxdb-1.1.1_linux_amd64.tar.gz
    [root@xxx ~]# mv influxdb-1.1.1-1 /mnt/app/influxdb
    [root@xxx ~]# mkdir -p /mnt/data/influxdb/{meta,data,hh,wal}
  2. influxdb 环境变量设置

    1
    2
    3
    4
    [root@xxx ~]# echo 'INFLUX_PATH=/mnt/app/influxdb'     |tee /etc/profile.d/influx.sh
    [root@xxx ~]# echo 'INFLUX_BIN=${INFLUX_PATH}/usr/bin' |tee -a /etc/profile.d/influx.sh
    [root@xxx ~]# echo 'export PATH=${INFLUX_BIN}:$PATH' |tee -a /etc/profile.d/influx.sh
    [root@xxx ~]# source /etc/profile
  3. influxdb 配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [root@xxx ~]# vim /mnt/app/influxdb/etc/influxdb/influxdb.conf
    [admin]
    enabled = true
    bind-address = ":8083"
    [http]
    bind-address = ":8086"
    [meta]
    dir = "/mnt/data/influxdb/meta"
    [data]
    dir = "/mnt/data/influxdb/data"
    wal-dir = "/mnt/data/influxdb/wal"
    [[udp]]
    bind-address = ":8089"
  4. influxdb 启动

    1
    2
    3
    [root@ip-172-31-90-45 ~]# /mnt/app/influxdb/usr/bin/influxd -config /mnt/app/influxdb/etc/influxdb/influxdb.conf
    or:
    [root@ip-172-31-90-45 ~]# /mnt/app/influxdb/usr/bin/influxd run -config /mnt/app/influxdb/etc/influxdb/influxdb.conf -pidfile /mnt/app/influxdb/run/influxdb.pid -cpuprofile /mnt/app/influxdb/run/influxdb.cpu -memprofile /mnt/app/influxdb/run/influxdb.memory &
  5. influxdb通过浏览器访问

    1
    http://{IP}:8083
  6. grafana install

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [root@xxx ~]# tar xzf grafana-4.1.1-1484211277.linux-x64.tar.gz
    [root@xxx ~]# mv grafana-4.1.1-1484211277 /mnt/app/grafana
    [root@xxx ~]# cp /mnt/app/grafana/conf/{sample.ini,custom.ini}

    [root@xxx srv]# vim /mnt/app/grafana/conf/custom.ini
    [root@xxx srv]# mkdir -p /mnt/data/grafana
    [root@xxx srv]# mkdir -p /mnt/log/grafana
    [root@xxx srv]# mkdir -p /mnt/app/grafana/plugins

    [root@xxx srv]# /mnt/app/grafana/bin/grafana-server -homepath /mnt/app/grafana/ -config /mnt/app/grafana/conf/custom.ini &

    用户和密码默认都是admin
    [root@xxx conf]# /mnt/app/grafana/bin/grafana-server -homepath /mnt/app/grafana -config /mnt/app/grafana/conf/custom.ini -pidfile /mnt/app/grafana/run/grafana.pid &

influxdb 配置

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
[root@xxx ~]# cat /mnt/app/influxdb/etc/influxdb/influxdb.conf
reporting-disabled = false
hostname = "172.31.90.45"
[meta]
dir = "/mnt/data/influxdb/meta"
retention-autocreate = true
logging-enabled = true
[data]
dir = "/mnt/data/influxdb/data"
wal-dir = "/mnt/data/influxdb/wal"
trace-logging-enabled = false
query-log-enabled = true
cache-max-memory-size = 1048576000
cache-snapshot-memory-size = 26214400
cache-snapshot-write-cold-duration = "10m"
compact-full-write-cold-duration = "4h"
max-series-per-database = 1000000
max-values-per-tag = 100000
[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 = "30m"
[shard-precreation]
enabled = true
check-interval = "10m"
advance-period = "30m"
[monitor]
store-enabled = true
store-database = "_internal"
store-interval = "10s"
[admin]
enabled = true
bind-address = ":8083"
https-enabled = false
[http]
enabled = true
bind-address = ":8086"
auth-enabled = false
log-enabled = true
write-tracing = false
pprof-enabled = true
https-enabled = false
max-row-limit = 10000
max-connection-limit = 0
unix-socket-enabled = false
[subscriber]
enabled = true
http-timeout = "30s"
insecure-skip-verify = false
write-concurrency = 40
write-buffer-size = 1000
[[collectd]]
enabled = true
bind-address = ":25826"
database = "collectd"
retention-policy = ""
typesdb = "/mnt/data/collectd/types.db"
batch-size = 5000
batch-pending = 10
batch-timeout = "10s"
read-buffer = 0
[continuous_queries]
enabled = true
log-enabled = true
run-interval = "1s"
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
[root@xxx ~]# cat /mnt/app/influxdb/etc/influxdb/influxdb.conf |grep -v \#|grep -v ^$
reporting-disabled = false
hostname = "172.31.90.45"
[meta]
dir = "/mnt/data/influxdb/meta"
retention-autocreate = true
logging-enabled = true
[data]
dir = "/mnt/data/influxdb/data"
wal-dir = "/mnt/data/influxdb/wal"
trace-logging-enabled = false
query-log-enabled = true
cache-max-memory-size = 1048576000
cache-snapshot-memory-size = 26214400
cache-snapshot-write-cold-duration = "10m"
compact-full-write-cold-duration = "4h"
max-series-per-database = 1000000
max-values-per-tag = 100000
[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 = "30m"
[shard-precreation]
enabled = true
check-interval = "10m"
advance-period = "30m"
[monitor]
store-enabled = true
store-database = "_internal"
store-interval = "10s"
[admin]
enabled = true
bind-address = ":8083"
https-enabled = false
[http]
enabled = true
bind-address = ":8086"
auth-enabled = false
log-enabled = true
write-tracing = false
pprof-enabled = true
https-enabled = false
max-row-limit = 10000
max-connection-limit = 0
unix-socket-enabled = false
[subscriber]
enabled = true
http-timeout = "30s"
insecure-skip-verify = false
write-concurrency = 40
write-buffer-size = 1000
[[collectd]]
enabled = true
bind-address = ":25826"
database = "collectd"
retention-policy = ""
typesdb = "/mnt/data/collectd/types.db"
batch-size = 5000
batch-pending = 10
batch-timeout = "10s"
read-buffer = 0
[continuous_queries]
enabled = true
log-enabled = true
run-interval = "1s"
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
[root@ip-172-31-90-45 ~]# cat /mnt/data/collectd/types.db
absolute value:ABSOLUTE:0:U
apache_bytes value:DERIVE:0:U
apache_connections value:GAUGE:0:65535
apache_idle_workers value:GAUGE:0:65535
apache_requests value:DERIVE:0:U
apache_scoreboard value:GAUGE:0:65535
ath_nodes value:GAUGE:0:65535
ath_stat value:DERIVE:0:U
backends value:GAUGE:0:65535
bitrate value:GAUGE:0:4294967295
blocked_clients value:GAUGE:0:U
bucket value:GAUGE:0:U
bytes value:GAUGE:0:U
cache_eviction value:DERIVE:0:U
cache_operation value:DERIVE:0:U
cache_ratio value:GAUGE:0:100
cache_result value:DERIVE:0:U
cache_size value:GAUGE:0:1125899906842623
capacity value:GAUGE:0:U
ceph_bytes value:GAUGE:U:U
ceph_latency value:GAUGE:U:U
ceph_rate value:DERIVE:0:U
changes_since_last_save value:GAUGE:0:U
charge value:GAUGE:0:U
clock_last_meas value:GAUGE:0:U
clock_last_update value:GAUGE:U:U
clock_mode value:GAUGE:0:U
clock_reachability value:GAUGE:0:U
clock_skew_ppm value:GAUGE:-2:2
clock_state value:GAUGE:0:U
clock_stratum value:GAUGE:0:U
compression uncompressed:DERIVE:0:U, compressed:DERIVE:0:U
compression_ratio value:GAUGE:0:2
connections value:DERIVE:0:U
conntrack value:GAUGE:0:4294967295
contextswitch value:DERIVE:0:U
count value:GAUGE:0:U
counter value:COUNTER:U:U
cpu value:DERIVE:0:U
cpufreq value:GAUGE:0:U
current value:GAUGE:U:U
current_connections value:GAUGE:0:U
current_sessions value:GAUGE:0:U
delay value:GAUGE:-1000000:1000000
derive value:DERIVE:0:U
df used:GAUGE:0:1125899906842623, free:GAUGE:0:1125899906842623
df_complex value:GAUGE:0:U
df_inodes value:GAUGE:0:U
dilution_of_precision value:GAUGE:0:U
disk_io_time io_time:DERIVE:0:U, weighted_io_time:DERIVE:0:U
disk_latency read:GAUGE:0:U, write:GAUGE:0:U
disk_merged read:DERIVE:0:U, write:DERIVE:0:U
disk_octets read:DERIVE:0:U, write:DERIVE:0:U
disk_ops read:DERIVE:0:U, write:DERIVE:0:U
disk_ops_complex value:DERIVE:0:U
disk_time read:DERIVE:0:U, write:DERIVE:0:U
dns_answer value:DERIVE:0:U
dns_notify value:DERIVE:0:U
dns_octets queries:DERIVE:0:U, responses:DERIVE:0:U
dns_opcode value:DERIVE:0:U
dns_qtype value:DERIVE:0:U
dns_qtype_cached value:GAUGE:0:4294967295
dns_query value:DERIVE:0:U
dns_question value:DERIVE:0:U
dns_rcode value:DERIVE:0:U
dns_reject value:DERIVE:0:U
dns_request value:DERIVE:0:U
dns_resolver value:DERIVE:0:U
dns_response value:DERIVE:0:U
dns_transfer value:DERIVE:0:U
dns_update value:DERIVE:0:U
dns_zops value:DERIVE:0:U
drbd_resource value:DERIVE:0:U
duration seconds:GAUGE:0:U
email_check value:GAUGE:0:U
email_count value:GAUGE:0:U
email_size value:GAUGE:0:U
energy value:GAUGE:U:U
energy_wh value:GAUGE:U:U
entropy value:GAUGE:0:4294967295
errors value:DERIVE:0:U
evicted_keys value:DERIVE:0:U
expired_keys value:DERIVE:0:U
fanspeed value:GAUGE:0:U
file_handles value:GAUGE:0:U
file_size value:GAUGE:0:U
files value:GAUGE:0:U
filter_result value:DERIVE:0:U
flow value:GAUGE:0:U
fork_rate value:DERIVE:0:U
frequency value:GAUGE:0:U
frequency_error value:GAUGE:-2:2
frequency_offset value:GAUGE:-1000000:1000000
fscache_stat value:DERIVE:0:U
gauge value:GAUGE:U:U
hash_collisions value:DERIVE:0:U
http_request_methods value:DERIVE:0:U
http_requests value:DERIVE:0:U
http_response_codes value:DERIVE:0:U
humidity value:GAUGE:0:100
if_collisions value:DERIVE:0:U
if_dropped rx:DERIVE:0:U, tx:DERIVE:0:U
if_errors rx:DERIVE:0:U, tx:DERIVE:0:U
if_multicast value:DERIVE:0:U
if_octets rx:DERIVE:0:U, tx:DERIVE:0:U
if_packets rx:DERIVE:0:U, tx:DERIVE:0:U
if_rx_dropped value:DERIVE:0:U
if_rx_errors value:DERIVE:0:U
if_rx_octets value:DERIVE:0:U
if_rx_packets value:DERIVE:0:U
if_tx_dropped value:DERIVE:0:U
if_tx_errors value:DERIVE:0:U
if_tx_octets value:DERIVE:0:U
if_tx_packets value:DERIVE:0:U
invocations value:DERIVE:0:U
io_octets rx:DERIVE:0:U, tx:DERIVE:0:U
io_packets rx:DERIVE:0:U, tx:DERIVE:0:U
ipc value:GAUGE:0:U
ipt_bytes value:DERIVE:0:U
ipt_packets value:DERIVE:0:U
irq value:DERIVE:0:U
latency value:GAUGE:0:U
links value:GAUGE:0:U
load shortterm:GAUGE:0:5000, midterm:GAUGE:0:5000, longterm:GAUGE:0:5000
memory_bandwidth value:DERIVE:0:U
md_disks value:GAUGE:0:U
memcached_command value:DERIVE:0:U
memcached_connections value:GAUGE:0:U
memcached_items value:GAUGE:0:U
memcached_octets rx:DERIVE:0:U, tx:DERIVE:0:U
memcached_ops value:DERIVE:0:U
memory value:GAUGE:0:281474976710656
memory_lua value:GAUGE:0:281474976710656
memory_throttle_count value:DERIVE:0:U
multimeter value:GAUGE:U:U
mutex_operations value:DERIVE:0:U
mysql_bpool_bytes value:GAUGE:0:U
mysql_bpool_counters value:DERIVE:0:U
mysql_bpool_pages value:GAUGE:0:U
mysql_commands value:DERIVE:0:U
mysql_handler value:DERIVE:0:U
mysql_innodb_data value:DERIVE:0:U
mysql_innodb_dblwr value:DERIVE:0:U
mysql_innodb_log value:DERIVE:0:U
mysql_innodb_pages value:DERIVE:0:U
mysql_innodb_row_lock value:DERIVE:0:U
mysql_innodb_rows value:DERIVE:0:U
mysql_locks value:DERIVE:0:U
mysql_log_position value:DERIVE:0:U
mysql_octets rx:DERIVE:0:U, tx:DERIVE:0:U
mysql_select value:DERIVE:0:U
mysql_sort value:DERIVE:0:U
mysql_sort_merge_passes value:DERIVE:0:U
mysql_sort_rows value:DERIVE:0:U
mysql_slow_queries value:DERIVE:0:U
nfs_procedure value:DERIVE:0:U
nginx_connections value:GAUGE:0:U
nginx_requests value:DERIVE:0:U
node_octets rx:DERIVE:0:U, tx:DERIVE:0:U
node_rssi value:GAUGE:0:255
node_stat value:DERIVE:0:U
node_tx_rate value:GAUGE:0:127
objects value:GAUGE:0:U
operations value:DERIVE:0:U
operations_per_second value:GAUGE:0:U
packets value:DERIVE:0:U
pending_operations value:GAUGE:0:U
percent value:GAUGE:0:100.1
percent_bytes value:GAUGE:0:100.1
percent_inodes value:GAUGE:0:100.1
pf_counters value:DERIVE:0:U
pf_limits value:DERIVE:0:U
pf_source value:DERIVE:0:U
pf_state value:DERIVE:0:U
pf_states value:GAUGE:0:U
pg_blks value:DERIVE:0:U
pg_db_size value:GAUGE:0:U
pg_n_tup_c value:DERIVE:0:U
pg_n_tup_g value:GAUGE:0:U
pg_numbackends value:GAUGE:0:U
pg_scan value:DERIVE:0:U
pg_xact value:DERIVE:0:U
ping value:GAUGE:0:65535
ping_droprate value:GAUGE:0:100
ping_stddev value:GAUGE:0:65535
players value:GAUGE:0:1000000
power value:GAUGE:U:U
pressure value:GAUGE:0:U
protocol_counter value:DERIVE:0:U
ps_code value:GAUGE:0:9223372036854775807
ps_count processes:GAUGE:0:1000000, threads:GAUGE:0:1000000
ps_cputime user:DERIVE:0:U, syst:DERIVE:0:U
ps_data value:GAUGE:0:9223372036854775807
ps_disk_octets read:DERIVE:0:U, write:DERIVE:0:U
ps_disk_ops read:DERIVE:0:U, write:DERIVE:0:U
ps_pagefaults minflt:DERIVE:0:U, majflt:DERIVE:0:U
ps_rss value:GAUGE:0:9223372036854775807
ps_stacksize value:GAUGE:0:9223372036854775807
ps_state value:GAUGE:0:65535
ps_vm value:GAUGE:0:9223372036854775807
pubsub value:GAUGE:0:U
queue_length value:GAUGE:0:U
records value:GAUGE:0:U
requests value:GAUGE:0:U
response_code value:GAUGE:0:U
response_time value:GAUGE:0:U
root_delay value:GAUGE:U:U
root_dispersion value:GAUGE:U:U
route_etx value:GAUGE:0:U
route_metric value:GAUGE:0:U
routes value:GAUGE:0:U
satellites value:GAUGE:0:U
segments value:GAUGE:0:65535
serial_octets rx:DERIVE:0:U, tx:DERIVE:0:U
signal_noise value:GAUGE:U:0
signal_power value:GAUGE:U:0
signal_quality value:GAUGE:0:U
smart_attribute current:GAUGE:0:255, worst:GAUGE:0:255, threshold:GAUGE:0:255, pretty:GAUGE:0:U
smart_badsectors value:GAUGE:0:U
smart_powercycles value:GAUGE:0:U
smart_poweron value:GAUGE:0:U
smart_temperature value:GAUGE:-300:300
snr value:GAUGE:0:U
spam_check value:GAUGE:0:U
spam_score value:GAUGE:U:U
spl value:GAUGE:U:U
swap value:GAUGE:0:1099511627776
swap_io value:DERIVE:0:U
tcp_connections value:GAUGE:0:4294967295
temperature value:GAUGE:U:U
threads value:GAUGE:0:U
time_dispersion value:GAUGE:-1000000:1000000
time_offset value:GAUGE:-1000000:1000000
time_offset_ntp value:GAUGE:-1000000:1000000
time_offset_rms value:GAUGE:-1000000:1000000
time_ref value:GAUGE:0:U
timeleft value:GAUGE:0:U
total_bytes value:DERIVE:0:U
total_connections value:DERIVE:0:U
total_objects value:DERIVE:0:U
total_operations value:DERIVE:0:U
total_requests value:DERIVE:0:U
total_sessions value:DERIVE:0:U
total_threads value:DERIVE:0:U
total_time_in_ms value:DERIVE:0:U
total_values value:DERIVE:0:U
uptime value:GAUGE:0:4294967295
users value:GAUGE:0:65535
vcl value:GAUGE:0:65535
vcpu value:GAUGE:0:U
virt_cpu_total value:DERIVE:0:U
virt_vcpu value:DERIVE:0:U
vmpage_action value:DERIVE:0:U
vmpage_faults minflt:DERIVE:0:U, majflt:DERIVE:0:U
vmpage_io in:DERIVE:0:U, out:DERIVE:0:U
vmpage_number value:GAUGE:0:4294967295
volatile_changes value:GAUGE:0:U
voltage value:GAUGE:U:U
voltage_threshold value:GAUGE:U:U, threshold:GAUGE:U:U
vs_memory value:GAUGE:0:9223372036854775807
vs_processes value:GAUGE:0:65535
vs_threads value:GAUGE:0:65535

#
# Legacy types
# (required for the v5 upgrade target)
#
arc_counts demand_data:COUNTER:0:U, demand_metadata:COUNTER:0:U, prefetch_data:COUNTER:0:U, prefetch_metadata:COUNTER:0:U
arc_l2_bytes read:COUNTER:0:U, write:COUNTER:0:U
arc_l2_size value:GAUGE:0:U
arc_ratio value:GAUGE:0:U
arc_size current:GAUGE:0:U, target:GAUGE:0:U, minlimit:GAUGE:0:U, maxlimit:GAUGE:0:U
mysql_qcache hits:COUNTER:0:U, inserts:COUNTER:0:U, not_cached:COUNTER:0:U, lowmem_prunes:COUNTER:0:U, queries_in_cache:GAUGE:0:U
mysql_threads running:GAUGE:0:U, connected:GAUGE:0:U, cached:GAUGE:0:U, created:COUNTER:0:U