问题:
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;
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。如有毛病或未斟酌完全的地方,望不吝赐教。
本文来源:https://www.yuntue.com/post/235293.html | 云服务器网,转载请注明出处!