問題:
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;
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。
您可能感興趣的文章:- 在Hadoop集群環境中為MySQL安裝配置Sqoop的教程
- sqoop export導出 map100% reduce0% 卡住的多種原因及解決
- sqoop讀取postgresql數據庫表格導入到hdfs中的實現
- 解決sqoop import 導入到hive后數據量變多的問題
- sqoop 實現將postgresql表導入hive表
- 使用shell腳本執行hive、sqoop命令的方法
- Sqoop的安裝與使用詳細教程