8

I am trying to run local jar file with spark-submit which is working perfectly fine. Here is the command-

spark-submit --class "SimpleApp" --master local myProject/target/scala-2.11/simple-project_2.11-1.0.jar

But when I am trying with curl

curl -X POST --data '{
 "file": "file:///home/user/myProject/target/scala-2.11/simple-project_2.11-1.0.jar",
 "className": "SimpleApp",
}'  
-H 
"Content-Type: application/json" 
http://server:8998/batches

It is throwing error

"requirement failed: Local path /home/user/myProject/target/scala-2.11/simple-project_2.11-1.0.jar cannot be added to user sessions."

Here is my livy.conf file, as some article suggest to change few things.

# What host address to start the server on. By default, Livy will bind to all network interfaces.
livy.server.host = 0.0.0.0

# What port to start the server on.
livy.server.port = 8998

# What spark master Livy sessions should use.
livy.spark.master = local

# What spark deploy mode Livy sessions should use.
livy.spark.deploy-mode = client

# List of local directories from where files are allowed to be added to user sessions. By
# default it's empty, meaning users can only reference remote URIs when starting their
# sessions.
livy.file.local-dir-whitelist= /home/user/.livy-sessions/

Please help me out with this.

Thanks in Advance.

4

3 回答 3

10

我最近从 Apache Livy 获得了本地文件读取的解决方案,因为我使用 cURL 创建了错误的请求。我刚刚用 'local:/' 替换了来自 'file://' 的文件读取协议,这对我有用。

curl -X POST --data '{
  "file": "local:/home/user/myProject/target/scala-2.11/simple-project_2.11-1.0.jar",
  "className": "SimpleApp",
}'  
-H 
"Content-Type: application/json" 
http://server:8998/batches

这是一个很小的错误,但仍然无法从 HDFS 访问我的 jar 文件。

谢谢大家帮忙。

于 2018-06-30T06:06:41.473 回答
0

如此处Apache Livy cURL not working for spark-submit command中所述,以下答案对我 有用

要将本地文件用于 livy 批处理作业,您需要将本地文件夹添加到 livy.conf 中的 livy.file.local-dir-whitelist 属性。

来自 livy.conf.template 的描述:

允许将文件添加到用户会话的本地目录列表。默认情况下它是空的,这意味着用户只能在开始会话时引用远程 URI。

于 2019-05-23T06:37:09.887 回答
0

Apache Livyjar 文件的存在是强制性要求。如果没有相应的 jar 文件,它将无法工作。

livy jar我的建议是下一个:只需将文件附加到类路径java's cp option

java -cp /usr/local/livy.jar com.myclass.Main

或者干脆使用 SBT:

libraryDependencies += "org.apache.livy" % "livy-api" % "0.4.0-incubating"

马文:

<dependency>
    <groupId>org.apache.livy</groupId>
    <artifactId>livy-api</artifactId>
    <version>0.4.0-incubating</version>
</dependency>

或者你最喜欢的构建工具。

顺便说一句,您还可以将livy jar文件上传到HDFSHadoop 集群并在其上使用,它可以显着简化您的生活。

于 2018-06-26T09:18:22.150 回答