07 部署Indluxdb-telegraf

部署INFLUDB

文章目录

    • 部署INFLUDB
      • 一、部署INFLUXDB
        • 1 .1下载并解压
        • 1.2 修改配置文件
          • 1.2.1修改influxdb.conf
        • 1.3 创建Data目录
        • 1.4 添加环境变量
        • 1.5设置启动文件
        • 1.6 基本命令
      • 二、部署telegraf
        • 2.1 下载并解压
        • 2.2 修改配置文件
        • 2.3 添加环境变量
        • 2.4 设置启动文件
      • 三、配置Grafana
        • 3.1 添加数据源
      • 四、部署chronograf
        • 4.1 下载并解压
        • 4.2 添加环境变量
        • 4.3设置启动文件
    • 后续参考(集群):

提供者:MappleZF

版本:1.0.0

一、部署INFLUXDB

1 .1下载并解压
wget -c https://dl.influxdata.com/influxdb/releases/influxdb-1.8.3_linux_amd64.tar.gz
tar -xf influxdb-1.8.3_linux_amd64.tar.gz -C /opt/

1.2 修改配置文件
1.2.1修改influxdb.conf
[[email protected]:/opt/influxdb/etc/influxdb]# vim influxdb.conf
### 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.
# 该选项用于上报influxdb的使用信息给InfluxData公司,默认值为false
# reporting-disabled = false

# Bind address to use for the RPC service for backup and restore.
# 绑定地址以用于RPC服务以进行备份和还原,默认配置是127.0.0.1:8088
# bind-address = "127.0.0.1:8088"

### 控制存储有关InfluxDB群集的元数据的Raft共识组的参数
### [meta]
###
### Controls the parameters for the Raft consensus group that stores metadata
### about the InfluxDB cluster.
###

[meta]
  # Where the metadata/raft database is stored
  # 存储元数据/ raft数据库的目录,默认值:/var/lib/influxdb/meta
  dir = "/var/lib/influxdb/meta"

  # Automatically create a default retention policy when creating a database.
  # 用于控制默认存储策略,数据库创建时,会自动生成autogen的存储策略,默认值:true。
  # retention-autocreate = true

  # If log messages are printed for the meta service
  #  为元服务打印日志消息,默认值:true
  # logging-enabled = true

