环境:
CentOS 6.5
InfluxDB 1.2
一、下载安装
1、下载RPM
https://dl.influxdata.com/influxdb/releases/influxdb-1.2.0.x86_64.rpm
wget下载链接有问题,直接复制到浏览器下载很快,然后上传至linux机器即可
2、安装
sudo yum install influxdb-1.2.0.x86_64.rpm
3、启动
sudo service influxdb start
查看状态
[hadoop@hadoop000 ~]$ sudo service influxdb status
influxdb process is running [ OK ]
二、使用语法
1、登录
influx -precision rfc3339
参数含义
- The
-precision
argument specifies the format/precision of any returned timestamps. In the example above,rfc3339
tells InfluxDB to return timestamps in RFC3339 format (YYYY-MM-DDTHH:MM:SS.nnnnnnnnnZ
).
2、创建数据库
> CREATE DATABASE mydb
选择数据库
> use mydb;
Using database mydb
3、创建表并插入数据
3.1、Conceptually you can think of a measurement as an SQL table,在概念你要将measurement 看成我们常见数据中的表,所以在InfluxDB中查看表为:
> show measurements;
3.2、插入数据,在InfluxDB中是不需要创建表的,可以直接:
> INSERT cpu,host=serverA,region=us_west value=0.64
cpu代表的就表(measurement),host=serverA为tags,后面的为fields.
格式为
<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp]
3.3查看数据
> show measurements
name: measurements
name
----
cpu
--------------------------------------
> select * from cpu
name: cpu
time host region value
---- ---- ------ -----
2019-07-09T14:45:56.543728445Z serverA us_west 0.64
在InfluxDB中主索引永远都是time。
1.2版本语法及文档请参考
https://docs.influxdata.com/influxdb/v1.2/introduction/getting_started/
目前最新稳定版本为1.7.x,具体参考
https://docs.influxdata.com/influxdb/v1.7/introduction/getting-started/
1.7版本下载安装
https://portal.influxdata.com/downloads/
网友评论