大数据全系列 教程
1869个小节阅读:464.7k
目录
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
https://sqoop.apache.org/docs/1.4.7/SqoopUserGuide.html#_literal_sqoop_export_literal
Syntax
xxxxxxxxxx
$ sqoop export (generic-args) (export-args)
$ sqoop-export (generic-args) (export-args)
Table 27. Common arguments
Argument | Description |
---|---|
--connect <jdbc-uri> | Specify JDBC connect string |
--connection-manager <class-name> | Specify connection manager class to use |
--driver <class-name> | Manually specify JDBC driver class to use |
--hadoop-mapred-home <dir> | Override $HADOOP_MAPRED_HOME |
--help | Print usage instructions |
--password-file | Set path for a file containing the authentication password |
-P | Read password from console |
--password <password> | Set authentication password |
--username <username> | Set authentication username |
--verbose | Print more information while working |
--connection-param-file <filename> | Optional properties file that provides connection parameters |
--relaxed-isolation | Set connection transaction isolation to read uncommitted for the mappers. |
Table 29. Export control arguments:
Argument | Description |
---|---|
--columns <col,col,col…> | Columns to export to table |
--direct | Use direct export fast path |
--export-dir <dir> | HDFS source path for the export |
-m,--num-mappers <n> | Use n map tasks to export in parallel |
--table <table-name> | Table to populate |
--call <stored-proc-name> | Stored Procedure to call |
--update-key <col-name> | Anchor column to use for updates. Use a comma separated list of columns if there are more than one column. |
--update-mode <mode> | Specify how updates are performed when new rows are found with non-matching keys in database. |
Legal values for mode include updateonly (default) and allowinsert . | |
--input-null-string <null-string> | The string to be interpreted as null for string columns |
--input-null-non-string <null-string> | The string to be interpreted as null for non-string columns |
--staging-table <staging-table-name> | The table in which data will be staged before being inserted into the destination table. |
--clear-staging-table | Indicates that any data present in the staging table can be deleted. |
--batch | Use batch mode for underlying statement execution. |
xxxxxxxxxx
[root@node3 ~]# vim sqoop6.txt
xxxxxxxxxx
export
--connect
jdbc:mysql://node1:3306/result_db
--username
root
--password
123456
-m
1
--table
hive_browser_dim
--columns
id,browser_name,browser_version
--export-dir
/user/hive_remote/warehouse/hive_browser_dim
xxxxxxxxxx
[root@node3 ~]# sqoop --options-file sqoop6.txt
ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'result_db.hive_browser_dim' doesn't exist
mysql中创建表
xxxxxxxxxx
create table `result_db`.`hive_browser_dim`(
`id` int ,
`browser_name` varchar(100) ,
`browser_version` varchar(100)
);
执行测试:
xxxxxxxxxx
[root@node3 ~]# sqoop --options-file sqoop6.txt
注意:由于文件使用,分割各个字段,sqoop导出的时候默认也是使用,分割。逗号不需要指定分隔符。