Sqoop导入到Hive,Hive使用 HA

Sqoop写入Hive卡在连接Hive的JDBC上不执行

Sqoop访问 启用 HA模式的Hive

找到Hive的安装根目录:$HIVE_HOME/conf

创建一个新的配置文件:beeline-hs2-connection.xml

复制代码
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
 <name>beeline.hs2.connection.user</name>
 <value>hive</value>
</property>
<property>
 <name>beeline.hs2.connection.password</name>
 <value>hive</value>
</property>
</configuration>

beeline.hs2.connection.user:指定Hive访问的用户名

beeline.hs2.connection.password:当前用户名对应的访问密码

重新执行后发现会有新的报错信息:

报错信息

复制代码
23/11/02 13:57:23 INFO hive.HiveImport: Error: Error while compiling statement: FAILED: SemanticException Unable to load data to destination table. Error: The file that you are trying to load does not match the file format of the destination table. (state=42000,code=40000)
23/11/02 13:57:23 INFO hive.HiveImport: Closing: 0: jdbc:hive2://hdp3.node1:2181,hdp3.node2:2181,hdp3.node3:2181/default;password=hive;serviceDiscoveryMode=zooKeeper;user=hive;zooKeeperNamespace=hiveserver2
23/11/02 13:57:23 ERROR tool.ImportTool: Import failed: java.io.IOException: Hive exited with status 2
	at org.apache.sqoop.hive.HiveImport.executeExternalHiveScript(HiveImport.java:253)
	at org.apache.sqoop.hive.HiveImport.importTable(HiveImport.java:206)
	at org.apache.sqoop.hive.HiveImport.importTable(HiveImport.java:273)
	at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:564)
	at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:655)
	at org.apache.sqoop.Sqoop.run(Sqoop.java:151)
	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:82)
	at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:187)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:241)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:250)
	at org.apache.sqoop.Sqoop.main(Sqoop.java:259)

解决办法:

1-新建一个存储格式为textfile的临时表

复制代码
create table hive_db.hive_01( id string comment 'Id') 
row format delimited fields terminated by '\001' 
stored as textFile;

2-将数据导入临时表中(Sqoop执行的Import写入到临时表中)

3-通过查询插入的方式将临时表数据导入目标表

复制代码
insert into hive_db.hive_table select * from hive_db.hive_01
相关推荐
王小王-12343 分钟前
基于Hadoop的用户购物行为可视化分析系统设计与实现
大数据·hadoop·分布式·用户购物行为·电商日志分析
爱吃面的猫18 小时前
大数据Hadoop之——Flink1.17.0安装与使用(非常详细)
大数据·hadoop·分布式
Edingbrugh.南空1 天前
Hadoop MapReduce 入门
大数据·hadoop·mapreduce
大数据CLUB2 天前
基于spark的奥运会奖牌变化数据分析
大数据·hadoop·数据分析·spark
Edingbrugh.南空2 天前
Hadoop高可用集群搭建
大数据·hadoop·分布式
无级程序员3 天前
hive2服务启动报错:/tmp/hive on HDFS should be writable(不是chmod 777能解决的)
hive·hadoop·hdfs
rui锐rui3 天前
大数据学习2:HIve
大数据·hive·学习
凌辰揽月3 天前
Servlet学习
hive·学习·servlet
weixin_307779134 天前
Hive集群之间迁移的Linux Shell脚本
大数据·linux·hive·bash·迁移学习
王小王-1234 天前
基于Hadoop的公共自行车数据分布式存储和计算平台的设计与实现
大数据·hive·hadoop·分布式·hadoop公共自行车·共享单车大数据分析·hadoop共享单车