### 控制InfluxDB的实际分片数据的生存位置以及它从WAL中刷新的方式。 “dir”可能需要更改为适合您系统的位置,但WAL设置是高级配置。 默认值应适用于大多数系统。
### [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.
  # 最终数据(TSM文件)存储目录,默认值:/var/lib/influxdb/data
  dir = "/mnt/cephfs/influxdb/data"

  # The directory where the TSM storage engine stores WAL files.
  # 预写日志存储目录,默认值:/var/lib/influxdb/wal
  wal-dir = "/var/lib/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.
  # 写入在fsyncing之前等待的时间.持续时间大于0可用于批量处理多个fsync调用.这对于较慢的磁盘或看到WAL写入争用时很有用.每次写入WAL时值为0s fsyncs.对于非SSD磁盘,建议使用0-100ms范围内的值
  # 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.
  # 用于新分片的分片索引的类型。 默认值是在启动时重新创建的内存中索引。 值“tsi1”将使用支持更高的基于磁盘的索引基数数据集
  index-version = "tsi1"

  # Trace logging provides more verbose output around the tsm engine. Turning
  # this on can provide more useful output for debugging tsm engine issues.
  # 是否开启跟踪(trace)日志,默认值:false。
  # 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.
  # 是否开启tsm引擎查询日志,默认值: true
  # 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.
  # 验证传入的写入以确保密钥仅具有有效的unicode字符。 此设置将产生很小的开销,因为必须检查每个密钥,默认值false
  # 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.
  # 用于限定shard最大值,大于该值时会拒绝写入,默认值:1GB
  cache-max-memory-size = "4g"

  # 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.
  # 用于设置快照大小,大于该值时数据会刷新到tsm文件,默认值:25MB
  # 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
  # tsm1引擎 snapshot(快照)写盘延迟,默认值:10m
  # 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
  # tsm文件在压缩前可以存储的最大时间,默认值:4h
  # 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.
  # 可以一次运行的最大并发完全和级别压缩数。 值为0会导致运行时使用50%运行时.GOMAXPROCS(0)。 任何大于0的数字都会限制对该值的压缩。 此设置不适用于缓存快照,默认值:0
  # 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
  # 是我们允许TSM压缩写入磁盘的速率限制(以字节/秒为单位)。 请注意,短脉冲串允许以可能更大的值发生,由Compact-Throughput-Burst设置,默认值:48m
  # compact-throughput = "48m"

  # CompactThroughputBurst is the rate limit in bytes per second that we
  # will allow TSM compactions to write to disk.
  # 是我们允许TSM压缩写入磁盘的速率限制,以每秒字节数为单位,默认值:48m
  # 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.
  # 如果为true,则将针对TSM文件向内核提供mmap建议值MADV_WILLNEED。 已发现此设置在某些内核上存在问题,默认值:false。 在某些情况下,它可能会帮助磁盘速度较慢的用户
  # 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.
  # 限制数据库的级数,该值为0时取消限制,默认值:1000000
  max-series-per-database = 10000000

  # 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.
  # 一个tag最大的value数,0取消限制,默认值:100000
  max-values-per-tag = 1000000

  # 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.
  # 索引预写日志文件压缩到索引文件中时的阈值(以字节为单位)。 较小的大小将导致日志文件更快地压缩,并导致较低的堆使用量,但代价是写入吞吐量。
  # 更高的大小将更少压缩,在内存中存储更多系列,并提供更高的写入吞吐量。有效大小的后缀为k,m或g(不区分大小写,1024 = 1k)。没有大小后缀的值以字节为单位,默认值:1m
  # 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.
  # 写操作超时时间,默认值: 10s
  # 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.
  # 最大并发查询数,0无限制,默认值: 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.
  # 查询操作超时时间,0无限制,默认值:0s
  # 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.
  # 慢查询超时时间,0无限制,默认值:0s
  # 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.
  # select语句可以处理的最大点数(points),0无限制,默认值:0
  # max-select-point = 0

  # The maximum number of series a SELECT can run.  A value of 0 will make the maximum series
  # count unlimited.
  # select语句可以处理的最大级数(series),0无限制,默认值:0
  # 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.
  # select语句可以处理的最大"GROUP BY time()"的时间周期,0无限制,默认值:0
  # max-select-buckets = 0

### 旧数据的保留策略
### [retention]
###
### Controls the enforcement of retention policies for evicting old data.
###

[retention]
  # Determines whether retention policy enforcement enabled.
  # 是否启用该模块,默认值 : true
  # enabled = true

  # The interval of time when retention policy enforcement checks run.
  # 检查时间间隔,默认值 :“30m”
  # 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.
  # 是否启用该模块,默认值 : true
  # enabled = true

  # The interval of time when the check to pre-create new shards runs.
  # 检查时间间隔,默认值 :“10m”
  # check-interval = "10m"

  # The default period ahead of the endtime of a shard group that its successor
  # group is created.
  # 预创建分区的最大提前时间,默认值 :30m
  # advance-period = "30m"

### 这一部分控制InfluxDB自有的监控系统。 默认情况下,InfluxDB把这些数据写入_internal 数据库,如果这个库不存在则自动创建。 
### _internal 库默认的retention策略是7天,如果你想使用一个自己的retention策略,需要自己创建
### 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.
  # 是否启用该模块,默认值 :true
  # store-enabled = true

  # The destination database for recorded statistics
  # 默认数据库:"_internal"
  # store-database = "_internal"

  # The interval at which to record statistics
  # 统计间隔,默认值:“10s”
  # store-interval = "10s"

### influxdb的http接口配置
### [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.
  # 是否启用该模块,默认值 :true
  # enabled = true

  # Determines whether the Flux query endpoint is enabled.
  # 是否启用流查询端点,默认值 :false
  # flux-enabled = false

  # Determines whether the Flux query logging is enabled.
  # flux-log-enabled = false

  # The bind address used by the HTTP service.
  # 绑定地址,默认值:":8086"
  # bind-address = ":8086"

  # Determines whether user authentication is enabled over HTTP/HTTPS.
  # 是否开启认证,默认值:false
  # auth-enabled = false

  # The default realm sent back when issuing a basic auth challenge.
  # 发出基本身份验证质询时发送回的默认域,默认值: “InfluxDB”
  # realm = "InfluxDB"

  # Determines whether HTTP request logging is enabled.
  # 是否开启http请求日志,默认值:true
  # log-enabled = true

  # Determines whether the HTTP write request logs should be suppressed when the log is enabled.
  # 在启用日志时是否应禁止HTTP写入请求日志,默认值:false
  # 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.
  # 启用HTTP请求日志记录时,此选项指定应写入日志条目的路径,如果未指定,则默认为写入stderr,它将HTTP日志与内部InfluxDB日志记录混合.
  # 如果涌入无法访问指定路径,它将记录错误并回退到将请求日志写入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.
  # 应记录哪些请求的过滤器。 每个过滤器的格式为NNN,NNX或NXX,其中N是数字,X是任意数字的通配符。 要过滤所有5xx响应,请使用字符串5xx。
  # 如果使用多个过滤器,则只需要匹配一个过滤器。 默认情况下没有过滤器会导致每个请求都被打印
  # access-log-status-filters = []

  # Determines whether detailed write logging is enabled.
  # 是否开启写操作日志,如果置成true,每一次写操作都会打日志,默认值:false
  # 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,此端点用于故障排除和监视,默认值:true
  # pprof-auth-enabled = false

  # Enables a pprof endpoint that binds to localhost:6060 immediately on startup.
  # This is only needed to debug startup issues.
  # 在启动时立即启用绑定到localhost:6060的pprof端点。这只需要调试启动问题。默认值:false
  # 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,默认值:false
  # https-enabled = false

  # The SSL certificate to use when HTTPS is enabled.
  # 设置https证书路径,默认值:"/etc/ssl/influxdb.pem"
  # https-certificate = "/etc/ssl/influxdb.pem"

  # Use a separate private key location.
  # 设置https私钥,无默认值
  # https-private-key = ""

  # The JWT auth shared secret to validate requests using JSON web tokens.
  # 用于JWT签名的共享密钥,无默认值
  # shared-secret = ""

  # The default chunk size for result sets that should be chunked.
  # 配置查询返回最大行数,默认值:10000
  # 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.
  # 配置最大连接数,超出此限制的新连接将被删除,0无限制,默认值:0
  # max-connection-limit = 0

  # Enable http service over unix domain socket
  # 通过unix域套接字启用http服务,默认值:false
  # unix-socket-enabled = false

  # The path of the unix domain socket.
  # unix-socket路径,默认值:"/var/run/influxdb.sock"
  # bind-socket = "/var/run/influxdb.sock"

  # The maximum size of a client request body, in bytes. Setting this value to 0 disables the limit.
  # 客户端请求正文的最大大小(以字节为单位), 将此值设置为0将禁用该限制。默认值:25000000
  # max-body-size = 25000000

  # The maximum number of writes processed concurrently.
  # Setting this to 0 disables the limit.
  # 并发处理的最大写入次数,将此设置为0将禁用该限制。默认值:0
  # max-concurrent-write-limit = 0

  # The maximum number of writes queued for processing.
  # Setting this to 0 disables the limit.
  # 排队等待处理的最大写入次数。将此设置为0将禁用该限制。默认值:0
  # 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.
  # 写入等待队列中写入的最长持续时间。将此设置为0或将max-concurrent-write-limit设置为0将禁用该限制。默认值:0
  # enqueued-write-timeout = 0

	# User supplied HTTP response headers
	#
	# [http.headers]
	#   X-Header-1 = "Header Value 1"
	#   X-Header-2 = "Header Value 2"

