从PHP服务器执行hadoop jar失败。没有权限 [英] Execute hadoop jar from PHP Server fails. Permission denied
问题描述
我试图执行一个jar文件,在PHP服务器上对我的HBase数据库进行简单的查询,因此我可以将结果打印到网页上。
PHP服务器配置为与hadoop用户相同的用户名,也是同一组。
PHP执行命令是:
exec(bash / usr / local / hadoop / bin / hadoop jar myjar.jar my.package.MyClass 2> php_error.log,$ result);
当我尝试执行命令时(在php_error.log中),我得到这个异常:
线程main中的异常java.io.IOException:Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native方法)
在java.io.File.createTempFile(File.java:1879)
在org.apache.hadoop.util.RunJar.main(RunJar.java:115)
我知道它与权限有关,但即使我的HDFS上有777和hadoop安装文件夹,它也不起作用。 p>
有什么想法?谢谢。
另外,这个临时文件想要创建的位置?
Hadoop dir? HDFS?在哪里?
编辑:
在本地运行,它完美的工作!没有权限错误!
hadoop jar myjar.jar my.package.MyClass
你的PHP没问题。问题是,您正在运行的命令是试图将文件复制到hadoop.tmp.dir。它的默认位置是 / tmp / hadoop - $ {user.name}
。您必须将> 文件夹的权限也递归给 / tmp / hadoop 目录
编辑:
发现apache在这种情况下不是合法用户。解决方案是创建一个新用户,将其添加到hadoop组,将权限设置为jar以及hadoop.tmp.dir,并将网页所有者更改为创建的用户。
I am trying to execute a jar file to do a simple query on my HBase database, from a PHP Server, so i can print the results to a webpage.
PHP Server in configured with same username as hadoop user, and same group too.
The PHP exec command is:
exec("bash /usr/local/hadoop/bin/hadoop jar myjar.jar my.package.MyClass 2> php_error.log", $result);
I get this exception when i try to exec the command(in the php_error.log):
Exception in thread "main" java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:1879)
at org.apache.hadoop.util.RunJar.main(RunJar.java:115)
I know its related to permissions, but even with 777 on my HDFS, and on hadoop installation folders, it doesnt work.
Any ideas? Thank you.
Also, where this temp file wants to be created? Hadoop dir? hdfs? Where?
Edit: running this locally, it works perfectly! no permission errors! hadoop jar myjar.jar my.package.MyClass
Your PHP is ok. The problem is, that the command you are running is trying to copy the file to the hadoop.tmp.dir. It's default location is /tmp/hadoop-${user.name}
. You have to give the permissions to that folder too, or the full /tmp/hadoop
directory recursively
Edit:
Figured out that apache isn't a valid user in that case. The solution is to create a new user, add it to hadoop group, set permissions to jar, and hadoop.tmp.dir and change the webpage owner to the created user
这篇关于从PHP服务器执行hadoop jar失败。没有权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!