InfluxDB -- 数据的导入导出




# influx_inspect export --help
Exports TSM files into InfluxDB line protocol format.

Usage: influx_inspect export [flags]
        Compress the output
  -database string
        Optional: the database to export
  -datadir string
        Data storage path (default "/root/.influxdb/data")
  -end string
        Optional: the end time to export (RFC3339 format)
  -out string
        Destination file to export to (default "/root/.influxdb/export")
  -retention string
        Optional: the retention policy to export (requires -database)
  -start string
        Optional: the start time to export (RFC3339 format)
  -waldir string
        WAL storage path (default "/root/.influxdb/wal")


influx_inspect export -datadir "/var/lib/influxdb/data" -waldir "/var/lib/influxdb/wal" -out "influxdb_dump_out" -database "opsultra" -start "2021-09-10T00:00:00Z"
  datadir: influxdb的数据存放位置
  waldir: influxdb的wal目录
  out: 输出文件
  database: 导出的db名称
  start: 从什么时间导出



# influx -import --help
Usage of influx:
       Display the version and exit.
  -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.
        Use https for requests.
        Set this when connecting to the cluster using https and not use SSL verification.
  -execute 'command'
       Execute command and quit.
  -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
       Turns on pretty print for the json format.
       Import a previous database export from file
       How many points per second the import will allow.  By default it is zero and will not throttle importing.
       Path to file to import
       Set to true if the import file is compressed

    # 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'


# influx -import -path=/root/influxdb_dump_out -precision=ns

  import: 标识导入
  path: 导入文件
  precision: 导入的数据时间精度
38 声望
21 粉丝
0 条评论
38 声望
21 粉丝