如何通过OOZIE为SQOOP提供密码以连接到MS-SQL? [英] how can i provide password to SQOOP through OOZIE to connect to MS-SQL?

查看:161
本文介绍了如何通过OOZIE为SQOOP提供密码以连接到MS-SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQOOP将信息从HDFS导出到MS-SQL.我正在通过OOZIE运行SQOOP.现在,我已经为OOZIE工作流程中的jdbc连接对uid(即pwd)进行了硬编码.切换到产品后,我将无法执行此操作.在这种情况下传递身份验证信息的最佳方法是什么?

I'm exporting information from HDFS into MS-SQL using SQOOP. I'm running SQOOP through OOZIE. Right now I've hard-coded the uid, pwd for the jdbc connection in the OOZIE workflow. Once I switch to prod I won't be able to do this. What is the best way to pass authentication information in a situation like this?

<sqoop xmlns="uri:oozie:sqoop-action:0.2">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <arg>export</arg>
            <arg>--connect</arg>
            <arg>jdbc:sqlserver://$sqlServerIP:1433</arg>
            <arg>--table</arg>
            <arg>tableName</arg>
            <arg>--export-dir</arg>
            <arg>/user/sqoop/file</arg>
            <arg>--username</arg>
            <arg>me</arg>
            <arg>--password</arg>
            <arg>password</arg>
</sqoop>

我可以将它们作为$ userName,$ password之类的参数传递.但是实际的uid/pwd仍会显示在oozie Web控制台中.

I could pass them in as parameters like $userName, $password. But the actual uid/pwd would still show in the oozie web console.

更新

我已经尝试了两种方法(如下所示)……在VIM中,我创建了pwd仅具有密码(没有空格或其他任何东西).叫做这个pwd.

I've tried two ways (as suggested bellow) to do this...In VIM I created pwd to just have the password (no white spaces or anything else). Called this pwd.

1)我尝试使用文件系统.但是我得到一个IOException,说该文件不存在.看完代码后,squip似乎使用传递的conf来访问fs.因此,我假设当通过oozie运行时,它只能访问HDFS.

1)I tried using the file system. However I got an IOException saying that the file doesn't exist. After looking through the code, It looks like sqoop uses passed conf to access the fs. So I'm assuming when ran through oozie it will have only access to HDFS.

2)我将密码文件加载到hdfs上的随机位置. /users/我的名字/pwd(pwd是文件).现在它可以访问文件了(因为我没有得到IOException).但是,它无法连接到SQLServer.我不确定要使其正常工作需要做什么?

2)I loaded the password file into a random location on hdfs. /users/my-name/pwd (pwd is the file). Now it can access the file (since I don't get an IOException). However it fails to connect to SQLServer. I'm not sure what I need to do to get it to work?

更新2 我正在这样创建密码文件:echo "pwd" > my.password 这会将EOL添加到文件my.password中 我更改为echo -n "pwd" > my.password,现在可以使用了.

UPDATE 2 I was creating the password file like so: echo "pwd" > my.password This adds an EOL to the file my.password I changed to echo -n "pwd" > my.password and now it works.

推荐答案

我认为您可以利用指定--password-file参数的优势,这样Oozie永远不会看到密码.请参阅《 Sqoop用户指南》 以了解更多详细信息.

I think that you can take advantage of specifying --password-file argument, so that Oozie will never see the password. Take a look into the Sqoop User Guide for more details.

这篇关于如何通过OOZIE为SQOOP提供密码以连接到MS-SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