All Products
Search
Document Center

E-MapReduce:Use the password-free feature of the JindoFS SDK

Last Updated:Nov 29, 2025

This topic describes how to use the JindoFS software development kit (SDK) for password-free access to an E-MapReduce (EMR) JindoFS file system from outside an EMR cluster.

Prerequisites

This procedure is for an environment that uses an Elastic Compute Service (ECS) instance, Hadoop, and the Java SDK outside an EMR cluster.

Background

Before using the JindoFS SDK, remove Jindo-related packages from your environment, such as jboot.jar and smartdata-aliyun-jfs-*.jar. To use Spark, also delete the packages in the /opt/apps/spark-current/jars/ directory.

Step 1: Create an instance RAM role

  1. Log on to the RAM console.

  2. In the navigation pane on the left, choose Identities > Roles.

  3. Click Create Role. For Principal Type, select Cloud Service. Then, select the specific Alibaba Cloud service and click OK.

Step 2: Grant permissions to the RAM role

  1. Log on to the RAM console.

  2. (Optional) If you do not want to use system permissions, you can create a custom policy. For more information, see the "Create a custom policy" section in Resource Access Management.

  3. In the navigation pane on the left, choose Identities > Roles.

  4. Click the name of the role that you created.

  5. Click Precise Permission.

  6. Set Permission Type to System Policy or Custom Policy.

    Select a policy based on your requirements, such as AliyunOSSReadOnlyAccess.

  7. Enter the policy name.

  8. Click OK.

Step 3: Grant the RAM role to an ECS instance

  1. Log on to the ECS console.

  2. In the navigation pane on the left, choose Instances & Images > Instances.

  3. In the top navigation bar, select a region.

  4. Find the target ECS instance. In the Actions column, choose image > Instance Settings > Attach/Detach RAM Role.

    image

  5. In the dialog box that appears, select the instance RAM role that you created and click Confirm.

Step 4: Set environment variables on the ECS instance

Run the following command on the ECS instance to set the environment variable.

export CLASSPATH=/xx/xx/jindofs-2.5.0-sdk.jar

Alternatively, run the following command.

HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/xx/xx/jindofs-2.5.0-sdk.jar

Step 5: Test the password-free access method

  1. Access OSS using a shell.

    hdfs dfs -ls/-mkdir/-put/....... oss://<ossPath>
  2. Access OSS using Hadoop FileSystem.

    The JindoFS SDK supports access to OSS using Hadoop FileSystem. The following code provides an example.

    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.fs.FileSystem;
    import org.apache.hadoop.fs.LocatedFileStatus;
    import org.apache.hadoop.fs.Path;
    import org.apache.hadoop.fs.RemoteIterator;
    
    import java.net.URI;
    
    public class test {
        public static void main(String[] args) throws Exception {
            FileSystem fs = FileSystem.get(new URI("ossPath"), new Configuration());
            RemoteIterator<LocatedFileStatus> iterator = fs.listFiles(new Path("ossPath"), false);
            while (iterator.hasNext()){
                LocatedFileStatus fileStatus = iterator.next();
                Path fullPath = fileStatus.getPath();
                System.out.println(fullPath);
            }
        }
    }