【问题标题】:Sqoop bulk export to SQL ServerSqoop 批量导出到 SQL Server
【发布时间】:2020-01-11 23:54:14
【问题描述】:

我正在尝试将 21046329 行导出到 SQL Server,但速度很慢。我尝试使用批量插入,但它不起作用。查看 SQL Server Profiler 我看到它每个 stmt 只插入 1 行,之后我看了一下 sqoop 映射器,我看到它生成这样的 SQL 查询

'org.apache.sqoop.mapreduce.sqlserver.SqlServerExportBatchOutputFormat: 使用查询 INSERT INTO [test3] ([col1], [col2], [col3], [col4], [col5], [col6], [col7]) 值 (?, ?, ?, ?, ?, ?, ?)'

Sqoop 导出命令:

sqoop export
--connect 'jdbc:sqlserver://server:port;database=test2;EnableBulkLoad=true;BulkLoadBatchSize=100024;BulkLoadOptions=0' 
--username test --password pass --table 'test3' 
--export-dir /exportDirFromHDFS --input-lines-terminated-by "n" 
--input-fields-terminated-by ',' 
--batch -m 10

有人知道如何解决这个问题吗?

【问题讨论】:

    标签: sqoop


    【解决方案1】:

    尝试使用属性sqoop.export.records.per.statement 指定将在每个插入语句中使用的记录数:

    sqoop export \
      -Dsqoop.export.records.per.statement=10 \
      --connect 
      ...
    

    因此,Sqoop 将创建以下查询:

    INSERT INTO table VALUES (...), (...), (...), ...;

    【讨论】:

    • 我试过了,还是这样生成的:org.apache.sqoop.mapreduce.sqlserver.SqlServerExportBatchOutputFormat: Using query INSERT INTO [test3] ([col1], [col2], [col3], [ col4],[col5],[col6],[col7])值(?,?,?,?,?,?,?)
    猜你喜欢
    • 1970-01-01
    • 2017-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多