目录
百战程序员,全站22050+开发课程+文档 ,学习精选优质好课快人一步!观看视频 快捷键ALT+N

大数据全系列 教程

1869个小节阅读:467k

收藏
全部开发者教程

408考研

JAVA全系列 教程

面向对象的程序设计语言

Python全系列 教程

Python3.x版本,未来主流的版本

人工智能 教程

顺势而为,AI创新未来

大厂算法 教程

算法,程序员自我提升必经之路

C++ 教程

一门通用计算机编程语言

微服务 教程

目前业界流行的框架组合

web前端全系列 教程

通向WEB技术世界的钥匙

大数据全系列 教程

站在云端操控万千数据

AIGC全能工具班

A

A A

White Night

阅读(248)
赞(0)

10.5.5 导入到HIVE

Table 8. Hive arguments:

ArgumentDescription
--hive-home <dir>Override $HIVE_HOME
--hive-importImport tables into Hive (Uses Hive’s default delimiters if none are set.)
--hive-overwriteOverwrite existing data in the Hive table.
--create-hive-tableIf set, then the job will fail if the target hive
table exists. By default this property is false.
--hive-table <table-name>Sets the table name to use when importing to Hive.
--hive-drop-import-delimsDrops \n, \r, and \01 from string fields when importing to Hive.
--hive-delims-replacementReplace \n, \r, and \01 from string fields with user defined string when importing to Hive.
--hive-partition-keyName of a hive field to partition are sharded on
--hive-partition-value <v>String-value that serves as partition key for this imported into hive in this job.
--map-column-hive <map>Override default mapping from SQL type to Hive type for configured columns. If specify commas in this argument, use URL encoded keys and values, for example, use DECIMAL(1%2C%201) instead of DECIMAL(1, 1).

默认字段的分隔符就是^A,也就是\001,可以指定为逗号。

sqoop5.txt

node3启动hive server执行:

node3命令行:

执行后抛出以下异常信息:

ClassNotFoundException: org.apache.hadoop.hive.conf.HiveConf

解决办法:

将数据从mysql的表中取出后,放到hdfs上由--target-dir的指定目录/sqoop/hive/hive_browser_dim下,所有数据转移完成后,将hdfs上数据load到hive的表对应的目录下,将该目录删除。

node4上启动hive进行查看数据是否导入

注意:如果写成命令行的行,其中sql语句要使用单引号。

sqoop import --connect jdbc:mysql://node1/result_db --username root --password 123456 --as-textfile -m 1 -e 'select id, browser_name, browser_version from dimension_browser where $CONDITIONS and id<=20' --hive-import --create-hive-table --hive-table hive_browser_dim --target-dir /my/tmp --delete-target-dir --fields-terminated-by '\t'

北京市昌平区回龙观镇南店村综合商业楼2楼226室

©2014-2023 百战卓越(北京)科技有限公司 All Rights Reserved.

京ICP备14032124号-2