Error accessing Hadoop cluster: Access denied for user Administrator. Superuser privilege is required

Source: Internet
Author: User

After the Hadoop cluster is set up, the Hadoop cluster is accessed locally via the Java API, as follows (see all node name information on the Hadoop cluster)

Import org.apache.hadoop.conf.Configuration;
Import Org.apache.hadoop.fs.FileSystem;
Import Org.apache.hadoop.hdfs.DistributedFileSystem;
Import Org.apache.hadoop.hdfs.protocol.DatanodeInfo;


public class Accesshdfs {public
    static void Main (string[] args) throws IOException {
        Configuration conf=new confi Guration ();
        FileSystem fs= Filesystem.get (uri.create ("Hdfs://your-ip:9000/file-path"), conf);
        Distributedfilesystem DFS = (distributedfilesystem) fs;
        datanodeinfo[] Datanodestats = Dfs.getdatanodestats ();

        for (int i=0; i<datanodestats.length; i++) {
            System.out.println ("Datanode_" + i + "_node:" + datanodestats[i]. GetHostName ());}}

The access denied for user Administrator appears. Superuser privilege is required error message:

Exception in thread "main" org.apache.hadoop.ipc.RemoteException ( ): Access denied for user Administrator. Superuser privilege is required at Org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkSuperuserPrivilege ( :) at Org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkSuperuserPrivilege ( at Org.apache.hadoop.hdfs.server.namenode.FSNamesystem.datanodeReport ( at Org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.getDatanodeReport ( at Org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.getDatanodeReport ( at Org.apache.hadoop.hdfs.protocol.proto.clientnamenodeprotocolprotos$clientnamenodeprotocol$2.callblockingmethod ( at Org.apache.hadoop.ipc.protobufrpcengine$server$ ( at Org.apache.hadoop.ipc.rpc$ ( at org.apache.hadoop.ipc.server$ ( at Org.apache.hadoop.ipc.server$ ( at (Native method) at ( At ( at Org.apache.hadoop.ipc.server$ ( at ( ) at ( at Org.apache.hadoop.ipc.protobufrpcengine$invoker.invoke ( at Com.sun.proxy. $Proxy 9.getDatanodeReport (Unknown Source) at Org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getDatanodeReport ( at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method) at Sun.reflect.NativeMethodAccessorImpl.invoke ( at Sun.reflect.DelegatingMethodAccessorImpl.invoke ( at Java.lang.reflect.Method.invoke ( at ( at ( at com.sun.proxy.$
	Proxy10.getdatanodereport (Unknown Source) at Org.apache.hadoop.hdfs.DFSClient.datanodeReport ( At Org.apache.hadoop.hdfs.DistributedFileSystem.getDataNodeStats ( at Org.apache.hadoop.hdfs.DistributedFileSystem.getDataNodeStats ( at Com.fhpt.AccessHdfs.main (

The reason for this error is that the administrator user does not have permission to refer to the or to use the following simple method.

Add the following information to your code, where "root" is the user name with access to the Hadoop cluster

System.setproperty ("Hadoop_user_name", "root");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.