問(wèn)題:
sqoop從postgresql拉數(shù)據(jù),在執(zhí)行到mapreduce時(shí)報(bào)錯(cuò)Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
問(wèn)題定位過(guò)程:
1、postgresql 5432端口已開(kāi)放,執(zhí)行任務(wù)的節(jié)點(diǎn)能telnet通,并且netcat測(cè)試通過(guò)
2、sqoop list-tables命令可正常執(zhí)行,sqoop import報(bào)錯(cuò)Connection refused. Check that the hostname and port are correct and that the
3、從其它服務(wù)器集群跑同樣腳本正常
解決:
集群中有node不能訪問(wèn)5432,sqoop import命令一定要集群中所有起nodemanager服務(wù)的節(jié)點(diǎn)有訪問(wèn)數(shù)據(jù)庫(kù)端口的權(quán)限,所以保證所有節(jié)點(diǎn)訪問(wèn)5432后解決
備注:
sqoop list-tables能執(zhí)行就說(shuō)明肯定不是postgresql端的問(wèn)題,sqoop list-tables執(zhí)行命令的這臺(tái)服務(wù)器能訪問(wèn)5432即可
補(bǔ)充:使用Sqoop從PostgreSQL向Hive中遷移數(shù)據(jù)遇到的問(wèn)題
postgreSQL的界面

跟mysql不同之處就是,多了一個(gè) 2 ,這也是導(dǎo)致數(shù)據(jù)遷移錯(cuò)誤原因
1.數(shù)據(jù)庫(kù)名稱 2.schema 3.表名
PostgreSQL中的對(duì)象屬于三層模型,即database->schema->table。PostgreSQL中一般包含多個(gè)database,每個(gè)database包含多個(gè)schema,schema下包含多個(gè)表。因此使用sqoop抽取數(shù)據(jù)時(shí)有時(shí)需要指定表是屬于哪個(gè)schema。
解決方案:
在代碼最后指定--schema
-- --schema 上圖2的名稱
整個(gè)代碼如下
./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;
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。
您可能感興趣的文章:- 在Hadoop集群環(huán)境中為MySQL安裝配置Sqoop的教程
- sqoop export導(dǎo)出 map100% reduce0% 卡住的多種原因及解決
- sqoop讀取postgresql數(shù)據(jù)庫(kù)表格導(dǎo)入到hdfs中的實(shí)現(xiàn)
- 解決sqoop import 導(dǎo)入到hive后數(shù)據(jù)量變多的問(wèn)題
- sqoop 實(shí)現(xiàn)將postgresql表導(dǎo)入hive表
- 使用shell腳本執(zhí)行hive、sqoop命令的方法
- Sqoop的安裝與使用詳細(xì)教程