### 控制记录器如何将日志发送到输出.
### [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.
  # 确定用于日志的日志编码器。 可用选项包括auto,logfmt和json。
  # 如果输出终端是TTY,则auto将使用更加用户友好的输出格式,但格式不易于机器读取。
  # 当输出是非TTY时,auto将使用logfmt。默认值:“auto”
  # 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.
  # 确定将发出的日志级别。 可用的级别包括错误,警告,信息和调试。 将发出等于或高于指定级别的日志。默认值:“info”
  # 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.
  # 禁止在程序启动时打印的徽标输出。 如果STDOUT不是TTY,则始终禁止使用徽标。默认值:false
  # suppress-logo = false

### 控制Kapacitor接受数据的配置。enabled:是否启用该模块,默认值 :true
### [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.
  # 控制Kapacitor接受数据的配置。enabled:是否启用该模块,默认值 :true
  # enabled = true

  # The default timeout for HTTP writes to subscribers.
  # http超时时间,默认值:“30s”
  # http-timeout = "30s"

  # Allows insecure HTTPS connections to subscribers.  This is useful when testing with self-
  # signed certificates.
  # 是否允许不安全的证书,当测试自己签发的证书时比较有用。默认值: false
  # 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证书,无默认值
  # ca-certs = ""

  # The number of writer goroutines processing the write channel.
  # 设置并发数目,默认值:40
  # write-concurrency = 40

  # The number of in-flight writes buffered in the write channel.
  # 设置buffer大小,默认值:1000
  # write-buffer-size = 1000


### graphite相关配置
### [[graphite]]
###
### Controls one or many listeners for Graphite data.
###

[[graphite]]
  # Determines whether the graphite endpoint is enabled.
  # 是否启用该模块,默认值 :false
  # enabled = false
  # 数据库名称,默认值:“graphite”
  # database = "graphite"
  # 存储策略,无默认值
  # retention-policy = ""
  # 绑定地址,默认值:":2003"
  # bind-address = ":2003"
  # 协议,默认值:“tcp”
  # protocol = "tcp"
  # 一致性等级,默认值:“one”
  # 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
  # 批量size,默认值:5000
  # batch-size = 5000

  # number of batches that may be pending in memory
  # 配置在内存中等待的batch数,默认值:10
  # batch-pending = 10

  # Flush at least this often even if we haven't hit buffer limit
  # 超时时间,默认值:“1s”
  # batch-timeout = "1s"

  # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.
  # udp读取buffer的大小,0表示使用操作系统提供的值,如果超过操作系统的默认配置则会出错。 该配置的默认值:0
  # udp-read-buffer = 0

  ### This string joins multiple matching 'measurement' values providing more control over the final measurement name.
  # 多个measurement间的连接符,默认值: “.”
  # separator = "."

  ### Default tags that will be added to all metrics.  These can be overridden at the template level
  ### or by tags extracted from metric
  # 将添加到所有指标的默认标记。 这些可以在模板级别或从度量标准中提取的标签中覆盖,[“region=us-east”, “zone=1c”]
  # 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.”,]
  # templates = [
  #   "*.app env.service.resource.measurement",
  #   # Default template
  #   "server.*",
  # ]

### 控制一个或多个收集数据的侦听器
### [collectd]
###
### Controls one or many listeners for collectd data.
###

[[collectd]]
  # 是否启用该模块,默认值 :false
  # enabled = false
  # 绑定地址,默认值: “:25826”
  # bind-address = ":25826"
  # 数据库名称,默认值:“collectd”
  # 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
  # 这些下一行控制批处理的工作方式。 您应该已启用此功能,否则您可能会丢失指标或性能不佳。 如果有很多人进入,批处理将缓冲内存中的点。如果这么多点被缓冲,则刷新,默认值:5000
  # batch-size = 5000

  # Number of batches that may be pending in memory
  # 内存中可能挂起的批次数,默认值:10
  # batch-pending = 10

  # Flush at least this often even if we haven't hit buffer limit
  # 即使我们没有达到缓冲限制,也要经常冲洗至少这个,默认值:“10s”
  # batch-timeout = "10s"

  # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.
  # udp读取buffer的大小,0表示使用操作系统提供的值,如果超过操作系统的默认配置则会出错。默认值:0
  # 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配置
