sqoop 抽取 postgres 数据库的数据

时间:2020-11-23 19:34:14   收藏:0   阅读:43

1.下载驱动:
wget http://jdbc.postgresql.org/download/postgresql-9.2-1002.jdbc4.jar



2.放到sqoop的lib下
cp postgresql-9.2-1002.jdbc4.jar /opt/cloudera/parcels/CDH/lib/sqoop/lib/



3.测试
sqoop list-tables --connect jdbc:postgresql://xx.xx.xxx.xxx/tagdb --username postgresql --P  postgresql

 

4.进行抽数
sqoop import --connect "jdbc:postgresql://xx.xx.xxx.xxx:5432/postdb" --username="postgresql" --password="postgresql" --outdir /tmp/.sqoop/java/ -m 1 --hive-import --hive-overwrite --target-dir /user/temp/ --hive-table "table_test" --hive-partition-key "dt" --hive-partition-value "20200101" --query "select * from  table_test where 1=1 AND \$CONDITIONS" --hive-drop-import-delims  --fields-terminated-by "^" --lines-terminated-by "\n" --null-string "\\\N" --null-non-string "\\\N"

原文:https://www.cnblogs.com/hello-wei/p/14026087.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!