Just a quick note, just in case:
1. For hadoop
If hadoop has not started Kerberos or the user obtained from Kerberos is null, then get the HADOOP_USER_NAME
environment variable and set its value as the Hadoop execution user. If we don't set HADOOP_USER_NAME
environment variables, then the program will call whoami to get the current user and groups to get the group the user is in.
So you can set environment variables:
export HADOOP_USER_NAME=hdfs
Or set in the program:
System.setProperty("HADOOP_USER_NAME", "hdfs");
2. For Spark
By default, Spark uses the current logged-in user of the system where the user program runs as the associated user of the user program.
So you can use the following two methods:
1. Modify the current user name: hdfs
2. Add in the code:
System.setProperty("user.name", "hdfs");