### [opentsdb]
###
### Controls one or many listeners for OpenTSDB data.
###

[[opentsdb]]
  # 是否启用该模块,默认值:false
  # enabled = false
  # 绑定地址,默认值:":4242"
  # bind-address = ":4242"
  # 默认数据库:“opentsdb”
  # database = "opentsdb"
  # 存储策略,无默认值
  # retention-policy = ""
  # 一致性级别,默认值:“one”
  # consistency-level = "one"
  # 是否开启tls,默认值:false
  # tls-enabled = false
  # 证书路径,默认值:"/etc/ssl/influxdb.pem"
  # certificate= "/etc/ssl/influxdb.pem"

  # Log an error for every malformed point.
  # 出错时是否记录日志,默认值:true
  # 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
  # 这些下一行控制批处理的工作方式。 您应该已启用此功能,否则您可能会丢失指标或性能不佳。
  # 仅通过telnet协议接收的指标进行批处理。如果这么多点被缓冲,请刷新。默认值:1000
  # batch-size = 1000

  # Number of batches that may be pending in memory
  # 内存中可能挂起的批次数,默认值:5
  # batch-pending = 5

  # Flush at least this often even if we haven't hit buffer limit
  # 即使我们没有达到缓冲限制,也要经常冲洗至少这个,默认值:“1s”
  # batch-timeout = "1s"

### udp配置
### [[udp]]
###
### Controls the listeners for InfluxDB line protocol data via UDP.
###

[[udp]]
  # 是否启用该模块,默认值:false
  # enabled = false
  # 绑定地址,默认值:":8089"
  # bind-address = ":8089"
  # 数据库名称,默认值:“udp”
  # database = "udp"
  # 存储策略,无默认值
  # retention-policy = ""

  # InfluxDB precision for timestamps on received points ("" or "n", "u", "ms", "s", "m", "h")
  # 时间精度("" 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
  # 接下来的行控制批处理的工作原理。 您应该已启用此功能,否则您可能会丢失指标或性能不佳。
  # 如果有很多进入,批处理将缓冲内存中的点。如果这么多点被缓冲,则刷新,默认值:5000
  # batch-size = 5000

  # Number of batches that may be pending in memory
  # 如果这么多点被缓冲,请刷新,默认值:10
  # batch-pending = 10

  # Will flush at least this often even if we haven't hit buffer limit
  # 即使我们没有达到缓冲限制,也会经常冲洗至少这个,默认值:“1s”
  # batch-timeout = "1s"

  # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.
  # udp读取buffer的大小,0表示使用操作系统提供的值,如果超过操作系统的默认配置则会出错。 默认值:0
  # read-buffer = 0

### CQs配置
### [continuous_queries]
###
### Controls how continuous queries are run within InfluxDB.
###

[continuous_queries]
  # Determines whether the continuous query service is enabled.
  # 是否开启CQs,默认值:true
  # enabled = true

  # Controls whether queries are logged when executed by the CQ service.
  # 是否开启日志,默认值:true
  # log-enabled = true

  # Controls whether queries are logged to the self-monitoring data store.
  # 控制是否将查询记录到自我监视数据存储。默认值:false
  # query-stats-enabled = false

  # interval for how often continuous queries will be checked if they need to run
  # 检查连续查询是否需要运行的时间间隔,默认值:“1s”
  # run-interval = "1s"

