時間:2024-03-26 14:35作者:下載吧人氣:23
sqoop從postgresql拉數(shù)據(jù),在執(zhí)行到mapreduce時報錯Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
1、postgresql 5432端口已開放,執(zhí)行任務(wù)的節(jié)點能telnet通,并且netcat測試通過
2、sqoop list-tables命令可正常執(zhí)行,sqoop import報錯Connection refused. Check that the hostname and port are correct and that the
3、從其它服務(wù)器集群跑同樣腳本正常
集群中有node不能訪問5432,sqoop import命令一定要集群中所有起nodemanager服務(wù)的節(jié)點有訪問數(shù)據(jù)庫端口的權(quán)限,所以保證所有節(jié)點訪問5432后解決
備注:
sqoop list-tables能執(zhí)行就說明肯定不是postgresql端的問題,sqoop list-tables執(zhí)行命令的這臺服務(wù)器能訪問5432即可
補充:使用Sqoop從PostgreSQL向Hive中遷移數(shù)據(jù)遇到的問題
postgreSQL的界面
跟mysql不同之處就是,多了一個 2 ,這也是導(dǎo)致數(shù)據(jù)遷移錯誤原因
1.數(shù)據(jù)庫名稱 2.schema 3.表名
PostgreSQL中的對象屬于三層模型,即database->schema->table。PostgreSQL中一般包含多個database,每個database包含多個schema,schema下包含多個表。因此使用sqoop抽取數(shù)據(jù)時有時需要指定表是屬于哪個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;
網(wǎng)友評論