InfluxDB学习(一):基本概念和安装

饮马天涯 2020-04-19

一. InfluxDB数据库介绍

InfluxDB是Influxdata旗下开源的一种时序数据库(Time Series Database),根据DB-engine排名,目前在time series数据库领域排名第一位。

InfluxDB下载地址

https://portal.influxdata.com/downloads/

InfluxDB排名

https://db-engines.com/en/ranking/time+series+dbms

InfluxDB学习(一):基本概念和安装

 InfluxDB主要功能

  1. 对时序数据(sereis data)使用TSM存储引擎,提供高性能的数据写入和压缩功能。
  2. go语言编写,程序只有一个二进制的可执行文件,没有其他依关系。
  3. 通过http API可提供高性能的便捷的读写操作。
  4. 插件支持采集Graphite, collectd, and OpenTSDB等数据源。
  5. 提供类似SQL语法格式的数据操作。
  6. 保留策略(retention policies)功能可以定期清除老旧数据。
  7. 不间断(continuous queries)自动化查询功能统计聚合数据来使数据查询更有效率。

缺点:

  1. 社区版只支持单机部署,集群功能需要使用收费的企业版。
  2. InfluxDB中文学习文档较少,对于想要了解该数据库的用户有一定的不便。

InfluxDB与RDBMS中的概念比较

概念InfluxDBRDBMS
数据库databasedatabase
measurementtable
pointrow
tag(可索引),field(不可索引)column

二. InfluxDB数据库安装

# mkdir /usr/local/influxdb
# groupadd -r dba
# useradd -r -g dba tnuser
# chown -R tnuser.dba /usr/local/influxdb
# sudo su - tnuser
$ cd /usr/local/influxdb
$ wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.0-static_linux_amd64.tar.gz
$ tar -zxf influxdb-1.8.0-static_linux_amd64.tar.gz
$ mv influxdb-1.8.0-1/* .
$ rm -rf influxdb-1.8.0*

使用CentOS7的systemctl管理InfluxDB服务

# cat /usr/lib/systemd/system/influxdb.service 
[Unit]
Description=InfluxDB is time series database
Documentation=https://docs.influxdata.com/influxdb/v1.8/introduction/get-started/
After=syslog.target
After=network.target

[Service]
Type=fork
User=tnuser
Group=dba
Restart=always

# Disable OOM kill on the Redis
OOMScoreAdjust=-1000
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0

ExecStart=/usr/local/influxdb/usr/bin/influxd
ExecStop=/bin/kill -15 $MAINPID
LimitNOFILE=65536
 
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl enable influxdb
# systemctl start influxdb
# systemctl status influxdb
● influxdb.service - InfluxDB is time series database
   Loaded: loaded (/usr/lib/systemd/system/influxdb.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-04-18 23:19:03 PDT; 1s ago
     Docs: https://docs.influxdata.com/influxdb/v1.8/introduction/get-started/
 Main PID: 22583 (influxd)
   CGroup: /system.slice/influxdb.service
           └─22583 /usr/local/influxdb/usr/bin/influxd

Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.203421Z lvl=info msg="InfluxDB starting" log...568f5
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.203467Z lvl=info msg="Go runtime" log_id=0MG...ocs=4
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.311597Z lvl=info msg="Using data dir" log_id.../data
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.311635Z lvl=info msg="Compaction settings" l...31648
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.311647Z lvl=info msg="Open store (start)" lo...start
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.553803Z lvl=info msg="Reading file" log_id=0...87843
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.572851Z lvl=info msg="Opened file" log_id=0M...749ms
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.594031Z lvl=info msg="Opened file" log_id=0M...915ms
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.610554Z lvl=info msg="Opened shard" log_id=0...256ms
Apr 18 23:19:04 ec2t-dbaadmin-01.mypna.com influxd[22583]: ts=2020-04-19T06:19:04.612039Z lvl=info msg="Opened shard" log_id=0...741ms
Hint: Some lines were ellipsized, use -l to show in full.

相关推荐