1.Influxdb使用1

2020-08-10 09:53:42

原創 George555   公衆號:測試江湖路 

如果這些內容對你有幫助,也可以開啓微信掃一掃,加關注:

一、簡介

    InfluxDB:是一款用Go語言編寫的開源分佈式時序、事件和指標數據庫, 一般主要用於儲存涉及大量的時間戳數據,如DevOps監控數據,APP metrics, loT感測器數據和實時分析數據。

二、安裝

1.centos下下載和安裝

下載命令:wget et https://dl.influxdata.com/influxdb/releases/influxdb-1.6.2.x86_64.rpm

[root@georgeComputer georgeProject]# wget et https://dl.influxdata.com/influxdb/releases/influxdb-1.6.2.x86_64.rpm

。。。。。。。此處省略1萬字

Saving to: 「influxdb-1.6.2.x86_64.rpm」

100%[===============================================>] 24,691,802  6.06M/s   in 5.0s

2020-06-24 19:20:59 (4.71 MB/s) - 「influxdb-1.6.2.x86_64.rpm」 saved [24691802/24691802]

FINISHED --2020-06-24 19:20:59--

Downloaded: 1 files, 24M in 5.0s (4.71 MB/s)

    安裝命令:yum localinstall influxdb-1.6.2.x86_64.rpm

[root@georgeComputer georgeProject]# yum localinstall influxdb-1.6.2.x86_64.rpm

Loaded plugins: fastestmirror

Setting up Local Package Process

Examining influxdb-1.6.2.x86_64.rpm: influxdb-1.6.2-1.x86_64   | 3.7 kB     00:00

。。。。。。。此處省略1萬字

Installed:

influxdb.x86_64 0:1.6.2-1

2.windows下下載安裝

    InfluxDB1.2.0可自行下載

    

    注:由於1.3後就不提供web管理端了,所以如果想用管理端的需要下載1.3之前版本,這裏提供了1.2版本,這個包比較難找到,如果網路上未找到請微信聯繫筆者。

    InfluxDB1.2.0安裝:

    InfluxDB的windows版本是綠色包,不需要安裝,下載後解壓即可使用,內部檔案如下圖:

    

三、設定-Centos環境

    安裝成功後,就需要去修改組態檔,以便可以和Jmeter或其他工具進行連通使用了。

    當然這裏windows和linux環境設定稍微有些差異,這裏以linux爲例進行說明:

    修改如下檔案:/etc/influxdb/influxdb.conf

    因爲jmeter把數據寫入到influxdb中,需要用graphite協定或http協定(兩種方式見下文中進行區分),所以需要修改如下板塊內容:

[http]

# Determines whether HTTP endpoint is enabled.

enabled = true

# The bind address used by the HTTP service.

bind-address = ":8086"

# Determines whether user authentication is enabled over HTTP/HTTPS.

# auth-enabled = false

# The default realm sent back when issuing a basic auth challenge.

# realm = "InfluxDB"

# Determines whether HTTP request logging is enabled.

log-enabled = true

[[graphite]]

# Determines whether the graphite endpoint is enabled.

enabled = true

database = "jmeterTest"

retention-policy = ""

bind-address = ":2003"

protocol = "tcp"

consistency-level = "one"

# These next lines control how batching works. You should have this enabled

# otherwise you could get dropped metrics or poor performance. Batching

# will buffer points in memory if you have many coming in.

# Flush if this many points get buffered

batch-size = 5000

# number of batches that may be pending in memory

batch-pending = 10

# Flush at least this often even if we haven't hit buffer limit

batch-timeout = "1s"

# UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.

udp-read-buffer = 0

### This string joins multiple matching 'measurement' values providing more control over the final measurement name.

separator = "."

    修改完成後可以使用命令:Influxd config ,查詢下修改後的設定資訊,如下圖:


[root@georgeComputer georgeProject]# influxd config
Merging with configuration at: /etc/influxdb/influxdb.conf
reporting-disabled = false
bind-address = "127.0.0.1:8088"
。。。。此處省略1萬字
[http]
  # Determines whether HTTP endpoint is enabled.
  enabled = true

  # The bind address used by the HTTP service.
  bind-address = ":8086"

  # Determines whether user authentication is enabled over HTTP/HTTPS.
  # auth-enabled = false

  # The default realm sent back when issuing a basic auth challenge.
  # realm = "InfluxDB"

  # Determines whether HTTP request logging is enabled.
  log-enabled = true
