influxdb 以及timescaledb 都是不错的时序数据库,timescaledb 团队提供了直接从influxdb 导入

环境准备

  • docker-compose 文件
version: "3"
services:
timescaledb:
image: timescale/timescaledb-postgis:latest-pg10
ports:
- "5432:5432"
environment:
- "POSTGRES_PASSWORD=dalong"
influxdb:
image: influxdb
ports:
- "8086:8086"

influxdb 数据导入

  • 下载测试数据

    注意需要在容器中操作 docker-compose exec influxdb sh

wget https://timescaledata.blob.core.windows.net/datasets/outflux_taxi.txt
  • 导入
influx -import -path=./outflux_taxi.txt -database=outflux_tutorial

schema 迁移

./outflux schema-transfer outflux_tutorial taxi --input-server=http://localhost:8086 --output-conn="dbname=postgres user=postgres password=
dalong"

效果

2019/04/12 11:03:55 Selected input database: outflux_tutorial
2019/04/12 11:03:55 Overriding PG environment variables for connection with: dbname=postgres user=postgres password=dalong
2019/04/12 11:03:55 pipe_taxi starting execution
2019/04/12 11:03:55 Discovering influx schema for measurement: taxi
2019/04/12 11:03:55 Discovered: DataSet { Name: taxi, Columns: [Column { Name: time, DataType: IDRFTimestamp} Column { Name: location_id, DataType
: IDRFString} Column { Name: rating, DataType: IDRFString} Column { Name: vendor, DataType: IDRFString} Column { Name: fare, DataType: IDRFDouble}
Column { Name: mta_tax, DataType: IDRFDouble} Column { Name: tip, DataType: IDRFDouble} Column { Name: tolls, DataType: IDRFDouble}], Time Column
: time }
2019/04/12 11:03:55 Selected Schema Strategy: CreateIfMissing
2019/04/12 11:03:55 existing hypertable 'taxi' is partitioned properly
2019/04/12 11:03:55 No data transfer will occur
2019/04/12 11:03:55 Schema Transfer complete in: 0.079 seconds

数据迁移

./outflux migrate outflux_tutorial taxi --input-server=http://localhost:8086 --output-conn="dbname=postgres user=postgres password=dalong" --schema-strategy=DropAndCreate

效果

2019/04/12 11:04:33 All pipelines scheduled
2019/04/12 11:04:33 Overriding PG environment variables for connection with: dbname=postgres user=postgres password=dalong
2019/04/12 11:04:33 pipe_taxi starting execution
2019/04/12 11:04:33 Discovering influx schema for measurement: taxi
2019/04/12 11:04:33 Discovered: DataSet { Name: taxi, Columns: [Column { Name: time, DataType: IDRFTimestamp} Column { Name: location_id, DataType
: IDRFString} Column { Name: rating, DataType: IDRFString} Column { Name: vendor, DataType: IDRFString} Column { Name: fare, DataType: IDRFDouble}
Column { Name: mta_tax, DataType: IDRFDouble} Column { Name: tip, DataType: IDRFDouble} Column { Name: tolls, DataType: IDRFDouble}], Time Column
: time }
2019/04/12 11:04:33 Selected Schema Strategy: DropAndCreate
2019/04/12 11:04:33 Table taxi exists, dropping it
2019/04/12 11:04:33 Executing: DROP TABLE taxi
2019/04/12 11:04:33 Table taxi ready to be created
2019/04/12 11:04:33 Creating table with:
CREATE TABLE "taxi"("time" TIMESTAMP, "location_id" TEXT, "rating" TEXT, "vendor" TEXT, "fare" FLOAT, "mta_tax" FLOAT, "tip" FLOAT, "tolls" FLOAT
)
2019/04/12 11:04:33 Preparing TimescaleDB extension:
CREATE EXTENSION IF NOT EXISTS timescaledb
2019/04/12 11:04:33 Creating hypertable with: SELECT create_hypertable('"taxi"', 'time');
2019/04/12 11:04:33 Starting extractor 'pipe_taxi_ext' for measure: taxi
2019/04/12 11:04:33 Starting data ingestor 'pipe_taxi_ing'
2019/04/12 11:04:33 pipe_taxi_ext: Extracting data from database 'outflux_tutorial'
2019/04/12 11:04:33 pipe_taxi_ext: SELECT "time", "location_id", "rating", "vendor", "fare", "mta_tax", "tip", "tolls"
FROM "taxi"
2019/04/12 11:04:33 pipe_taxi_ext:Pulling chunks with size 15000
2019/04/12 11:04:33 Will batch insert 8000 rows at once. With commit strategy: CommitOnEachBatch
2019/04/12 11:04:33 pipe_taxi_ext: Extracted 185 rows from Influx
2019/04/12 11:04:33 pipe_taxi_ing: Complete. Inserted 185 rows.
2019/04/12 11:04:33 All pipelines finished
2019/04/12 11:04:33 Migration execution time: 0.094 seconds

