$ cat conf/livy-env.sh
#!/usr/bin/env bash
SPARK_HOME=/opt/spark
HADOOP_CONF_DIR=/etc/hadoop/conf
$ cat conf/livy.conf
livy.server.session.factory = yarn
livy.spark.master = yarn-client
livy.impersonation.enabled = true
livy.repl.enable-hive-context = true
livy.server.csrf_protection.enabled = false
主要报错内容是:java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException:User: root is not allowed to impersonate anonymous
解决办法:通过httpfs协议访问rest接口,以root用户包装自己用户的方式操作HDFS
首先需要开启rest接口,在hdfs-site.xml文件中加入:
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
<property>
然后在core-site.xml文件中加入:
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>