edit-icon download-icon

MetaService

Last Updated: Dec 06, 2017

MetaService is provided under the E-MapReduce environment. MetaService allows you to access Alibaba Cloud resources in the E-MapReduce cluster without using AK.

Default roles

By default, you must authorize an application role (AliyunEmrEcsDefaultRole) to E-MapReduce when creating a cluster. After authorization, you can perform operations on E-MapReduce to access Alibaba Cloud resources without needing to explicitly input AK. By default, the following permission policies are granted to AliyunEmrEcsDefaultRole:

  1. {
  2. "Version": "1",
  3. "Statement": [
  4. {
  5. "Action": [
  6. "oss:GetObject",
  7. "oss:ListObjects",
  8. "oss:PutObject",
  9. "oss:DeleteObject",
  10. "oss:ListBuckets",
  11. "oss:AbortMultipartUpload"
  12. ],
  13. "Resource": "*",
  14. "Effect": "Allow"
  15. }
  16. ]
  17. }

By default, your operations based on MetaService can Access OSS Data Only. If you want to access other Alibaba Cloud resources, such as LogService by using MetaService, you must grant permissions to AliyunEmrEcsDefaultRole. You can perform the preceding operations by using the RAM console.

Note: MetaService only supports AK-free operations on the OSS, LogService, and MNS data. You must edit and delete the default role with caution. Otherwise, your cluster creation or operations may fail.

Custom application role

In most cases, you only need to use a default role or modify the default role. E-MapReduce also allows you to create your own application role. When creating a cluster, you can use a default role or create your own application role. For more information about how to create and authorize a role to E-MapReduce, see RAM Documentations.

Accessing MetaService

MetaService is an HTTP service which can be accessed directly to obtain metadata information. For example, you can click here to view the region where the current cluster is located.

MetaService supports the following types of information:

  • Region: “/cluster-region”
  • Role name: “/cluster-role-name”
  • AccessKeyId: “/role-access-key-id”
  • AccessKeySecret: “/role-access-key-secret”
  • SecurityToken: “/role-security-token”
  • Network type: “/cluster-network-type”

Use MetaService

You can use MetaSerivce to access Alibaba Cloud resources without needing to use AK, which can:

  • Reduce the risk of an AK leak. The RAM-based usage can minimize security risk. The permissions are minimized by only granting the required permissions to the role.
  • Improve user experience. This is intended especially when you interactively access the OSS resources by using MetaService. You do not need to write a long string of OSS path.

Several usage methods are introduced as follows:

  1. I. Using the Hadoop command line to display OSS data
  2. Previously, we used: hadoop fs -ls oss://ZaH******As1s:Ba23N**************sdaBj2@bucket.oss-cn-hangzhou-internal.aliyuncs.com/a/b/c
  3. Now, we use: hadoop fs -ls oss://bucket/a/b/c
  4. II. Using Hive to create a table
  5. Previously, we used:
  6. CREATE EXTERNAL TABLE test_table(id INT, name string)
  7. ROW FORMAT DELIMITED
  8. FIELDS TERMINATED BY '/t'
  9. LOCATION 'oss://ZaH******As1s:Ba23N**************sdaBj2@bucket.oss-cn-hangzhou-internal.aliyuncs.com/a/b/c';
  10. Now, we use:
  11. CREATE EXTERNAL TABLE test_table(id INT, name string)
  12. ROW FORMAT DELIMITED
  13. FIELDS TERMINATED BY '/t'
  14. LOCATION 'oss://bucket/a/b/c';
  15. III. Spark
  16. Previously, we used: val data = sc.textFile("oss://ZaH******As1s:Ba23N**************sdaBj2@bucket.oss-cn-hangzhou-internal.aliyuncs.com/a/b/c")
  17. Now, we use: val data = sc.textFile("oss://bucket/a/b/c")
Thank you! We've received your feedback.