pg 效果


参考资料

https://docs.timescale.com/v1.2/tutorials/outflux
https://docs.influxdata.com/influxdb/v1.7/introduction/getting-started/
https://blog.timescale.com/migrate-outflux-a-smart-way-out-of-influxdb/

 
 
 
 

使用outflux 导入influxdb 的数据到timescaledb的更多相关文章

  1. 在Linux环境下,将Solr部署到tomcat7中,导入Mysql数据库数据, 定时更新索引

    什么是solr solr是基于Lucene的全文搜索服务器,对Lucene进行了扩展优化. 准备工作 首先,去下载以下软件包: JDK8:jdk-8u60-linux-x64.tar.gz TOMCA ...

  2. [diango]批量导入不重复数据

    去年研究导入数据的时候写了一个批量导入数据的脚本,但有个问题,如果导入这批数据在数据库中已经存在,那么我们导入的数据不就重复了么,本文就讨论如何解决这个问题? 程序如下: #coding:utf-8 ...

  3. java调用sqlldr导入csv文件数据到临时表

    package cn.com.file;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File; ...

  4. Sqoop2入门之导入关系型数据库数据到HDFS上(sqoop2-1.99.4版本)

    sqoop2-1.99.4和sqoop2-1.99.3版本操作略有不同:新版本中使用link代替了老版本的connection,其他使用类似. sqoop2-1.99.4环境搭建参见:Sqoop2环境 ...

  5. ECshop导入淘宝数据包乱码问题解决方法

    ECshop在导入淘宝数据包的时候出现数据乱码. 测试版本 ecshop2.73 利用淘宝助手导出一个数据包(.csv),不要一次全部商品导出,最好是将数据包控制在1M左右,因为ecshop对上传文件 ...

  6. Oracle sqlldr导入导出txt数据文件详解

    一.sqlldr导入txt 1.预备 a).txt文件 这里要保存成无签名的UTF-8 b).oracle建表 2.编写控制文件input_test.ctl LOAD DATA CHARACTERSE ...

  7. Oracle Imp and Exp (导入和导出) 数据 工具使用

    Oracle 提供两个工具imp.exe 和exp.exe分别用于导入和导出数据.这两个工具位于Oracle_home/bin目录下. 导入数据exp 1 将数据库ATSTestDB完全导出,用户名s ...

  8. DOS 选择跳转实现、dos + bcp 双击导入和导出数据

    DOS 选择跳转实现.dos + bcp 双击导入和导出数据 option.bat @echo off :Start2 cls goto Start :Start title Frequently U ...

  9. xp下Oracle数据库导入SQLServer数据库数据

    Oracle数据库利用ODBC数据源.PLSQL Developer导入SQLServer数据库数据 操作: 建立数据源:控制面板→管理工具→数据源 (ODBC) 打开,界面如下: 点击添加,界面如下 ...

随机推荐

  1. 714-Card Trick

    思维题,把n个卡片倒着放,然后每个卡片循环放到最底下i次,最后出来的结果就是要求的卡牌顺序 #include<stdio.h> #include<string.h> #incl ...

  2. 【shell脚本】 变量基础学习整理

    1.linux系统环境 echo 'echo /etc/profile ' >> /etc/profile echo 'echo /etc/bashrc' >> /etc/ba ...

  3. axios和promise

    什么是axios axios is a promise based HTTP client for the browser and node.js Features: Make XMLHttpRequ ...

  4. kibana升级之后原本保存的数据dashboards, visualizations, index patterns丢失

    1,es升级注意的问题:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/rolling-upgrades.html 2,kiba ...

  5. 一天一点Zynq(1)xilinx-arm-linux交叉编译链 安装总结以及资源更新

    结束了对xilinx-arm-linux交叉编译链安装后,总结一下整个过程,方便后来的研究者们,少走点弯路. 关于xilinx-arm-linux交叉编译链的安装,网上一搜一大把,可是有的资料中的资源 ...

  6. js实现滚动条来动态加载数据

    主要angular2+es6 data:Array<any> //展示的数据 allData:Array<any> //全部的数据 size:number = 10 //每次动 ...

  7. 简单excel导入导出

    import java.io.File;import java.io.IOException; import jxl.Cell;import jxl.Sheet;import jxl.Workbook ...

  8. atom插件安装失败解决方法

    在atom 上下载插件失败,可以用下面的方法. 1.找到C:/Users/你的用户名/.atom/packages/文件夹内 2.在.atom packages 目录下 使用gitbash 3.git ...

  9. 一个神奇的???whatever~~

    一个神奇的类,用来封装消息数据,统一数据传递接口,从unity引擎源码拷贝而来. #include <iostream> #include <assert.h> #includ ...

  10. constructor&object 的对比

    Constructor vs object A constructor is a special member function in the class to allocate memory to ...