sqoop导入数据到hive---2
1.hive-table
从mysql导入数据到hive表中,可以使用--hive-table来指定hive的表名,不指定hive表名,则hive表名与mysql表名保持一致。
- sqoop import --connect jdbc:mysql://localhost:3306/test --username root --password 123456 --table person --hive-import --fields-terminated-by '|' --lines-terminated-by "\n" -m 1 --hive-table person_mysql
hive中的表结构是:
- hive> show create table person_mysql;
- OK
- CREATE TABLE `person_mysql`(
- `id` int,
- `name` string)
- COMMENT 'Imported by sqoop on 2016/07/26 15:13:48'
- ROW FORMAT DELIMITED
- FIELDS TERMINATED BY '|'
- LINES TERMINATED BY '\n'
- STORED AS INPUTFORMAT
- 'org.apache.hadoop.mapred.TextInputFormat'
- OUTPUTFORMAT
- 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
- LOCATION
- 'hdfs://hadoop26:8020/user/hive/warehouse/person_mysql'
- TBLPROPERTIES (
- 'COLUMN_STATS_ACCURATE'='true',
- 'numFiles'='',
- 'totalSize'='',
- 'transient_lastDdlTime'='')
- Time taken: 0.21 seconds, Fetched: row(s)
2.create-hive-table工具
create-hive-table工具是依据mysql中的表定义在hive中创建一个表
- sqoop create-hive-table --connect jdbc:mysql://localhost:3306/test --username root --password 123456 --table person --hive-table person_mysql_222 fields-terminated-by '|'
只在hive中创建了表,没有把数据进行导入,所以hive表中是没有数据的:
- hive> select * from person_mysql_222;
- OK
- Time taken: 0.299 seconds
- hive> show create table person_mysql_222;
- OK
- CREATE TABLE `person_mysql_222`(
- `id` int,
- `name` string)
- COMMENT 'Imported by sqoop on 2016/07/26 15:22:14'
- ROW FORMAT DELIMITED
- FIELDS TERMINATED BY '|'
- LINES TERMINATED BY '\n'
- STORED AS INPUTFORMAT
- 'org.apache.hadoop.mapred.TextInputFormat'
- OUTPUTFORMAT
- 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
- LOCATION
- 'hdfs://hadoop26:8020/user/hive/warehouse/person_mysql_222'
- TBLPROPERTIES (
- 'transient_lastDdlTime'='')
- Time taken: 0.22 seconds, Fetched: row(s)
3.import-all-tables工具
将数据库中所有的表都导入到hive中
目前mysql中有person、sun两张表
- sqoop import-all-tables --connect jdbc:mysql://localhost:3306/test --username root --password 123456 --hive-import -m 1
这样在hive中也生成了两张表,分别是person和sun.
在这个语句中也可以指定hive-table来指定一个表名,这样多个表的数据就会导入到一个hive表中了。
- sqoop import-all-tables --connect jdbc:mysql://localhost:3306/test --username root --password 123456 -m 1 --hive-import --hive-table all_person
sqoop导入数据到hive---2的更多相关文章
- sqoop导入数据到hive
1.1hive-import参数 使用--hive-import就可以将数据导入到hive中,但是下面这个命令执行后会报错,报错信息如下: sqoop import --connect jdbc:my ...
- sqoop导入数据到hive中元数据问题
简单配置了sqoop之后开始使用,之前用的时候很好用,也不记得有没有启动hivemetastore,今天用的时候没有启动,结果导入数据时,如果使用了db.tablename,就会出现找不到数据库的错, ...
- sqoop导入数据到hive表中的相关操作
1.使用sqoop创建表并且指定对应的hive表中的字段的数据类型,同时指定该表的分区字段名称 sqoop create-hive-table --connect "jdbc:oracle: ...
- 使用Sqoop从MySQL导入数据到Hive和HBase 及近期感悟
使用Sqoop从MySQL导入数据到Hive和HBase 及近期感悟 Sqoop 大数据 Hive HBase ETL 使用Sqoop从MySQL导入数据到Hive和HBase 及近期感悟 基础环境 ...
- 使用sqoop从mysql导入数据到hive
目录 前言 一.使用的导入命令 二.遇到的问题及解决 1. 用文本字段进行分区的问题 2. Hadoop历史服务器Hadoop JobHistory没开启的问题 3. 连接元数据存储数据库报错 4 ...
- 教程 | 使用Sqoop从MySQL导入数据到Hive和HBase
基础环境 sqoop:sqoop-1.4.5+cdh5.3.6+78, hive:hive-0.13.1+cdh5.3.6+397, hbase:hbase-0.98.6+cdh5.3.6+115 S ...
- Sqoop导入关系数据库到Hive
参考:segmentfault.com:Sqoop导入关系数据库到Hive Sqoop 是 apache 下用于 RDBMS 和 HDFS 互相导数据的工具.本文以 mysql 数据库为例,实现关系数 ...
- 使用sqoop1.4.4从oracle导入数据到hive中错误记录及解决方案
在使用命令导数据过程中,出现如下错误 sqoop import --hive-import --connect jdbc:oracle:thin:@192.168.29.16:1521/testdb ...
- Sqoop导入数据到mysql数据库报错:ERROR tool.ExportTool: Error during export: Export job failed!(已解决)
问题描述: Container killed by the ApplicationMaster. Container killed on request. Exit code is 143 Conta ...
随机推荐
- HOST ip is not allowed to connect to this MySql server
报错:1130-host ... is not allowed to connect to this MySql server 解决方法: 1. 改表法. 可能是你的帐号不允许从远程登陆,只能在loc ...
- nyoj 56-阶乘因式分解(一)
点击打开链接 阶乘因式分解(一) 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 给定两个数m,n,其中m是一个素数. 将n(0<=n<=10000)的阶乘分 ...
- Contains DuplicateII
超时版: /*Contains Duplicate II Given an array of integers and an integer k, find out whether there the ...
- oracle分布式事务总结-转载
基本概念 Local Coordinator:在分布事务中,必须参考其它节点上的数据才能完成自己这部分操作的站点. Global Coordinator:分布事务的发起者,负责协调这个分布事务. Co ...
- openssl rsa 私钥 PKCS8私钥 公钥
上文配置好 openssl 运行 => cmd => cd C:\usr\local\ssl\bin => 执行 openssl
- fw: firefox plugin
http://blog.csdn.net/fancycow/article/details/7261191 firefox的插件分两种类型,一种extension,叫扩展,一种是plugin,我们叫插 ...
- android 操作sqlite的一点小技巧
1.android 在sqlite插入数据时,是非常耗时的操作,原因是sqlite缺省会为每个插入操作开启一个事务,当数量变多的时候,自然时间就变得很慢,这时候可以考虑在插入等操作时先开启一个事务,再 ...
- flex使用buttonbar为viewstack添加导航功能
先建立一个Main.mxml的应用程序,作为一个主程序,再建立两个component ,一个是jiaju.mxml ,另一个是dianqi.mxml. Main.mxml: <?xml ver ...
- Exercises - Kangaroo
Write a definition for a class named Kangaroo with the following methods: An __init__ method that in ...
- 处理程序“WebServiceHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”
开发web项目时需要安装IIS,在安装好IIS的Windows7本上发布asp.net网站时,web程序已经映射到了本地IIS上,但运行如下错误提示“处理程序“PageHandlerFactory-I ...