您现在的位置是:网站首页> 编程资料编程资料
解决sqoop从postgresql拉数据,报错TCP/IP连接的问题_PostgreSQL_
2023-05-27
540人已围观
简介 解决sqoop从postgresql拉数据,报错TCP/IP连接的问题_PostgreSQL_
问题:
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;
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。如有错误或未考虑完全的地方,望不吝赐教。
相关内容
- sqoop读取postgresql数据库表格导入到hdfs中的实现_PostgreSQL_
- 解决sqoop import 导入到hive后数据量变多的问题_PostgreSQL_
- sqoop 实现将postgresql表导入hive表_PostgreSQL_
- postgresql流复制原理以及流复制和逻辑复制的区别说明_PostgreSQL_
- PostgreSQL 流复制异步转同步的操作_PostgreSQL_
- Postgresql 检查数据库主从复制进度的操作_PostgreSQL_
- PostgreSQL流复制参数max_wal_senders的用法说明_PostgreSQL_
- 在postgresql数据库中创建只读用户的操作_PostgreSQL_
- postgresql中wal_level的三个参数用法说明_PostgreSQL_
- 启动PostgreSQL服务器 并用pgAdmin连接操作_PostgreSQL_
