Hue中使用Oozie创建Ssh工作流时sudo命令执行失败问题分析

时间:2022-05-06
本文章向大家介绍Hue中使用Oozie创建Ssh工作流时sudo命令执行失败问题分析,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看。 Fayson的github:https://github.com/fayson/cdhproject

1.问题描述


在使用Hue创建Ssh的Oozie工作流,在Shell脚本中执行sudo命令失败,异常如下:

测试shell脚本

#!/bin/bash

sudo mkdir /dfs/myshell

运行异常:

 Log Upload Time: Mon Dec 18 05:22:07 -0500 2017
          
            Log Length: 400
          
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified
Failing Oozie Launcher, Main class [org.apache.oozie.action.hadoop.ShellMain], exit code [1]

2.问题复现


1.使用Fayson用户登录Hue,创建一个Shell Workflow的工作流

2.将test.sh脚本上传至当前工作流的workspace/lib目录下

3.保存工作流,点击运行,作业执行失败

失败日志如下

3.问题解决


1.使用root用户修改/etc/sudoers文件,将fayson用户修改为拥有sudo权限的用户

在/etc/sudoers文件末尾增加如下配置

fayson          ALL=(ALL)       NOPASSWD: ALL

将配置文件中的如下信息注释

#
# Disable "ssh hostname sudo <cmd>", because it will show the password in clear. 
#         You have to run "ssh -t hostname sudo <cmd>".
#
#Defaults    requiretty

注意:这里需要集为群所有节点的fayson用户添加sudo权限。

2.再次运行作业

3.保存作业并执行

4.总结


  • 在Oozie的Ssh Action脚本中有需要使用Sudo权限去执行的命令,则需要为fayson用户添加Sudo权限,否则是无法执行Sudo命令的。
  • 在非Kerberos环境下如果需要切换不同的用户执行hadoop命令,可以使用exportHADOOP_USER_NAME=hive在Shell加载执行用户。

为天地立心,为生民立命,为往圣继绝学,为万世开太平。

温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看