简体   繁体   English

shell 脚本中的 Hive SQL 在 oozie 中失败

[英]Hive SQL in shell script failing in oozie

i have an hive HQL that needs to be called in a Shell script.我有一个需要在 Shell 脚本中调用的 hive HQL。 it works fine when I execute the .Sh file in linux.当我在 linux 中执行 .Sh 文件时它工作正常。 But when I execute the same .sh in oozie, the hive part doesn't seem to work.但是当我在 oozie 中执行相同的 .sh 时,hive 部分似乎不起作用。 I am unable to see the error in yarn.我看不到纱线中的错误。

.sh file is as below .sh 文件如下

export UDR_START_DT=default.udr_lt_bc_$(date +"%Y%m%d" -d "yesterday")

echo "Start date : "$UDR_START_DT

hive -f /home/scripts/hive/tab_create.hql

the tab_create.hql is a below: tab_create.hql 如下:

CREATE TABLE default.san_tst
(
alt_rated_amount double ,
alt_rated_currency double ,
alt_tariff_clicks_volume double ,
alt_tmcode double ,
bill_display_ind string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ",";

note: the path of the .hql file is in linux and its not the HDFS path.注意:.hql 文件的路径在 linux 中,而不是 HDFS 路径。

Oozie takes a copy of this shell script and executes in any one of the node in your cluster. Oozie 获取此 shell 脚本的副本并在集群中的任何一个节点中执行。 So the hive path you are referring to might not be present in that node.因此,您所指的配置单元路径可能不存在于该节点中。

If it is single node cluster, make sure oozie user has access to that complete path or copy the hql file into your oozie workflow directory in hdfs.如果是单节点集群,请确保 oozie 用户可以访问该完整路径或将 hql 文件复制到 hdfs 中的 oozie 工作流目录中。

Add file into your shell action:将文件添加到您的 shell 操作中:

<file>oozie_workflow_dir/scripts/hive/tab_create.hql#tab_create.hql</file>

However, you dont need to use shell script to execute hql files.但是,您不需要使用 shell 脚本来执行 hql 文件。 Hive action is better and suggested to run hive scripts. Hive 操作更好,建议运行 hive 脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM