问题:
sqoop从postgresql拉数据,在执行到mapreduce时报错connection refused. check that the hostname and port are correct and that the postmaster is accepting tcp/ip connections
问题定位过程:
1、postgresql 5432端口已开放,执行任务的节点能telnet通,并且netcat测试通过
2、sqoop list-tables命令可正常执行,sqoop import报错connection refused. check that the hostname and port are correct and that the
3、从其它服务器集群跑同样脚本正常
解决:
集群中有node不能访问5432,sqoop import命令一定要集群中所有起nodemanager服务的节点有访问数据库端口的权限,所以保证所有节点访问5432后解决
备注:
sqoop list-tables能执行就说明肯定不是postgresql端的问题,sqoop list-tables执行命令的这台服务器能访问5432即可
补充:使用sqoop从postgresql向hive中迁移数据遇到的问题
postgresql的界面
跟mysql不同之处就是,多了一个 2 ,这也是导致数据迁移错误原因
1.数据库名称 2.schema 3.表名
postgresql中的对象属于三层模型,即database->schema->table。postgresql中一般包含多个database,每个database包含多个schema,schema下包含多个表。因此使用sqoop抽取数据时有时需要指定表是属于哪个schema。
解决方案:
在代码最后指定–schema
— –schema 上图2的名称
整个代码如下
./sqoop import --connect jdbc:postgresql://***.***.***.***:38888/bigdata --username test --password test123 --table tb_ecar_gps_zhengzhou_standard --fields-terminated-by 't' -m 1 --target-dir '/sqoop/postgresql123' -- --schema benchmark_data;
以上为个人经验,希望能给大家一个参考,也希望大家多多支持<计算机技术网(www.ctvol.com)!!>。如有错误或未考虑完全的地方,望不吝赐教。
需要了解更多数据库技术:解决sqoop从postgresql拉数据,报错TCP/IP连接的问题,都可以关注数据库技术分享栏目—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/dtteaching/632092.html