InfluxDB學習(一):基本概念和安裝


一. 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主要功能

  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中的概念比較

概念 InfluxDB RDBMS
數據庫 database database
measurement table
point row
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*

修改InfluxDB數據庫配置文件,模板文件在數據庫安裝路徑下的etc/influxdb/influxdb.conf

reporting-disabled = true
bind-address = "0.0.0.0:8088"
[meta]
  dir = "/usr/local/influxdb/meta"
  retention-autocreate = true
[data]
  dir = "/usr/local/influxdb/data"
  wal-dir = "/usr/local/influxdb/wal"

使用CentOS7的systemctl管理InfluxDB服務

[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 run -config /usr/local/influxdb/etc/influxdb/influxdb.conf
ExecStop=/bin/kill -15 $MAINPID
ExecReload=/bin/kill -s HUP $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.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM