sqoop資料匯入匯出
sqoop: 1.配置 配置conf/sqoop-env-templete.sh,修改 HADOOP_COMMON_HOME、HADOOP_MAPRED_HOME、HIVE_HOME、HBASE_HOME 複製相應的jdbc驅動:例如,如果是mysql,則將mysqljdbc驅動複製到lib/ 也可以直接配置HADOOP_HOME 這樣 會根據hadoop_home尋找 HADOOP_COMMON_HOME、HADOOP_MAPRED_HOME 2.import匯出資料到hdfs ./sqoop import --connect jdbc:mysql://192.168.249.133:3306/test --username root --password 123456 --table test --input-fields-terminated-by ',' --lines-terminated-by '\n' --warehouse-dir /sqoop -m 1 透過select語句指定特定的輸出目錄: ./sqoop import --connect jdbc:mysql://192.168.249.133:3306/test --username root --password 123456 --input-fields-terminated-by ',' --lines-terminated-by '\n' --target-dir /sqoop/test1 --query 'select *from test where id>2 and $CONDITIONS ;' -m 1 透過where指定查詢條件: ./sqoop import --connect jdbc:mysql://192.168.249.133:3306/test --username root --password 123456 --input-fields-terminated-by ',' --lines-terminated-by '\n' --target-dir /sqoop/test2 --table test --where 'id<=3' -m 1 3.匯出資料到hive(不用建表,自動生成目標表) 自動生成目標表 ./sqoop import --connect jdbc:mysql://192.168.249.133:3306/test --username root --password 123456 --hive-import --hive-database test --create-hive-table --input-fields-terminated-by ',' --lines-terminated-by '\n' --table test --where 'id<=3' -m 1 1.這個時候可能會報錯:Could not load org.apache.hadoop.hive.conf.HiveConf. 將hive lib/*新增到HADOOP_CLASSPATH 下 2.main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register") 解決方法: Just add the following lines to your java.policy file unter <JRE_HOME>/lib/security. grant { // JMX Java Management eXtensions permission javax.management.MBeanTrustPermission "register"; }; ./sqoop import --connect jdbc:mysql://192.168.249.133:3306/test --username root --password 123456 --hive-import --hive-database test --input-fields-terminated-by ',' --lines-terminated-by '\n' --table test --where 'id<=3' -m 1 注:split-by id maptask根據id分片 與-m 相關 增量匯入: ./sqoop import --connect jdbc:mysql://192.168.249.133:3306/test --username root --password 123456 --hive-import --hive-database test --input-fields-terminated-by ',' --lines-terminated-by '\n' --incremental append --check-column id --last-value 3 --table test -m 1 3.export從hdfs匯出資料 ./sqoop export --connect jdbc:mysql://192.168.249.133:3306/test --username root --password 123456 --export-dir /user/hive/warehouse/test.db/test --table test --fields-terminated-by ',' --lines-terminated-by '\n'
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31506529/viewspace-2213877/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- sqoop用法之mysql與hive資料匯入匯出OOPMySqlHive
- sqoop部署及匯入與匯出OOP
- sqoop定時增量匯入匯出OOP
- 資料搬運元件:基於Sqoop管理資料匯入和匯出元件OOP
- 資料泵匯出匯入
- Oracle 資料匯入匯出Oracle
- mysql資料匯入匯出MySql
- mysql資料匯出匯入MySql
- oracle資料匯入匯出Oracle
- Sqoop匯入資料異常處理OOP
- 資料庫 MySQL 資料匯入匯出資料庫MySql
- 資料匯入匯出EXP/IMP
- MongoDB資料匯入與匯出MongoDB
- mysqldump匯入匯出表資料MySql
- exp/imp匯出匯入資料
- postgresql 資料匯入和匯出SQL
- 資料庫的匯入匯出資料庫
- 資料泵的匯入匯出
- mysql 資料庫匯入匯出MySql資料庫
- 資料泵匯出匯入表
- MySQL資料庫匯入匯出MySql資料庫
- Oracle資料庫匯入匯出。imp匯入命令和exp匯出命令Oracle資料庫
- Sqoop匯出ClickHouse資料到HiveOOPHive
- MySQL入門--匯出和匯入資料MySql
- Sqoop將MySQL資料匯入到hive中OOPMySqlHive
- hadoop匯入資料工具sqoop介紹Hadoop
- Mongodb資料的匯出與匯入MongoDB
- EasyPoi, Excel資料的匯入匯出Excel
- 匯入和匯出AWR的資料
- oracle資料匯出匯入(exp/imp)Oracle
- 【mysql】資料庫匯出和匯入MySql資料庫
- Oracle資料泵-schema匯入匯出Oracle
- BCP 資料的匯入和匯出
- mysql匯入匯出.csv格式資料MySql
- db2匯入匯出資料DB2
- mysqldump匯入匯出mysql資料庫MySql資料庫
- MySQL表資料匯入與匯出MySql
- AWR資料的匯出與匯入