### InfluxDB中TLS的全局配置设置
### [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.
  # 确定可用的密码套件集。 有关可用密码的列表,请参阅https://golang.org/pkg/crypto/tls/#pkg-constants,这取决于Go的版本(使用查询SHOW DIAGNOSTICS查看用于构建InfluxDB的Go版本)。
  # 如果未指定,则使用Go的crypto / tls包中的默认设置,默认值:ciphers =[“TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305”,“TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256”,]
  # 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.
  # 将协商的tls协议的最低版本。 如果未指定,则使用Go的crypto / tls包中的默认设置,默认值:“tls1.2”
  # 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.
  # 将协商的tls协议的最大版本。 如果未指定,则使用Go的crypto / tls包中的默认设置,默认值:“tls1.2”
  # max-version = "tls1.3"

1.3 创建Data目录
mkdir -p /mnt/cephfs/influxdb/data
1.4 添加环境变量
vim /etc/profile
export PATH=/opt/influxdb/usr/bin:$PATH
source /etc/profile
1.5设置启动文件
cp -p /opt/influxdb/usr/lib/influxdb/scripts/influxdb.service /usr/lib/systemd/system/

systemctl enable influxdb.service
systemctl start influxdb.service
systemctl status influxdb.service

netstat -ntlp | grep 8086
ps -ef | grep influxdb

1.6 基本命令
登录命令   influx
显示所有数据库   show databases
使用数据库       use 
显示该数据库中所有的表   show measurements
查询语句 -- 查询10条数据  select * from  limit 10;
select * from  where .... limit 10;
删库drop database  
删表 drop measurement 

precision rfc3339; -- 之后再查询,时间就是rfc3339标准格式
-- 或可以在连接数据库的时候,直接带该参数
influx -precision rfc3339

-- 查看一个measurement中所有的tag key 
show tag keys
-- 查看一个measurement中所有的field key 
show field keys
-- 查看一个measurement中所有的保存策略(可以有多个,一个标识为default)
show retention policies;

二、部署telegraf

2.1 下载并解压
wget -c https://dl.influxdata.com/telegraf/releases/telegraf-1.15.3_linux_amd64.tar.gz
tar -xf telegraf-1.15.3_linux_amd64.tar.gz -C /opt/
mv telegraf-1.15.3 telegraf
2.2 修改配置文件
[[email protected]:/opt/telegraf/etc/telegraf]# vim telegraf.conf
###############################################################################
#                            OUTPUT PLUGINS                                   #
###############################################################################


# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
  ## The full HTTP or UDP URL for your InfluxDB instance.
  ##
  ## Multiple URLs can be specified for a single cluster, only ONE of the
  ## urls will be written to each interval.
  # urls = ["unix:///var/run/influxdb.sock"]
  # urls = ["udp://127.0.0.1:8089"]
  ## influxdb http地址,由于是宿主机直接安装,直接访问本地8086端口即可。
  urls = ["http://192.168.13.101:8086"]

  ## The target database for metrics; will be created as needed.
  ## For UDP url endpoint database needs to be configured on server side.
  # 数据库名,不存在会自动创建,默认"telegraf"
  database = "telegraf"

  ## The value of this tag will be used to determine the database.  If this
  ## tag is not set the 'database' option is used as the default.
  # database_tag = ""

  ## If true, the 'database_tag' will not be included in the written metric.
  # exclude_database_tag = false

  ## If true, no CREATE DATABASE queries will be sent.  Set to true when using
  ## Telegraf with a user without permissions to create databases or when the
  ## database already exists.
  # 跳过创建数据库
  skip_database_creation = false

  ## Name of existing retention policy to write to.  Empty string writes to
  ## the default retention policy.  Only takes effect when using HTTP.
  # retention_policy = ""

  ## The value of this tag will be used to determine the retention policy.  If this
  ## tag is not set the 'retention_policy' option is used as the default.
  # retention_policy_tag = ""

  ## If true, the 'retention_policy_tag' will not be included in the written metric.
  # exclude_retention_policy_tag = false
  ## Write consistency (clusters only), can be: "any", "one", "quorum", "all".
  ## Only takes effect when using HTTP.
  # write_consistency = "any"

  ## Timeout for HTTP messages.
  # 超时时间
  timeout = "5s"

  ## HTTP Basic Auth
  # username = "telegraf"
  # password = "metricsmetricsmetricsmetrics"

2.3 添加环境变量
vim /etc/profile
export PATH=/opt/telegraf/usr/bin:$PATH
source /etc/profile

2.4 设置启动文件
[[email protected]:/opt/telegraf/usr/lib/telegraf/scripts]# vim telegraf.service
[Unit]
Description=The plugin-driven server agent for reporting metrics into InfluxDB
Documentation=https://github.com/influxdata/telegraf
After=network.target

[Service]
EnvironmentFile=-/opt/telegraf/etc/default/telegraf
User=root
ExecStart=/opt/telegraf/usr/bin/telegraf -config /opt/telegraf/etc/telegraf/telegraf.conf -config-directory /opt/telegraf/etc/telegraf/telegraf.d $TELEGRAF_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartForceExitStatus=SIGPIPE
KillMode=control-group

[Install]
WantedBy=multi-user.target

:x 保存退出


cp -p /opt/telegraf/usr/lib/telegraf/scripts/telegraf.service  /usr/lib/systemd/system/

systemctl enable telegraf
systemctl start telegraf
systemctl status telegraf


三、配置Grafana

注:此处我们使用lb的集群外的grafana来配置,不使用k8s集群内的grafana

3.1 添加数据源

点击添加数据源,按照下图配置选择influxdb添加一个influxdb数据源;InfluxDB Details需填写数据名(默认telegraf);填写完成后,点击Save&Test按钮,若访问正常,会出现Data source is working提示,否则请检查配置内容以及网络。

07 部署Indluxdb-telegraf_第1张图片

四、部署chronograf

4.1 下载并解压
wget https://dl.influxdata.com/chronograf/releases/chronograf-1.8.7_linux_amd64.tar.gz
tar -xf chronograf-1.8.7_linux_amd64.tar.gz -C /opt
mv chronograf-1.8.7-1 chronograf
4.2 添加环境变量
vim /etc/profile
export PATH=/opt/chronograf/usr/bin:$PATH

source /etc/profile
4.3设置启动文件
[[email protected]:/opt/chronograf/usr/lib/chronograf/scripts]# vim chronograf.service

# If you modify this, please also make sure to edit init.sh

[Unit]
Description=Open source monitoring and visualization UI for the entire TICK stack.
Documentation="https://www.influxdata.com/time-series-platform/chronograf/"
After=network-online.target

[Service]
User=root
Group=root
Environment="HOST=0.0.0.0"
Environment="PORT=8888"
Environment="BOLT_PATH=/opt/chronograf/var/lib/chronograf/chronograf-v1.db"
Environment="CANNED_PATH=/opt/chronograf/usr/share/chronograf/canned"
Environment="PROTOBOARDS_PATH=/opt/chronograf/usr/share/chronograf/protoboards"
EnvironmentFile=-/opt/chronograf/etc/default/chronograf
ExecStart=/opt/chronograf/usr/bin/chronograf $CHRONOGRAF_OPTS
KillMode=control-group
Restart=on-failure

[Install]
WantedBy=multi-user.target
~                              
:x 保存退出

cp -p /opt/chronograf/usr/lib/chronograf/scripts/chronograf.service /usr/lib/systemd/system/

systemctl enable chronograf.service
systemctl start chronograf.service
systemctl status chronograf.service

07 部署Indluxdb-telegraf_第2张图片

后续参考(集群):

01 kubernetes二进制部署
02 kubernetes辅助环境设置
03 K8S集群网络ACL规则
04 Ceph集群部署
05 部署zookeeper和kafka集群
06 部署日志系统
07 部署Indluxdb-telegraf
08 部署jenkins
09 部署k3s和Helm-Rancher
10 部署maven软件

你可能感兴趣的:(kubernetes)