详细信息:
Sqoop 1.4.6
已尝试的密码文件位于HDFS和本地FS中。还尝试将密码文件声明为--password-file file:///user/username/password.file。
sqoop import \
--connect 'jdbc:sqlserver://servername;database=databasename' \
--username userxxx \
--password-file password.file \
--table 'sales' \
--fields-terminated-by '|' \
--null-string '\\N' \
--null-non-string '\\N' \
--hive-import在运行sqoop导入时,除非我将用户名和密码放在连接字符串中,否则将从sql server获得身份验证失败。如果我尝试使用-P或--密码文件,身份验证将失败。
发布于 2017-06-11 06:14:30
--password-file
根据文档的说法,
向数据库提供密码的安全方法。您应该用400个权限将密码保存在用户主目录上的一个文件中,并使用-- password -file参数指定该文件的路径,这是输入凭据的首选方法。然后,Sqoop将从文件中读取密码,并使用安全方法将其传递给MapReduce集群,而不会在作业配置中公开密码。包含密码的文件可以位于本地FS或HDFS上。
检查文件的权限,它应该在主目录中。
Sqoop期望HDFS中的--password-file,如果您使用本地FS添加file://。
示例:--password-file file:///user/dev/database.password
-P option
它将从控制台读取密码。使用此命令时,必须在执行命令时写入密码。
password
只需添加你的密码。
发布于 2018-02-20 12:37:14
还有一种更好的方法。使用expect脚本。
创建一个脚本文件,如"script.sh“:
#!/usr/bin/expect -f
set password "<ur password desination or file>"
spawn sqoop <args> # define sqoop command here
expect "*?Enter password:*" # As ask for password as while reading from database
send -- "$password\r"
expect sleep 15 # or you can use "set timeout -1" for infinite waiting time
expect eof
EOF
done如果您遇到错误,生成命令不存在等等,这意味着expect没有安装。
对于centos7
yum install expect -y并运行文件"script.sh“
如果expect脚本无法加载
试着:
> /usr/bin/expect script.sh谢谢
https://stackoverflow.com/questions/44474949
复制相似问题