使用 sqoop 将mysql数据导入到hive表(import)
Sqoop将mysql数据导入到hive表中
先在mysql创建表
CREATE TABLE `sqoop_test` (
`id` int() DEFAULT NULL,
`name` varchar() DEFAULT NULL,
`age` int() DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
插入数据
fz
dx
test
test_add
test_add-
test_add_2
在hive中创建表,表结构和mysql中一样
hive> create external table sqoop_test_table(id int,name string,age int)
> ROW FORMAT DELIMITED
> FIELDS TERMINATED BY ','
> STORED AS TEXTFILE;
OK
Time taken: 0.083 seconds
开始导入
sqoop import --connect jdbc:mysql://localhost:3306/sqooptest --username root --password 123qwe --table sqoop_test
--hive-import --hive-overwrite --hive-table sqoop_test_table --fields-terminated-by ',' -m 1
EFdeMacBook-Pro:jarfile FengZhen$ sqoop import --connect jdbc:mysql://localhost:3306/sqooptest --username root --password 123qwe --table sqoop_test --hive-import --hive-overwrite --hive-table sqoop_test_table --fields-terminated-by ',' -m 1
Warning: /Users/FengZhen/Desktop/Hadoop/sqoop-1.4..bin__hadoop-2.0.-alpha/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /Users/FengZhen/Desktop/Hadoop/sqoop-1.4..bin__hadoop-2.0.-alpha/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/FengZhen/Desktop/Hadoop/hadoop-2.8./share/hadoop/common/lib/slf4j-log4j12-1.7..jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/FengZhen/Desktop/Hadoop/hbase-1.3./lib/slf4j-log4j12-1.7..jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
// :: INFO sqoop.Sqoop: Running Sqoop version: 1.4.
// :: WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
// :: INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
// :: INFO tool.CodeGenTool: Beginning code generation
// :: INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `sqoop_test` AS t LIMIT
// :: INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `sqoop_test` AS t LIMIT
// :: INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /Users/FengZhen/Desktop/Hadoop/hadoop-2.8.
// :: INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-FengZhen/compile/241f28a04b0ece18cd4a07bd6939d50a/sqoop_test.jar
// :: WARN manager.MySQLManager: It looks like you are importing from mysql.
// :: WARN manager.MySQLManager: This transfer can be faster! Use the --direct
// :: WARN manager.MySQLManager: option to exercise a MySQL-specific fast path.
// :: INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql)
// :: INFO mapreduce.ImportJobBase: Beginning import of sqoop_test
// :: INFO Configuration.deprecation: mapred.job.tracker is deprecated. Instead, use mapreduce.jobtracker.address
// :: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
// :: INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar
// :: INFO Configuration.deprecation: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps
// :: INFO client.RMProxy: Connecting to ResourceManager at localhost/127.0.0.1:
// :: INFO db.DBInputFormat: Using read commited transaction isolation
// :: INFO mapreduce.JobSubmitter: number of splits:
// :: INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1505439184374_0001
// :: INFO impl.YarnClientImpl: Submitted application application_1505439184374_0001
// :: INFO mapreduce.Job: The url to track the job: http://192.168.1.64:8088/proxy/application_1505439184374_0001/
// :: INFO mapreduce.Job: Running job: job_1505439184374_0001
// :: INFO mapreduce.Job: Job job_1505439184374_0001 running in uber mode : false
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: Job job_1505439184374_0001 completed successfully
// :: INFO mapreduce.Job: Counters:
File System Counters
FILE: Number of bytes read=
FILE: Number of bytes written=
FILE: Number of read operations=
FILE: Number of large read operations=
FILE: Number of write operations=
HDFS: Number of bytes read=
HDFS: Number of bytes written=
HDFS: Number of read operations=
HDFS: Number of large read operations=
HDFS: Number of write operations=
Job Counters
Launched map tasks=
Other local map tasks=
Total time spent by all maps in occupied slots (ms)=
Total time spent by all reduces in occupied slots (ms)=
Total time spent by all map tasks (ms)=
Total vcore-milliseconds taken by all map tasks=
Total megabyte-milliseconds taken by all map tasks=
Map-Reduce Framework
Map input records=
Map output records=
Input split bytes=
Spilled Records=
Failed Shuffles=
Merged Map outputs=
GC time elapsed (ms)=
CPU time spent (ms)=
Physical memory (bytes) snapshot=
Virtual memory (bytes) snapshot=
Total committed heap usage (bytes)=
File Input Format Counters
Bytes Read=
File Output Format Counters
Bytes Written=
// :: INFO mapreduce.ImportJobBase: Transferred bytes in 22.0614 seconds (3.2636 bytes/sec)
// :: INFO mapreduce.ImportJobBase: Retrieved records.
// :: INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `sqoop_test` AS t LIMIT
// :: INFO hive.HiveImport: Loading uploaded data into Hive
// :: INFO hive.HiveImport: SLF4J: Class path contains multiple SLF4J bindings.
// :: INFO hive.HiveImport: SLF4J: Found binding in [jar:file:/Users/FengZhen/Desktop/Hadoop/hadoop-2.8./share/hadoop/common/lib/slf4j-log4j12-1.7..jar!/org/slf4j/impl/StaticLoggerBinder.class]
// :: INFO hive.HiveImport: SLF4J: Found binding in [jar:file:/Users/FengZhen/Desktop/Hadoop/hbase-1.3./lib/slf4j-log4j12-1.7..jar!/org/slf4j/impl/StaticLoggerBinder.class]
// :: INFO hive.HiveImport: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
// :: INFO hive.HiveImport: SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
// :: INFO hive.HiveImport: // :: WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
// :: INFO hive.HiveImport:
// :: INFO hive.HiveImport: Logging initialized using configuration in file:/Users/FengZhen/Desktop/Hadoop/hive/apache-hive-1.2.-bin/conf/hive-log4j.properties
// :: INFO hive.HiveImport: OK
// :: INFO hive.HiveImport: Time taken: 1.502 seconds
// :: INFO hive.HiveImport: Loading data to table default.sqoop_test_table
// :: INFO hive.HiveImport: Table default.sqoop_test_table stats: [numFiles=, numRows=, totalSize=, rawDataSize=]
// :: INFO hive.HiveImport: OK
// :: INFO hive.HiveImport: Time taken: 0.762 seconds
// :: INFO hive.HiveImport: Hive import complete.
// :: INFO hive.HiveImport: Export directory is contains the _SUCCESS file only, removing the directory.
导入成功后,会在hdfs中产生数据文件
在路径 /user/hive/warehouse/sqoop_test_table 下
EFdeMacBook-Pro:jarfile FengZhen$ hadoop fs -ls /user/hive/warehouse/sqoop_test_table
Found items
-rwxr-xr-x FengZhen supergroup -- : /user/hive/warehouse/sqoop_test_table/part-m- EFdeMacBook-Pro:jarfile FengZhen$ hadoop fs -text /user/hive/warehouse/sqoop_test_table/part-m-
,fz,
,dx,
,test,
,test_add,
,test_add-,
,test_add_2,
hive中查看表数据
hive> select * from sqoop_test_table;
OK
fz
dx
test
test_add
test_add-
test_add_2
Time taken: 0.507 seconds, Fetched: row(s)
完成。
使用 sqoop 将mysql数据导入到hive表(import)的更多相关文章
- 使用 sqoop 将mysql数据导入到hdfs(import)
Sqoop 将mysql 数据导入到hdfs(import) 1.创建mysql表 CREATE TABLE `sqoop_test` ( `id` ) DEFAULT NULL, `name` va ...
- 使用sqoop将mysql数据导入到hive中
首先准备工具环境:hadoop2.7+mysql5.7+sqoop1.4+hive3.1 准备一张数据库表: 接下来就可以操作了... 一.将MySQL数据导入到hdfs 首先我测试将zhaopin表 ...
- 使用sqoop把mysql数据导入hive
使用sqoop把mysql数据导入hive export HADOOP_COMMON_HOME=/hadoop export HADOOP_MAPRED_HOME=/hadoop cp /hive ...
- Sqoop将mysql数据导入hbase的血与泪
Sqoop将mysql数据导入hbase的血与泪(整整搞了大半天) 版权声明:本文为yunshuxueyuan原创文章.如需转载请标明出处: https://my.oschina.net/yunsh ...
- python脚本 用sqoop把mysql数据导入hive
转:https://blog.csdn.net/wulantian/article/details/53064123 用python把mysql数据库的数据导入到hive中,该过程主要是通过pytho ...
- 用sqoop将mysql的数据导入到hive表中
1:先将mysql一张表的数据用sqoop导入到hdfs中 准备一张表 需求 将 bbs_product 表中的前100条数据导 导出来 只要id brand_id和 name 这3个字段 数据存 ...
- 11.把文本文件的数据导入到Hive表中
先在hive里面创建一个表 create table mydb2.t3(id int,name string,age int) row format delimited fields terminat ...
- sqoop将mysql数据导入hbase、hive的常见异常处理
原创不易,如需转载,请注明出处https://www.cnblogs.com/baixianlong/p/10700700.html,否则将追究法律责任!!! 一.需求: 1.将以下这张表(test_ ...
- 使用sqoop将mysql数据导入到hadoop
hadoop的安装配置这里就不讲了. Sqoop的安装也很简单. 完成sqoop的安装后,可以这样测试是否可以连接到mysql(注意:mysql的jar包要放到 SQOOP_HOME/lib 下): ...
随机推荐
- Angular Material表单提交及验证
AngularJS中一些表单验证属性: 修改过的表单,只要用户修改过表单,无论输入是否通过验证,该值都将返回false{formName}.{inputFieldName}.$dirty 合法的表单, ...
- 启动 ./spark-shell 命令报错
当使用./spark-shell 命令报错 Caused by: ERROR XJ040: Failed to start database @476fde05, see the next excep ...
- [Java]事件驱动程序设计
事件驱动模型三大要素 1)事件源:能接收外部事件的源体: 2)监听器xListener:能接收事件源通知的对象: 3)处理器Handler:用于处理事件的对象. 在Java中使用监听器对象处理事件的方 ...
- linux把某个文件拷贝到不同的目录下面
find -name '7*' -type d|xargs -n 1 cp PBClassname.properties
- MHA安装配置
1. 前言 MHA可以在较短的时间内实现自己主动故障检測和故障转移,通常在10-30秒以内;在复制框架中,MHA可以非常好地解决复制过程中的数据一致性问题,因为不须要在现有的replication中加 ...
- MySQL视图概述
1.介绍 在传统关系型数据库里,视图有时也被称作虚表,是基于特定SQL结果集的虚拟数据表.在有些场合会变得很方便,例如:原有系统重构,旧的数据表A和B已经被拆分和合并到数据表C.D.F里面,为了实现平 ...
- DAO调用存储过程问题
相关文章:1.使用 Spring 框架调用 DB2 存储过程 2.Spring如何使用JdbcTemplate调用存储过程的三种情况 3.spring中调用存储过程,函数
- lnmp 环境require(): open_basedir restriction in effect 错误
最近配置开发用的lnmp环境,环境配置完成后,爆500错误,查看nginx错误日志 open_basedir 将 PHP 所能打开的文件限制在指定的目录树,包括文件本身 错误日志显示,访问脚本不在 o ...
- dynamic与var
dynamic与var示例 var是一种语法省略写法,编译器会根据上下文推断出正确的类型. , , , , , , , }; foreach (var item in scores) { Consol ...
- 如何使CSS--better(系列一)
我们想一下以下问题: 1.什么样子的css代码才是高效的? 2.什么样子的css代码才是便于维护的? 3.什么样子的css才是可扩展的? 带着以下问题咱们简单的说一下css的“性能”问题 虽然我技术不 ...