时间:2024-03-26 14:35作者:下载吧人气:29
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;
网友评论