[[graphite]]
  enabled = false
  bind-address = ":2003"
  database = "jmeterTest"
  retention-policy = ""
  protocol = "tcp"
  batch-size = 5000
  batch-pending = 10
  batch-timeout = "1s"
  consistency-level = "one"
  separator = "."
  udp-read-buffer = 0

四、設定-Win環境

    windows環境下的influxdb.conf組態檔中,需要設定如下8大板塊內容:

    A.meta:數據庫源meta儲存路徑,預設是linux路徑,需要改爲windows目錄,注意 \\

[meta]
  # Where the metadata/raft database is stored
  #dir = "/var/lib/influxdb/meta"
  dir = "d:\\influx\\meta"
  # Automatically create a default retention policy when creating a database.
    retention-autocreate = true
  # If log messages are printed for the meta service
     logging-enabled = true

    B.data:TSM儲存引擎存放TSM檔案目錄

[data]
  # The directory where the TSM storage engine stores TSM files.
  # dir = "/var/lib/influxdb/data"
  dir = "d:\\influx\\data"
  # The directory where the TSM storage engine stores WAL files.
  #wal-dir = "/var/lib/influxdb/wal"
  wal-dir = "d:\\influx\\waldir"
  # Trace logging provides more verbose output around the tsm engine. Turning
  # this on can provide more useful output for debugging tsm engine issues.
  # trace-logging-enabled = false
  # Whether queries should be logged before execution. Very useful for troubleshooting, but will
  # log any sensitive data contained within a query.
    query-log-enabled = true

    C.retention:確定是否啓用執行保留策略

[retention]
  # Determines whether retention policy enforcment enabled.
  enabled = true

  # The interval of time when retention policy enforcement checks run.
  check-interval = "30m"

    D.shard-precreation:確定是否開啓 分片預建立,預設開啓

[shard-precreation]
  # Determines whether shard pre-creation service is enabled.
  enabled = true

  # The interval of time when the check to pre-create new shards runs.
  check-interval = "10m"

  # The default period ahead of the endtime of a shard group that its successor
  # group is created.
  advance-period = "30m"

    E.monitor:是否記錄內部統計數據

[monitor]
  # Whether to record statistics internally.
  store-enabled = true

  # The destination database for recorded statistics
  store-database = "_internal"

  # The interval at which to record statistics
  store-interval = "10s"

    F.admin:web端管理設定

[admin]
  # Determines whether the admin service is enabled.
  enabled = true

  # The default bind address used by the admin service.
  bind-address = ":8083"

  # Whether the admin service should use HTTPS.
  # https-enabled = false

  # The SSL certificate used when HTTPS is enabled.
  # https-certificate = "/etc/ssl/influxdb.pem"

    備註:admin板塊是針對influxdb的web後臺管理端做的設定,只有在V1.3版本之前可用,之後版本中官方組態檔取消了這個設定項,不能直接用web後臺設定管理了,這時候可以用chronograf,此工具使用見後面分享。

    G.http:http協定設定。用於http協定存取influxdb,比如jmeter中後端監聽器(Backend Listener)中選influxdb方式

[http]
  # Determines whether HTTP endpoint is enabled.
  enabled = true

  # The bind address used by the HTTP service.
  bind-address = ":8086"

    H.graphite:graphite協定設定。用於graphite協定存取influxdb,比如jmeter中後端監聽器(Backend Listener)中選graphite方式

[[graphite]]
  # Determines whether the graphite endpoint is enabled.是否啓用
  enabled = true
  #數據庫名設定
  database = "jmeterTest"
  retention-policy = ""
  #數據庫連線ip和埠設定
  bind-address = ":2003"
  #協定設定
  protocol = "tcp"
  consistency-level = "one"

 

 

#####歡迎加好友交流切磋####

QQ:464314378

微信羣請先加羣主微信,羣主會拉各位小夥伴進羣,注意新增備註。