使用sqoop把mysql数据导入hive
使用sqoop把mysql数据导入hive
export HADOOP_COMMON_HOME=/hadoop |
share表第一列为自增主键 share_id,share_id<1000的数据共有999条:
mysql> SELECT COUNT(*) FROM share WHERE share_id<1000; |
使用sqoop导入到hive
[hduser@www lib]$ /sqoop/bin/sqoop import --connect jdbc:mysql://localhost/shipincon --table share --username root --password xxx --hive-import --where "share_id<1000" -- --default-character-set=utf8 |
去hive中看看数据:
[hduser@www lib]$ /hive/bin/hive |
再去dfs里面看看:
[hduser@www lib]$ /hadoop/bin/hadoop dfs -ls /user/hive/warehouse2/share |
乍一看,像是4个partition。 可是细看文件名,并不是partition的那种结构:
比如:/user/hive/warehouse2/cm/country_name=VN_en
把文件复制到本地:
/hadoop/bin/hadoop dfs -get /user/hive/warehouse2/share ~/ |
–hive-overwrite 可以覆盖hive中的现有数据。
–hive-table
Sets the table name to use when importing to Hive.
可以把数据import到某个分区中:
–hive-partition-key Name of a hive field to partition are sharded on
–hive-partition-value String-value that serves as partition key for this imported into hive in this job.
可以写个cron,周期性地把share表的新增数据导入到hive中了: –append
参考:
http://sqoop.apache.org/docs/1.4.3/SqoopUserGuide.html
http://www.mysqlperformanceblog.com/2013/07/11/mysql-and-hadoop/
使用sqoop把mysql数据导入hive的更多相关文章
- python脚本 用sqoop把mysql数据导入hive
转:https://blog.csdn.net/wulantian/article/details/53064123 用python把mysql数据库的数据导入到hive中,该过程主要是通过pytho ...
- 使用 sqoop 将mysql数据导入到hive表(import)
Sqoop将mysql数据导入到hive表中 先在mysql创建表 CREATE TABLE `sqoop_test` ( `id` ) DEFAULT NULL, `name` varchar() ...
- 使用sqoop将mysql数据导入到hive中
首先准备工具环境:hadoop2.7+mysql5.7+sqoop1.4+hive3.1 准备一张数据库表: 接下来就可以操作了... 一.将MySQL数据导入到hdfs 首先我测试将zhaopin表 ...
- Sqoop将mysql数据导入hbase的血与泪
Sqoop将mysql数据导入hbase的血与泪(整整搞了大半天) 版权声明:本文为yunshuxueyuan原创文章.如需转载请标明出处: https://my.oschina.net/yunsh ...
- 使用 sqoop 将mysql数据导入到hdfs(import)
Sqoop 将mysql 数据导入到hdfs(import) 1.创建mysql表 CREATE TABLE `sqoop_test` ( `id` ) DEFAULT NULL, `name` va ...
- 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 下): ...
- 使用sqoop将mysql中表导入hive中报错
[hdfs@node1 root]$ sqoop import --connect jdbc:mysql://node2:3306/cm?charset-utf8 --username root -- ...
- sqoop导出mysql数据进入hive错误
看mr的运行显示:sqoop job可以获得的select max(xxx)结果,但是当mr开始时却显示大片错误,就是连接超时,和连接重置等问题, 最后去每个节点ping mysql的ip地址,发现 ...
随机推荐
- 与时间有关的类Date,DateFormat,Calendar
Date类用于表示日期和时间.它没考虑国际化问题,所以又设计了另外两个类. Calendar类: 主要是进行日期字段之间的相互操作. 编程实例:计算出距当前日期时间315天后的日期时间,并使用”xxx ...
- XMLRPC 学习笔记(一)- Python 实现
参考文章: http://baike.baidu.com/view/643379.htm http://docs.python.org/2/library/xmlrpclib.html http:// ...
- MFC多国语言——资源DLL
此随笔中主要内容来自http://blog.csdn.net/china_hxx/article/details/10066655,原出处不详. 以下内容基于VC 6.0.要实现界面多语言化,必须要先 ...
- 华为OJ平台试题 —— 数组:输入n个整数,输出当中最小的k个
输入n个整数.输出当中最小的k个: 代码: /* * 输入n个整数,输出当中最小的k个. * 输入说明:1.输入两个整数:2.输入一个整数数组 * 输出说明:输出一个整数数组 */ <p ...
- UE问题分部解决
0.寻找Actor ALandscape *land=nullptr; for (TActorIterator<ALandscape> It(GEditor->GetEditorWo ...
- 手动编译svn
#!/bin/bash yum -y remove subversionmkdir -p /dist/{dist,src}cd /dist/dist/bin/rm -f openssl* subver ...
- laragon 使用(php版本升级切换)
php版本升级切换 1.下载对应不带 nts 的php版本(http://windows.php.net/download/),然后解压放到\laragon\bin\php目录下 2.记得改环境变量下 ...
- poj3414
Pots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13545 Accepted: 5717 Special J ...
- vs2017 git 操作重置、还原、挑拣对比
工具 :vs2017 git 操作 背景:本地与远程分支同步 操作:还原.挑拣.重置--hard .重置--mixed 分支:本地1.本地2.origin\本地1 基本操作 1:分支:本地2-ad ...
- VS2013\VS2017 使用git 总是需要输入账号密码
问题: VS2013\VS2017 使用git 总是需要输入账号密码 解决方案:删除原凭证,或者修改原凭证,重新输入一次账号和密码并且选择“记住凭证”即可!