hadoop - 从 hdfs 到 GreenPlum 的 Sqoop 导出不起作用
问题描述
我正在尝试将数据从 hdfs 位置导出到 Greenplum 用户定义的模式(不是默认模式)。
尝试 Sqoop Eval 来检查连接。
sqoop eval --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sample_user --password xxxx --query "SELECT * FROM sample_db.sample_table LIMIT 3"
结果: 工作正常
尝试使用--schema
选项
/usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sampleuser --password samplepassword --table sample_table --schema sample_schema --export-dir=/sample/gp_export --input-fields-terminated-by ',' --update-mode allowinsert
结果:
Warning: /usr/hdp/2.3.6.0-3796/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
18/06/25 11:09:41 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.3.6.0-3796
18/06/25 11:09:41 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Error parsing arguments for export:
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --schema
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: sample_schema
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --export-dir=/sample/gp_export
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --input-fields-terminated-by
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: ,
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --update-mode
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: allowinsert
根据 sqoop 文档
https://sqoop.apache.org/docs/1.4.3/SqoopUserGuide.html'--'
在之前添加了额外内容'--schema'
/usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sampleuser --password samplepassword --table sample_table -- --schema sample_schema --export-dir=/sample/gp_export --input-fields-terminated-by ',' --update-mode allowinsert
结果:
Warning: /usr/hdp/2.3.6.0-3796/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
18/06/25 11:06:26 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.3.6.0-3796
18/06/25 11:06:26 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
Export requires an --export-dir argument or --hcatalog-table argument.
Try --help for usage instructions.
有人可以指导我吗?谢谢
解决方案
感谢@cricket_007 的澄清。
--schema
参数应该在 sqoop 命令的最后。所以下面的代码正在工作。
/usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb" \
--username sampleuser --password samplepassword \
--export-dir=/sample/gp_export --input-fields-terminated-by ',' \
--table sample_table -- --schema sample_schema
但是UPSERT
postgresSql 不支持操作。这里有一张开放的 Jira 票。
https://issues.apache.org/jira/browse/SQOOP-1270
推荐阅读
- json - Jmeter,Groovy JSON slurper 用于作为变量的键
- authentication - 无密码基于密钥的身份验证不起作用
- java - 为什么抛出 AccessDeniedException 时 Files.move() 会删除文件?
- javascript - 如何在 Angular 6 中向 Algolia ais-instantsearch 组件添加数字过滤器
- javascript - console.log 在文档滚动到结束时不会触发
- php - 文件夹中的图像被删除,但图像路径在 PHP 中未更新为 null
- powershell - 如何获取 Hyper-V 主机最近一小时的 CPU 使用率?
- .net - 使 ClickOnce 完全信任应用程序“绿色”
- azure - UserSecretsId 阻止将 F# ASP.NET Core 应用程序部署到 Azure 应用程序服务
- cordova-plugins - Crodova vk 插件不起作用[无法从清单文件中读取包名]