InfluxDB 是一个开源分布式时序、事件和指标数据库。使用 Go 语言编写,无需外部依赖。其设计目标是实现分布式和水平伸缩扩展。

它有三大特性:

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

特点

  • schemaless(无结构),可以是任意数量的列
  • Scalable
  • min, max, sum, count, mean, median 一系列函数,方便统计
  • Native HTTP API, 内置http支持,使用http读写
  • Powerful Query Language 类似sql
  • Built-in Explorer 自带管理工具

一、安装

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.1.1.x86_64.rpm
sudo yum localinstall influxdb-1.1.1.x86_64.rpm

二、简单操作

一、CRUD
[root@OEL6-38 influxdb]# ls
influx influxd init.sh versions
[root@OEL6-38 influxdb]# /opt/influxdb/influx
Connected to http://localhost:8086 version 0.9.3
InfluxDB shell 0.9.3
> help
Usage:
connect <host:port> connect to another node
auth prompt for username and password
pretty toggle pretty print
use <db_name> set current databases
format <format> set the output format: json, csv, or column
settings output the current settings for the shell
exit quit the influx shell show databases show database names
show series show series information
show measurements show measurement information
show tag keys show tag key information
show tag values show tag value information a full list of influxql commands can be found at:
https://influxdb.com/docs/v0.9/query_language/spec.html

> show databases;
name: databases
---------------
name
db
yy
testDB

> use yy
Using database yy

> INSERT cpu_load_short,host=server01,region=us-west value=0.64,value2=0.86 1434055562000000000
> INSERT cpu_load_short,host=server02,region=us-west value=0.64,value2=0.86 1434055562000000000
> INSERT cpu_load_short,host=server02,region=us-west value3=0.84,value4=0.96 1434055562000008888

> SHOW MEASUREMENTS      #显示所有表

name: measurements
------------------
name
cpu_load_short

> SHOW FIELD KEYS
name: cpu_load_short
--------------------
fieldKey
value
value2
value3
value4

> SHOW series from cpu_load_short
name: cpu_load_short
--------------------
_keyhostregion
cpu_load_short,host=server01,region=us-westserver01us-west
cpu_load_short,host=server02,region=us-westserver02us-west

> SHOW TAG KEYS FROM cpu_load_short
name: cpu_load_short
--------------------
tagKey
host
region

> SHOW TAG VALUES FROM cpu_load_short with key = "host"
name: hostTagValues
-------------------
host
server01
server02

> SHOW TAG VALUES FROM cpu_load_short WITH KEY IN ("region", "host")
name: hostTagValues
-------------------
host
server01
server02

name: regionTagValues
---------------------
region
us-west

二、查询数据

> SELECT * FROM /.*/ LIMIT 1
name: cpu_load_short
--------------------
timehostregionvaluevalue2value3value4
2015-06-11T20:46:02Zserver01us-west0.640.86

参考链接:

https://www.influxdata.com/downloads/

http://www.cnblogs.com/liujianzuo888/articles/6017943.html

05-20 12:36