Influxdb安装、启动influxdb控制台、常用命令、Influx命令使用、Influx-sql使用举例、Influxdb的数据格式、Influxdb客户端工具
目錄:
1.1. Influxdb下載 2
1.2. 解壓tar包 2
1.3. 修改配置文件 2
1.4. 配置文件參數(shù)說明 3
1.5. 實(shí)際配置(主要是修改路徑和端口) 10
1.6. 啟動 33
1.7. 啟動influxdb控制臺,第一次啟動會較慢,耐心等待 34
2.1. 常用命令 34
2.2. Influx命令使用 36
2.3. Influx-sql使用舉例 37
2.4. Influxdb的數(shù)據(jù)格式 37
1.Influxdb安裝
https://blog.csdn.net/weixin_43786255/article/details/107133899
1.1.Influxdb下載
獲取tar包
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.0_linux_amd64.tar.gz1.2.解壓tar包
cd /root/software tar -zxvf influxdb-1.8.0_linux_amd64.tar.gz -C /root/installed/cd /root/installed/ mv influxdb-1.8.0-1/ influxdb1.3.修改配置文件
可執(zhí)行文件路徑為:{influxdb目錄}/usr/bin
安裝InfluxDB之后,在/usr/bin下會有如下幾個文件:
默認(rèn)配置文件所在路徑:{influxdb目錄}/etc/influxdb/influxdb.conf
mkdir -p /data/influxdb/conf cp /root/installed/influxdb/etc/influxdb/influxdb.conf /data/influxdb/conf/ cd /data/influxdb mkdir meta mkdir data mkdir wal然后修改配置:
1.4.配置文件參數(shù)說明
# reporting-disabled = false # 該選項(xiàng)用于上報influxdb的使用信息給InfluxData公司,默認(rèn)值為false bind-address = "127.0.0.1:8085" # 備份恢復(fù)時使用,默認(rèn)值為8088 ### [meta] [meta]dir = "/data/influxdb/meta" # meta數(shù)據(jù)存放目錄# retention-autocreate = true # 用于控制默認(rèn)存儲策略,數(shù)據(jù)庫創(chuàng)建時,會自動生成autogen的存儲策略,默認(rèn)值:true# logging-enabled = true # 是否開啟meta日志,默認(rèn)值:true ### [data] [data]dir = "/data/influxdb/data" # 最終數(shù)據(jù)(TSM文件)存儲目錄wal-dir = "/data/influxdb/wal" # 預(yù)寫日志存儲目錄# wal-fsync-delay = "0s" # 在同步寫入之前等待的總時間,默認(rèn)0s# index-version = "inmem" # 用于新碎片的切分索引的類型。# trace-logging-enabled = false # 跟蹤日志記錄在tsm引擎周圍提供了更詳細(xì)的輸出# query-log-enabled = true # 是否開啟tsm引擎查詢?nèi)罩?#xff0c;默認(rèn)值: true# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).# cache-max-memory-size = "1g" # 用于限定shard最大值,大于該值時會拒絕寫入,默認(rèn)值:1000MB,單位:byte# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).# cache-snapshot-memory-size = "25m" # 用于設(shè)置快照大小,大于該值時數(shù)據(jù)會刷新到tsm文件,默認(rèn)值:25MB,單位:byte# cache-snapshot-write-cold-duration = "10m" # tsm引擎 snapshot寫盤延遲,默認(rèn)值:10Minute# compact-full-write-cold-duration = "4h" # tsm文件在壓縮前可以存儲的最大時間,默認(rèn)值:4Hour# max-concurrent-compactions = 0 # 壓縮并發(fā)的最大數(shù)量,默認(rèn)設(shè)置為0表示runtime.GOMAXPROCS(0)*50% ,否則以設(shè)置的非零值為準(zhǔn)# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).# max-index-log-file-size = "1m" # 限制索引日志文件大小# max-series-per-database = 1000000 # 限制數(shù)據(jù)庫的級數(shù),該值為0時取消限制,默認(rèn)值:1000000# max-values-per-tag = 100000 # 一個tag最大的value數(shù),0取消限制,默認(rèn)值:100000# tsm-use-madv-willneed = false # 如果為true,mmap的建議值MADV_WILLNEED會被提供給內(nèi)核 ### [coordinator] [coordinator]# write-timeout = "10s" # 寫操作超時時間,默認(rèn)值: 10s# max-concurrent-queries = 0 # 最大并發(fā)查詢數(shù),0無限制,默認(rèn)值: 0# query-timeout = "0s" # 查詢操作超時時間,0無限制,默認(rèn)值:0s# log-queries-after = "0s" # 慢查詢超時時間,0無限制,默認(rèn)值:0s# max-select-point = 0 # SELECT語句可以處理的最大點(diǎn)數(shù)(points),0無限制,默認(rèn)值:0# max-select-series = 0 # SELECT語句可以處理的最大級數(shù)(series),0無限制,默認(rèn)值:0# max-select-buckets = 0 # SELECT語句可以處理的最大"GROUP BY time()"的時間周期,0無限制,默認(rèn)值:0 ### [retention] [retention]# enabled = true # 是否啟用該模塊,默認(rèn)值 : true# check-interval = "30m" # 檢查時間間隔,默認(rèn)值 :"30m" ### [shard-precreation] [shard-precreation]# enabled = true # 是否啟用該模塊,默認(rèn)值 : true# check-interval = "10m" # 檢查時間間隔,默認(rèn)值 :"10m"# advance-period = "30m" # 預(yù)創(chuàng)建分區(qū)的最大提前時間,默認(rèn)值 :"30m" [monitor]# store-enabled = true # 是否啟用該模塊,默認(rèn)值 :true# store-database = "_internal" # 默認(rèn)數(shù)據(jù)庫:"_internal"# store-interval = "10s" # 統(tǒng)計間隔,默認(rèn)值:"10s" ### [http] [http]# enabled = true # 是否啟用該模塊,默認(rèn)值 :true# bind-address = ":8086" # 綁定地址,默認(rèn)值 :":8086"# auth-enabled = false # 是否開啟認(rèn)證,默認(rèn)值:false# realm = "InfluxDB" # 配置JWT realm,默認(rèn)值: "InfluxDB"# log-enabled = true # 是否開啟日志,默認(rèn)值:true# suppress-write-log = false # 在啟用日志時是否抑制HTTP寫請求日志# access-log-path = "" # 當(dāng)啟用HTTP請求日志時,該選項(xiàng)指定了路徑。如influxd不能訪問指定的路徑,它將記錄一個錯誤并將請求日志寫入stderr# write-tracing = false # 是否開啟寫操作日志,如果置成true,每一次寫操作都會打日志,默認(rèn)值:false# pprof-enabled = true # 是否開啟pprof,默認(rèn)值:true# debug-pprof-enabled = false # 是否開啟pprof,默認(rèn)值:true# https-enabled = false # 是否開啟https ,默認(rèn)值 :false# https-certificate = "/etc/ssl/influxdb.pem" # 設(shè)置https證書路徑,默認(rèn)值:"/etc/ssl/influxdb.pem"# https-private-key = "" # 設(shè)置https私鑰,無默認(rèn)值# shared-secret = "" # 用于JWT簽名的共享密鑰,無默認(rèn)值# max-row-limit = 0 # 配置查詢返回最大行數(shù),0無限制,默認(rèn)值:0# max-connection-limit = 0 # 配置最大連接數(shù),0無限制,默認(rèn)值:0# unix-socket-enabled = false # 是否使用unix-socket,默認(rèn)值:false# bind-socket = "/var/run/influxdb.sock" # unix-socket路徑,默認(rèn)值:"/var/run/influxdb.sock"# max-body-size = 25000000 # 客戶端請求主體的最大值,以字節(jié)為單位。0無限制,默認(rèn)值0# max-concurrent-write-limit = 0 # 并發(fā)處理的最大寫入次數(shù),0無限制,默認(rèn)值0# max-enqueued-write-limit = 0 # 排隊等待處理的最大數(shù)量,0無限制,默認(rèn)值0# enqueued-write-timeout = 0 # 在隊列中等待處理的最長時間,0或者setting max-concurrent-write-limit=0無限制,默認(rèn)值0 ### [ifql] [ifql]# enabled = true # 是否啟用該模塊,默認(rèn)值 :true# log-enabled = true # 是否開啟日志,默認(rèn)值:true# bind-address = ":8082" # ifql RPC服務(wù)使用的綁定地址默認(rèn)是8082 ### [logging] [logging]# format = "auto" # 日志格式,默認(rèn)是自動# level = "info" # 日志級別默認(rèn)info# suppress-logo = false # 當(dāng)程序啟動時,會抑制打印出來的logo輸出 ### [subscriber] [subscriber]# enabled = true # 是否啟用該模塊,默認(rèn)值 :true# http-timeout = "30s" # http超時時間,默認(rèn)值:"30s"# insecure-skip-verify = false # 是否允許不安全的證書# ca-certs = "" # 設(shè)置CA證書# write-concurrency = 40 # 設(shè)置并發(fā)數(shù)目,默認(rèn)值:40# write-buffer-size = 1000 # 設(shè)置buffer大小,默認(rèn)值:1000 ### [[graphite]] [[graphite]]# enabled = false # 是否啟用該模塊,默認(rèn)值 :false# database = "graphite" # 數(shù)據(jù)庫名稱,默認(rèn)值:"graphite"# retention-policy = "" # 存儲策略,無默認(rèn)值# bind-address = ":2003" # 綁定地址,默認(rèn)值:":2003"# protocol = "tcp" # 協(xié)議,默認(rèn)值:"tcp"# consistency-level = "one" # 一致性級別,默認(rèn)值:"one# batch-size = 5000 # 批量size,默認(rèn)值:5000# batch-pending = 10 # 配置在內(nèi)存中等待的batch數(shù),默認(rèn)值:10# batch-timeout = "1s" # 超時時間,默認(rèn)值:"1s"# udp-read-buffer = 0 # udp讀取buffer的大小,0表示使用操作系統(tǒng)提供的值,如果超過操作系統(tǒng)的默認(rèn)配置則會出錯。 該配置的默認(rèn)值:0# separator = "." # 多個measurement間的連接符,默認(rèn)值: "."# tags = ["region=us-east", "zone=1c"] # 將被添加到所有指標(biāo)的默認(rèn)標(biāo)簽。這些可以在模板級別上覆蓋或者從指標(biāo)中提取的標(biāo)簽# templates = [# "*.app env.service.resource.measurement",# # Default template# "server.*",# ] ### [collectd] [[collectd]]# enabled = false # 是否啟用該模塊,默認(rèn)值 :false# bind-address = ":25826" # 綁定地址,默認(rèn)值: ":25826"# database = "collectd" # 數(shù)據(jù)庫名稱,默認(rèn)值:"collectd"# retention-policy = "" # 存儲策略,無默認(rèn)值# typesdb = "/usr/local/share/collectd" # 路徑,默認(rèn)值:"/usr/share/collectd/types.db"# security-level = "none" # 安全級別# auth-file = "/etc/collectd/auth_file"# batch-size = 5000 # 從緩存中批量獲取數(shù)據(jù)的量,默認(rèn)值:5000# batch-pending = 10 # 可能在內(nèi)存中等待的批次的數(shù)量,默認(rèn)值:10# batch-timeout = "10s" # 即使沒有達(dá)到緩沖區(qū)的限制,至少要刷新一下,默認(rèn)值:"10s"# read-buffer = 0 # udp讀取buffer的大小,0表示使用操作系統(tǒng)提供的值,如果超過操作系統(tǒng)的默認(rèn)配置則會出錯。默認(rèn)值:0# parse-multivalue-plugin = "split" # 兩種處理方式split和join,split會分到不同的表中,join會將記錄作為一個單獨(dú)的記錄處理。默認(rèn)是split ### [opentsdb] [[opentsdb]]# enabled = false # 是否啟用該模塊,默認(rèn)值 :false# bind-address = ":4242" # 綁定地址,默認(rèn)值:":4242"# database = "opentsdb" # 默認(rèn)數(shù)據(jù)庫:"opentsdb"# retention-policy = "" # 存儲策略,無默認(rèn)值# consistency-level = "one" # 一致性級別,默認(rèn)值:"one"# tls-enabled = false # 是否開啟tls,默認(rèn)值:false# certificate= "/etc/ssl/influxdb.pem" # 證書路徑,默認(rèn)值:"/etc/ssl/influxdb.pem"# log-point-errors = true # 出錯時是否記錄日志,默認(rèn)值:true# batch-size = 1000 # 從緩存中批量獲取數(shù)據(jù)的量,默認(rèn)值:1000# batch-pending = 5 # 可能在內(nèi)存中等待的批次的數(shù)量,默認(rèn)值:5# batch-timeout = "1s" # 即使沒有達(dá)到緩沖區(qū)的限制,至少要刷新一下,默認(rèn)值:"1s" ### [[udp]] [[udp]]# enabled = false # 是否啟用該模塊,默認(rèn)值 :false# bind-address = ":8089" # 綁定地址,默認(rèn)值:":8089"# database = "udp" # 數(shù)據(jù)庫名稱,默認(rèn)值:"udp"# retention-policy = "" # 存儲策略,無默認(rèn)值# precision = "" # 接收點(diǎn)的時間點(diǎn)的精度("" or "n", "u", "ms", "s", "m", "h")# batch-size = 5000 # 從緩存中批量獲取數(shù)據(jù)的量,默認(rèn)值:5000# batch-pending = 10 # 可能在內(nèi)存中等待的批次的數(shù)量,默認(rèn)值:10# batch-timeout = "1s" # 即使沒有達(dá)到緩沖區(qū)的限制,至少要刷新一下,默認(rèn)值:"1s"# read-buffer = 0 # udp讀取buffer的大小,0表示使用操作系統(tǒng)提供的值,如果超過操作系統(tǒng)的默認(rèn)配置則會出錯。 該配置的默認(rèn)值:0 ### [continuous_queries] [continuous_queries]# enabled = true # 是否啟用該模塊,默認(rèn)值 :true# log-enabled = true # 是否開啟日志,默認(rèn)值:true# query-stats-enabled = false # 控制查詢是否被記錄到自我監(jiān)控數(shù)據(jù)存儲中# run-interval = "1s" # 時間間隔,默認(rèn)值:"1s" ### [tls] [tls]# ciphers = [# "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",# "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",# ]# min-version = "tls1.2"# max-version = "tls1.2"1.5.實(shí)際配置(主要是修改路徑和端口)
### Welcome to the InfluxDB configuration file.# The values in this file override the default values used by the system if # a config option is not specified. The commented out lines are the configuration # field and the default value used. Uncommenting a line and changing the value # will change the value used at runtime when the process is restarted.# Once every 24 hours InfluxDB will report usage data to usage.influxdata.com # The data includes a random ID, os, arch, version, the number of series and other # usage data. No data from user databases is ever transmitted. # Change this option to true to disable reporting. # reporting-disabled = false# Bind address to use for the RPC service for backup and restore. # bind-address = ":8088"bind-address = ":8085"### ### [meta] ### ### Controls the parameters for the Raft consensus group that stores metadata ### about the InfluxDB cluster. ###[meta]# Where the metadata/raft database is storeddir = "/data/influxdb/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### ### [data] ### ### Controls where the actual shard data for InfluxDB lives and how it is ### flushed from the WAL. "dir" may need to be changed to a suitable place ### for your system, but the WAL settings are an advanced configuration. The ### defaults should work for most systems. ###[data]# The directory where the TSM storage engine stores TSM files.dir = "/data/influxdb/data"# The directory where the TSM storage engine stores WAL files.wal-dir = "/data/influxdb/wal"# The amount of time that a write will wait before fsyncing. A duration# greater than 0 can be used to batch up multiple fsync calls. This is useful for slower# disks or when WAL write contention is seen. A value of 0s fsyncs every write to the WAL.# Values in the range of 0-100ms are recommended for non-SSD disks.# wal-fsync-delay = "0s"# The type of shard index to use for new shards. The default is an in-memory index that is# recreated at startup. A value of "tsi1" will use a disk based index that supports higher# cardinality datasets.# index-version = "inmem"# 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# Validates incoming writes to ensure keys only have valid unicode characters.# This setting will incur a small overhead because every key must be checked.# validate-keys = false# Settings for the TSM engine# CacheMaxMemorySize is the maximum size a shard's cache can# reach before it starts rejecting writes.# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).# Values without a size suffix are in bytes.# cache-max-memory-size = "1g"# CacheSnapshotMemorySize is the size at which the engine will# snapshot the cache and write it to a TSM file, freeing up memory# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).# Values without a size suffix are in bytes.# cache-snapshot-memory-size = "25m"# CacheSnapshotWriteColdDuration is the length of time at# which the engine will snapshot the cache and write it to# a new TSM file if the shard hasn't received writes or deletes# cache-snapshot-write-cold-duration = "10m"# CompactFullWriteColdDuration is the duration at which the engine# will compact all TSM files in a shard if it hasn't received a# write or delete# compact-full-write-cold-duration = "4h"# The maximum number of concurrent full and level compactions that can run at one time. A# value of 0 results in 50% of runtime.GOMAXPROCS(0) used at runtime. Any number greater# than 0 limits compactions to that value. This setting does not apply# to cache snapshotting.# max-concurrent-compactions = 0# CompactThroughput is the rate limit in bytes per second that we# will allow TSM compactions to write to disk. Note that short bursts are allowed# to happen at a possibly larger value, set by CompactThroughputBurst# compact-throughput = "48m"# CompactThroughputBurst is the rate limit in bytes per second that we# will allow TSM compactions to write to disk.# compact-throughput-burst = "48m"# If true, then the mmap advise value MADV_WILLNEED will be provided to the kernel with respect to# TSM files. This setting has been found to be problematic on some kernels, and defaults to off.# It might help users who have slow disks in some cases.# tsm-use-madv-willneed = false# Settings for the inmem index# The maximum series allowed per database before writes are dropped. This limit can prevent# high cardinality issues at the database level. This limit can be disabled by setting it to# 0.# max-series-per-database = 1000000# The maximum number of tag values per tag that are allowed before writes are dropped. This limit# can prevent high cardinality tag values from being written to a measurement. This limit can be# disabled by setting it to 0.# max-values-per-tag = 100000# Settings for the tsi1 index# The threshold, in bytes, when an index write-ahead log file will compact# into an index file. Lower sizes will cause log files to be compacted more# quickly and result in lower heap usage at the expense of write throughput.# Higher sizes will be compacted less frequently, store more series in-memory,# and provide higher write throughput.# Valid size suffixes are k, m, or g (case insensitive, 1024 = 1k).# Values without a size suffix are in bytes.# max-index-log-file-size = "1m"# The size of the internal cache used in the TSI index to store previously# calculated series results. Cached results will be returned quickly from the cache rather# than needing to be recalculated when a subsequent query with a matching tag key/value# predicate is executed. Setting this value to 0 will disable the cache, which may# lead to query performance issues.# This value should only be increased if it is known that the set of regularly used# tag key/value predicates across all measurements for a database is larger than 100. An# increase in cache size may lead to an increase in heap usage.series-id-set-cache-size = 100### ### [coordinator] ### ### Controls the clustering service configuration. ###[coordinator]# The default time a write request will wait until a "timeout" error is returned to the caller.# write-timeout = "10s"# The maximum number of concurrent queries allowed to be executing at one time. If a query is# executed and exceeds this limit, an error is returned to the caller. This limit can be disabled# by setting it to 0.# max-concurrent-queries = 0# The maximum time a query will is allowed to execute before being killed by the system. This limit# can help prevent run away queries. Setting the value to 0 disables the limit.# query-timeout = "0s"# The time threshold when a query will be logged as a slow query. This limit can be set to help# discover slow or resource intensive queries. Setting the value to 0 disables the slow query logging.# log-queries-after = "0s"# The maximum number of points a SELECT can process. A value of 0 will make# the maximum point count unlimited. This will only be checked every second so queries will not# be aborted immediately when hitting the limit.# max-select-point = 0# The maximum number of series a SELECT can run. A value of 0 will make the maximum series# count unlimited.# max-select-series = 0# The maximum number of group by time bucket a SELECT can create. A value of zero will max the maximum# number of buckets unlimited.# max-select-buckets = 0### ### [retention] ### ### Controls the enforcement of retention policies for evicting old data. ###[retention]# Determines whether retention policy enforcement enabled.# enabled = true# The interval of time when retention policy enforcement checks run.# check-interval = "30m"### ### [shard-precreation] ### ### Controls the precreation of shards, so they are available before data arrives. ### Only shards that, after creation, will have both a start- and end-time in the ### future, will ever be created. Shards are never precreated that would be wholly ### or partially in the past.[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"### ### Controls the system self-monitoring, statistics and diagnostics. ### ### The internal database for monitoring data is created automatically if ### if it does not already exist. The target retention within this database ### is called 'monitor' and is also created with a retention period of 7 days ### and a replication factor of 1, if it does not exist. In all cases the ### this retention policy is configured as the default for the database.[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"### ### [http] ### ### Controls how the HTTP endpoints are configured. These are the primary ### mechanism for getting data into and out of InfluxDB. ###[http]# Determines whether HTTP endpoint is enabled.# enabled = true# Determines whether the Flux query endpoint is enabled.# flux-enabled = false# Determines whether the Flux query logging is enabled.# flux-log-enabled = false# 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# Determines whether the HTTP write request logs should be suppressed when the log is enabled.# suppress-write-log = false# When HTTP request logging is enabled, this option specifies the path where# log entries should be written. If unspecified, the default is to write to stderr, which# intermingles HTTP logs with internal InfluxDB logging.## If influxd is unable to access the specified path, it will log an error and fall back to writing# the request log to stderr.# access-log-path = ""# Filters which requests should be logged. Each filter is of the pattern NNN, NNX, or NXX where N is# a number and X is a wildcard for any number. To filter all 5xx responses, use the string 5xx.# If multiple filters are used, then only one has to match. The default is to have no filters which# will cause every request to be printed.# access-log-status-filters = []# Determines whether detailed write logging is enabled.# write-tracing = false# Determines whether the pprof endpoint is enabled. This endpoint is used for# troubleshooting and monitoring.# pprof-enabled = true# Enables authentication on pprof endpoints. Users will need admin permissions# to access the pprof endpoints when this setting is enabled. This setting has# no effect if either auth-enabled or pprof-enabled are set to false.# pprof-auth-enabled = false# Enables a pprof endpoint that binds to localhost:6060 immediately on startup.# This is only needed to debug startup issues.# debug-pprof-enabled = false# Enables authentication on the /ping, /metrics, and deprecated /status# endpoints. This setting has no effect if auth-enabled is set to false.# ping-auth-enabled = false# Determines whether HTTPS is enabled.# https-enabled = false# The SSL certificate to use when HTTPS is enabled.# https-certificate = "/etc/ssl/influxdb.pem"# Use a separate private key location.# https-private-key = ""# The JWT auth shared secret to validate requests using JSON web tokens.# shared-secret = ""# The default chunk size for result sets that should be chunked.# max-row-limit = 0# The maximum number of HTTP connections that may be open at once. New connections that# would exceed this limit are dropped. Setting this value to 0 disables the limit.# max-connection-limit = 0# Enable http service over unix domain socket# unix-socket-enabled = false# The path of the unix domain socket.# bind-socket = "/var/run/influxdb.sock"# The maximum size of a client request body, in bytes. Setting this value to 0 disables the limit.# max-body-size = 25000000# The maximum number of writes processed concurrently.# Setting this to 0 disables the limit.# max-concurrent-write-limit = 0# The maximum number of writes queued for processing.# Setting this to 0 disables the limit.# max-enqueued-write-limit = 0# The maximum duration for a write to wait in the queue to be processed.# Setting this to 0 or setting max-concurrent-write-limit to 0 disables the limit.# enqueued-write-timeout = 0### ### [logging] ### ### Controls how the logger emits logs to the output. ###[logging]# Determines which log encoder to use for logs. Available options# are auto, logfmt, and json. auto will use a more a more user-friendly# output format if the output terminal is a TTY, but the format is not as# easily machine-readable. When the output is a non-TTY, auto will use# logfmt.# format = "auto"# Determines which level of logs will be emitted. The available levels# are error, warn, info, and debug. Logs that are equal to or above the# specified level will be emitted.# level = "info"# Suppresses the logo output that is printed when the program is started.# The logo is always suppressed if STDOUT is not a TTY.# suppress-logo = false### ### [subscriber] ### ### Controls the subscriptions, which can be used to fork a copy of all data ### received by the InfluxDB host. ###[subscriber]# Determines whether the subscriber service is enabled.# enabled = true# The default timeout for HTTP writes to subscribers.# http-timeout = "30s"# Allows insecure HTTPS connections to subscribers. This is useful when testing with self-# signed certificates.# insecure-skip-verify = false# The path to the PEM encoded CA certs file. If the empty string, the default system certs will be used# ca-certs = ""# The number of writer goroutines processing the write channel.# write-concurrency = 40# The number of in-flight writes buffered in the write channel.# write-buffer-size = 1000### ### [[graphite]] ### ### Controls one or many listeners for Graphite data. ###[[graphite]]# Determines whether the graphite endpoint is enabled.# enabled = false# database = "graphite"# 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 = "."### Default tags that will be added to all metrics. These can be overridden at the template level### or by tags extracted from metric# tags = ["region=us-east", "zone=1c"]### Each template line requires a template pattern. It can have an optional### filter before the template and separated by spaces. It can also have optional extra### tags following the template. Multiple tags should be separated by commas and no spaces### similar to the line protocol format. There can be only one default template.# templates = [# "*.app env.service.resource.measurement",# # Default template# "server.*",# ]### ### [collectd] ### ### Controls one or many listeners for collectd data. ###[[collectd]]# enabled = false# bind-address = ":25826"# database = "collectd"# retention-policy = ""## The collectd service supports either scanning a directory for multiple types# db files, or specifying a single db file.# typesdb = "/usr/local/share/collectd"## security-level = "none"# auth-file = "/etc/collectd/auth_file"# 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 = "10s"# UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.# read-buffer = 0# Multi-value plugins can be handled two ways.# "split" will parse and store the multi-value plugin data into separate measurements# "join" will parse and store the multi-value plugin as a single multi-value measurement.# "split" is the default behavior for backward compatibility with previous versions of influxdb.# parse-multivalue-plugin = "split" ### ### [opentsdb] ### ### Controls one or many listeners for OpenTSDB data. ###[[opentsdb]]# enabled = false# bind-address = ":4242"# database = "opentsdb"# retention-policy = ""# consistency-level = "one"# tls-enabled = false# certificate= "/etc/ssl/influxdb.pem"# Log an error for every malformed point.# log-point-errors = true# These next lines control how batching works. You should have this enabled# otherwise you could get dropped metrics or poor performance. Only points# metrics received over the telnet protocol undergo batching.# Flush if this many points get buffered# batch-size = 1000# Number of batches that may be pending in memory# batch-pending = 5# Flush at least this often even if we haven't hit buffer limit# batch-timeout = "1s"### ### [[udp]] ### ### Controls the listeners for InfluxDB line protocol data via UDP. ###[[udp]]# enabled = false# bind-address = ":8089"# database = "udp"# retention-policy = ""# InfluxDB precision for timestamps on received points ("" or "n", "u", "ms", "s", "m", "h")# precision = ""# 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# Will 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.# read-buffer = 0### ### [continuous_queries] ### ### Controls how continuous queries are run within InfluxDB. ###[continuous_queries]# Determines whether the continuous query service is enabled.# enabled = true# Controls whether queries are logged when executed by the CQ service.# log-enabled = true# Controls whether queries are logged to the self-monitoring data store.# query-stats-enabled = false# interval for how often continuous queries will be checked if they need to run# run-interval = "1s"### ### [tls] ### ### Global configuration settings for TLS in InfluxDB. ###[tls]# Determines the available set of cipher suites. See https://golang.org/pkg/crypto/tls/#pkg-constants# for a list of available ciphers, which depends on the version of Go (use the query# SHOW DIAGNOSTICS to see the version of Go used to build InfluxDB). If not specified, uses# the default settings from Go's crypto/tls package.# ciphers = [# "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",# "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",# ]# Minimum version of the tls protocol that will be negotiated. If not specified, uses the# default settings from Go's crypto/tls package.# min-version = "tls1.2"# Maximum version of the tls protocol that will be negotiated. If not specified, uses the# default settings from Go's crypto/tls package.# max-version = "tls1.3"其中,修改端口的是:
bind-address = "127.0.0.1:8085"1.6.啟動
cd /root/installed/influxdb/usr/bin nohup ./influxd -config /data/influxdb/conf/influxdb.conf > influxdb.log 2>&1 &啟動日志如下:
[root@node1 bin]# pwd /root/installed/influxdb/usr/bin [root@node1 bin]# ls influx influxd influxdb.log influx_inspect influx_stress influx_tsm [root@node1 bin]# tail -f influxdb.log ts=2021-08-10T09:40:34.625789Z lvl=info msg="Starting precreation service" log_id=0Vsro8Hl000 service=shard-precreation check_interval=10m advance_period=30m ts=2021-08-10T09:40:34.626089Z lvl=info msg="Starting snapshot service" log_id=0Vsro8Hl000 service=snapshot ts=2021-08-10T09:40:34.627613Z lvl=info msg="Starting continuous query service" log_id=0Vsro8Hl000 service=continuous_querier ts=2021-08-10T09:40:34.626355Z lvl=info msg="Storing statistics" log_id=0Vsro8Hl000 service=monitor db_instance=_internal db_rp=monitor interval=10s ts=2021-08-10T09:40:34.627886Z lvl=info msg="Starting HTTP service" log_id=0Vsro8Hl000 service=httpd authentication=false ts=2021-08-10T09:40:34.628627Z lvl=info msg="opened HTTP access log" log_id=0Vsro8Hl000 service=httpd path=stderr ts=2021-08-10T09:40:34.628868Z lvl=info msg="Listening on HTTP" log_id=0Vsro8Hl000 service=httpd addr=[::]:8086 https=false ts=2021-08-10T09:40:34.629726Z lvl=info msg="Starting retention policy enforcement service" log_id=0Vsro8Hl000 service=retention check_interval=30m ts=2021-08-10T09:40:34.629991Z lvl=info msg="Listening for signals" log_id=0Vsro8Hl000 ts=2021-08-10T09:40:34.630847Z lvl=info msg="Sending usage statistics to usage.influxdata.com" log_id=0Vsro8Hl0001.7.啟動influxdb控制臺,第一次啟動會較慢,耐心等待
[root@node1 bin]# ./influx -port 8085 Connected to http://localhost:8085 version 1.8.0 InfluxDB shell version: 1.8.0 > create user "tuzq" with password '123456' with all privileges > show users user admin ---- ----- tuzq true >2.使用
2.1.常用命令
[root@node1 bin]# ./influx -help Usage of influx:-versionDisplay the version and exit.-path-prefix 'url path'Path that follows the host and port-host 'host name'Host to connect to.-port 'port #'Port to connect to.-socket 'unix domain socket'Unix socket to connect to.-database 'database name'Database to connect to the server.-password 'password'Password to connect to the server. Leaving blank will prompt for password (--password '').-username 'username'Username to connect to the server.-sslUse https for requests.-unsafeSslSet this when connecting to the cluster using https and not use SSL verification.-execute 'command'Execute command and quit.-type 'influxql|flux'Type specifies the query language for executing commands or when invoking the REPL.-format 'json|csv|column'Format specifies the format of the server responses: json, csv, or column.-precision 'rfc3339|h|m|s|ms|u|ns'Precision specifies the format of the timestamp: rfc3339, h, m, s, ms, u or ns.-consistency 'any|one|quorum|all'Set write consistency level: any, one, quorum, or all-prettyTurns on pretty print for the json format.-importImport a previous database export from file-ppsHow many points per second the import will allow. By default it is zero and will not throttle importing.-pathPath to file to import-compressedSet to true if the import file is compressedExamples:# Use influx in a non-interactive mode to query the database "metrics" and pretty print json:$ influx -database 'metrics' -execute 'select * from cpu' -format 'json' -pretty# Connect to a specific database on startup and set database context:$ influx -database 'metrics' -host 'localhost' -port '8086'2.2.Influx命令使用
Influx是連接influxdb的一個CLI程序,在本地成功安裝influxdb后,influxdb啟動,influx命令就可以直接使用。Influxdb默認(rèn)在8086端口運(yùn)行。Influx cli默認(rèn)使用localhost:8085連接。可以使用-host和-port選項(xiàng),連接到其他機(jī)器或者端口。
[root@node1 bin]# ./influx -port 8085 Connected to http://localhost:8085 version 1.8.0 InfluxDB shell version: 1.8.0 >2.3.Influx-sql使用舉例
Influx命令連接數(shù)據(jù)庫后,可以使用類sql語句查詢數(shù)據(jù)
| CREATE DATABASE database_name | 建立數(shù)據(jù)庫 |
| SHOW DATABASES | 查詢所有數(shù)據(jù)庫 |
| USE database_name | USE database_name |
| INSERT cpu,host=host_name,region=cn value=66 | 插數(shù)據(jù)入cpu measurement,標(biāo)簽host=host_name,region=cn, field是value=66 |
| SELECT “host”, “region”, “value” FROM “cpu” | 從cpu measurement查詢數(shù)據(jù) |
| SELECT * FROM “cpu” | 從cpu measurement查詢所有數(shù)據(jù) |
2.4.Influxdb的數(shù)據(jù)格式
Influxdb是一個時序數(shù)據(jù)庫,其保存metric的在某一系列時間點(diǎn)的狀態(tài)。這些點(diǎn)狀態(tài)包含時間戳,一個所謂的“measurement”名稱,至少一個稱為filed的鍵值對,以及0到多個標(biāo)簽(如 host=bigdata01)。
在influxdb中可以把measurement看為關(guān)系數(shù)據(jù)庫中的table,tag和field是其中的列。其中Tag都加了索引、field不加。和關(guān)系數(shù)據(jù)庫不同的是,不用預(yù)先定義schema,沒有value的點(diǎn)不會被保存。其格式如下:
<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp]舉例:
cpu,host=bigdata01,region=cn value=66payment,device=mobile,product=Notepad,method=credit billed=88,licenses=2i 14340674691563293233.Influxdb客戶端工具
下載InfluxDBStudio-0.2.0,解壓,然后點(diǎn)擊:InfluxDBStudio.exe , 配置好參數(shù)配置:
示例:
總結(jié)
以上是生活随笔為你收集整理的Influxdb安装、启动influxdb控制台、常用命令、Influx命令使用、Influx-sql使用举例、Influxdb的数据格式、Influxdb客户端工具的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 5.prometheus告警插件-ale
- 下一篇: 借呗的放款机构能换吗