经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » InfluxDB » 查看文章
influxdb得导出与导入
来源:cnblogs  作者:香吧香  时间:2024/7/13 21:41:13  对本文有异议

转载请注明出处:

1、备份元数据

  基本语法:

  1. influxd backup <path-to-backup>

  备份元数据,没有任何其他参数,备份将只转移当前状态的系统元数据到path-to-backuppath-to-backup为备份保存的目录,不存在会自动创建。

  该备份会备份所有数据库以及所有保存策略下得数据。

   导出常用得其他参数:

  1. root@704be48ac1bc:/# influxd backup -h
  2. Creates a backup copy of specified InfluxDB OSS database(s) and saves the files in an Enterprise-compatible
  3. format to PATH (directory where backups are saved).
  4. Usage: influxd backup [options] PATH
  5. -portable
  6. Required to generate backup files in a portable format that can be restored to InfluxDB OSS or InfluxDB
  7. Enterprise. Use unless the legacy backup is required.
  8. -host <host:port>
  9. InfluxDB OSS host to back up from. Optional. Defaults to 127.0.0.1:8088.
  10. -db <name>
  11. InfluxDB OSS database name to back up. Optional. If not specified, all databases are backed up when
  12. using '-portable'.
  13. -rp <name>
  14. Retention policy to use for the backup. Optional. If not specified, all retention policies are used by
  15. default.
  16. -shard <id>
  17. The identifier of the shard to back up. Optional. If specified, '-rp <rp_name>' is required.
  18. -start <2015-12-24T08:12:23Z>
  19. Include all points starting with specified timestamp (RFC3339 format).
  20. Not compatible with '-since <timestamp>'.
  21. -end <2015-12-24T08:12:23Z>
  22. Exclude all points after timestamp (RFC3339 format).
  23. Not compatible with '-since <timestamp>'.
  24. -since <2015-12-24T08:12:23Z>
  25. Create an incremental backup of all points after the timestamp (RFC3339 format). Optional.
  26. Recommend using '-start <timestamp>' instead.
  27. -skip-errors
  28. Optional flag to continue backing up the remaining shards when the current shard fails to backup.
  29. backup: flag: help requested

  具体如下:

  1. Usage: influxd backup [options] PATH
  2. -portable # 在线备份,必选
  3. -host <host:port> # 需要备份的influxdb服务机器地址,可选,Defaults to 127.0.0.1:8088.
  4. -db <name> # 需要备份的db名称,可选,若没有指定,将备份所有数据库
  5. -rp <name> # 备份某个保留策略的数据,未指定,则备份所有rp的数据。
  6. -shard <id> # 需要备份的shard id,可选,若指定了备份shard,必须先选择rp
  7. -start # 需要备份的数据的起始时间,timestamp (RFC3339 format). 不能和-since一起使用
  8. -end # 需要备份的数据的结束时间,timestamp (RFC3339 format). 不能和-since一起使用
  9. -since # 备份这个timestamp之后的数据,建议用-start <timestamp>代替
  10. -skip-errors # 可选,当备份shards时,跳过备份失败的shard,继续备份其他shard。

 

2.influxdb导入

  1.先删除数据库

                           

  2.导入备份数据:

               

   这种方式只能导入按个数据库进行导入;

  3.导入其他配置项参数:

  1. root@704be48ac1bc:/# influxd restore -h
  2. Uses backup copies from the specified PATH to restore databases or specific shards from InfluxDB OSS
  3. or InfluxDB Enterprise to an InfluxDB OSS instance.
  4. Usage: influxd restore -portable [options] PATH
  5. Note: Restore using the '-portable' option consumes files in an improved Enterprise-compatible
  6. format that includes a file manifest.
  7. Options:
  8. -portable
  9. Required to activate the portable restore mode. If not specified, the legacy restore mode is used.
  10. -host <host:port>
  11. InfluxDB OSS host to connect to where the data will be restored. Defaults to '127.0.0.1:8088'.
  12. -db <name>
  13. Name of database to be restored from the backup (InfluxDB OSS or InfluxDB Enterprise)
  14. -newdb <name>
  15. Name of the InfluxDB OSS database into which the archived data will be imported on the target system.
  16. Optional. If not given, then the value of '-db <db_name>' is used. The new database name must be unique
  17. to the target system.
  18. -rp <name>
  19. Name of retention policy from the backup that will be restored. Optional.
  20. Requires that '-db <db_name>' is specified.
  21. -newrp <name>
  22. Name of the retention policy to be created on the target system. Optional. Requires that '-rp <rp_name>'
  23. is set. If not given, the '-rp <rp_name>' value is used.
  24. -shard <id>
  25. Identifier of the shard to be restored. Optional. If specified, then '-db <db_name>' and '-rp <rp_name>' are
  26. required.
  27. PATH
  28. Path to directory containing the backup files.
  29. restore: flag: help requested

  主要作用:

  1. Usage: influxd restore -portable [options] PATH
  2. Options:
  3. -portable #
  4. -host <host:port>
  5. -db <name> # 从备份数据的哪个库恢复数据Name of database to be restored from the backup
  6. -newdb <name>
  7. # 数据恢复到新库名称,若没有指定,选择-db <name>的名称。newdb必须不存在,恢复时会自动创建
  8. -rp <name> # 从备份数据的哪个rp恢复数据,指定了-rp,必须指定-db
  9. -newrp <name> #恢复数据新的rp名称,newrp必须存在。指定了-rp,未指定-newrp则使用-rp
  10. -shard <id> # 需要恢复的shard,如果指定了'-db <db_name>' and '-rp <rp_name>',必须-shard<id>
  11. PATH #备份数据文件list

  4.第二种导入方式:

  删除influxdb数据库存储得元数据文件,将influxdb得数据库元文件目录指定为备份得目录,然后再重启influxdb数据库即可完成导入

  1. influxd restore -metadir <path-to-meta-or-data-directory> <path-to-backup>

  从/var/lib/influxdb/ 目录下删除meta目录,即 rm -rf /var/lib/influxdb/meta,然后重启influxdbservice influxdb restart

 

 

原文链接:https://www.cnblogs.com/zjdxr-up/p/18300776

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号