すべてのプロダクト
Search
ドキュメントセンター

AnalyticDB:アカウントの権限付与

最終更新日:Oct 21, 2026

RAM ユーザーを使用して他のクラウドリソースにアクセスする場合、シナリオ (同一アカウントまたはクロスアカウント) に基づいて、RAM ユーザーに必要な権限を付与できます。本トピックでは、同一アカウントでの権限付与とクロスアカウント権限付与の詳細な手順について説明します。

前提条件

クラスターは、Enterprise Edition、Basic Edition、または Lakehouse Edition のいずれかである必要があります。

Spark ジョブの権限

Spark ジョブを送信するには、次の 3 種類の権限が必要です。

権限

説明

次のいずれかの権限:

  • AliyunADBFullAccess

  • AliyunADBDeveloperAccess

  • AliyunADBFullAccess:AnalyticDB for MySQL クラスターを管理する権限

  • AliyunADBDeveloperAccess:AnalyticDB for MySQL クラスターの開発者権限

詳細については、「RAM ユーザーに権限を付与する」をご参照ください。

AnalyticDB for MySQL データベースおよびテーブルの読み取りおよび書き込み権限

AnalyticDB for MySQL では、デフォルトでデータベースアカウントを使用してデータベースとテーブルの権限を管理します。RAM ユーザーとして Spark ジョブを送信する際、Spark ジョブでデータの読み取りまたは書き込みが必要な場合は、標準データベースアカウントを RAM ユーザーにバインドする必要があります。詳細については、「RAM ユーザーとデータベースアカウントのバインドまたはバインド解除」をご参照ください。

AliyunADBSparkProcessingDataRole

AnalyticDB for MySQL Spark が、OSS ディレクトリや OTS データなどの他のクラウドリソースへアクセスすることを許可するために使用されます。詳細については、「同一アカウントでの権限付与」をご参照ください。

同一アカウントでの権限付与

前提条件

RAM ユーザーが作成されていること。

操作手順

RAM コンソールを使用した権限付与 (推奨)

ステップ 1:RAM ロールの作成と権限の付与

  1. RAM ロールを作成します。

    説明

    「[信頼されたエンティティタイプ]」が「[Alibaba Cloud Service]」で、「[信頼されたエンティティ]」が「[AnalyticDB for MySQL]」である RAM ロールをすでに作成している場合は、この手順をスキップして次の手順に進むことができます。

    1. RAM 管理者として RAM コンソール にログオンします。

    2. ナビゲーションペインで、[ID 管理] > [ロール] を選択します。

    3. [ロール] ページで、[ロールの作成] をクリックします。

    4. [ロールの作成] ページで、[信頼されたエンティティタイプ] を [Alibaba Cloud Service] に設定し、[信頼されたエンティティ] で [AnalyticDB for MySQL] を選択してから、[OK] をクリックします。

    5. [ロールの作成] ダイアログボックスで、[ロール名] を入力し、[OK] をクリックします。

  2. RAM ロールに権限を付与します。

    1. [ポリシーによる権限付与] をクリックします。

    2. [ポリシーによる権限付与] パネルで、ポリシータイプを [システムポリシー] または [カスタムポリシー] に設定し、ポリシー名を入力します。

      特定のクラウドリソースにのみアクセスする場合は、カスタムポリシーを作成する必要があります。詳細については、「カスタムポリシーの作成」をご参照ください。

    3. [OK] をクリックします。

ステップ 2:Spark ジョブの送信

RAM コンソールで RAM ロールを作成して権限を付与した後、Spark ジョブを送信する際には、Spark ジョブが正常に実行されるように、Spark ジョブ設定で spark.adb.roleArn パラメーターを設定する必要があります。 例:

{
 "comments": [
 "-- これは LakeCache を使用する例です。内容を変更して、Spark プログラムを実行してください。"
 ],
 "args": ["oss://testBucketName/data/readme.txt"],
 "name": "spark-oss-test",
 "file": "oss://testBucketName/data/example.py",
 "conf": {
 "spark.adb.lakecache.enabled": "true";,
 "spark.adb.roleArn": "acs:ram::testAccountID:role/adbtest";
 }
}

クイック権限付与

警告

同一アカウントでの権限付与後、AliyunADBSparkProcessingDataRole ロールには、デフォルトで AliyunADBSparkProcessingDataRolePolicy ポリシーが付与されます。このポリシーには、OSS、Table Store、DMS などのクラウドリソースへのアクセス権限が含まれており、過剰な権限付与が発生する可能性があります。権限付与後、AliyunADBSparkProcessingDataRolePolicy ポリシーを削除し、AliyunADBSparkProcessingDataRole ロールに業務に必要な権限のみを付与することを推奨します。

  1. クイック権限付与リンク をクリックします。

    説明

    RAM ユーザー管理権限 (少なくとも RAM ロールの作成、RAM ポリシーの作成、RAM ロールのクエリ、RAM ポリシーのクエリの権限) を持つユーザーのみが、クイック権限付与を実行できます。

  2. 左下の [権限付与の確認] をクリックします。

    権限付与後、AnalyticDB for MySQL が使用するサービスロール AliyunADBSparkProcessingDataRole が自動的に作成されます。AnalyticDB for MySQL は、このロールを使用して他のクラウドリソースにアクセスします。

Cross-Account Authorization

AnalyticDB for MySQL Spark supports access to all cloud resources of other Alibaba Cloud accounts. This topic uses Alibaba Cloud Account A (the primary account with ID testAccountIDA) to access data of Alibaba Cloud Account B (the primary account with ID testAccountIDB) as an example to describe the cross-account authorization procedure.

Step 1: Create a RAM role for Account B and grant permissions

  1. Create a RAM role and allow Account A to assume this RAM role.

    説明

    If you have already created a RAM role and allowed Account A to assume this RAM role, you can skip this step and continue with the following steps.

    1. Use Alibaba Cloud Account B (the primary account) or a RAM administrator to log on to the RAMconsole.

    2. In the left-side navigation pane, choose Identity Management > Roles.

    3. On the [Roles]page, Click[Create Role].

    4. On the [Create Role]page, choose[Trusted Entity Type]for[Alibaba Cloud Account], specify the Alibaba Cloud account, and then click [OK].

    5. Configure the role information.

      1. Enter a [Role Name].In this example, set the role name to admin-oss.

      2. Optional: Enter a [Description].

      3. Set Trusted Alibaba Cloud Account to [Other Alibaba Cloud Account], and then enter the UID of Account A (testAccountIDA).

    6. Click [Complete].

for RAMRoles Grant Permission by Policy.

  1. Click [Grant Permission by Policy].

  2. On the [Grant Permission by Policy]panel, set the policy type to[System Policy]or[Custom Policy], and then enter the policy name.

    Access OSS

    • AliyunOSSReadOnlyAccess: The permission to read OSS resources.

    • AliyunOSSFullAccess: The permission to manage OSS. If you need to perform data update operations such as INSERT on OSS external tables, you must grant this permission to the RAM role.

    Access resources in a specified VPC

    If you want to access resources in a specified VPC, you must create a custom policy and specify the security group and vSwitch in the Resource parameter. For more information, see Create a custom policy.

    In this example, only access to the ApsaraDB RDS for MySQL instance in the specified VPC is authorized. The custom policy name is eni_policy, and the policy content is as follows:

    説明

    You mustRDS MySQLinstance and add a security group, and allow inbound and outbound access in the security group rules toRDS MySQLport access requests.

    {
     "Version": "1",
     "Statement": [
     {
     "Effect": "Allow",
     "Action": "ecs:*",
     "Resource": "acs:ecs:*:*:securitygroup/<Security group ID of the ApsaraDB RDS instance>"
     },
     {
     "Effect": "Allow",
     "Action": "vpc:*",
     "Resource": "acs:vpc:*:*:vswitch/<vSwitch ID of the ApsaraDB RDS instance>"
     }
     ]
    }
  3. Click [OK].

  4. Click [Close].

  1. Modify the trust policy to allow any RAM user under Account A to assume this RAM role.

    1. In the left-side navigation pane, choose Identity Management > Roles.

    2. On the [Roles] page, click the name of the target RAM role.

    3. On the [Trust Policy]tab, Click[Edit Trust Policy].

    4. In the editor, Modify the trust policy content, and then click[OK].

      {
       "Statement": [
       {
       "Action": "sts:AssumeRole",
       "Effect": "Allow",
       "Principal": {
       "RAM": [
       "acs:ram::testAccountIDA:root"
       ]
       }
       },
       {
       "Action": "sts:AssumeRole",
       "Effect": "Allow",
       "Principal": {
       "Service": [
       "testAccountIDA@ads.aliyuncs.com"
       ]
       }
       }
       ],
       "Version": "1"
      }

Step 2: forAaccount. CreateRAMUsersand grantassumeRAMRoles permissions

  1. Create a RAM user.

    1. Use Alibaba Cloud Account A (the primary account) or a RAM administrator to log on to the RAMconsole.

    2. In the left-side navigation pane, choose Identity Management > Users.

    3. On the [Users]page, Click[Create User].

    4. On the [Create User] page, configure the basic user information in the [User Account Information] section.

      • [Logon Name](Required): can contain letters, digits, periods (.), hyphens (-), and underscores (_). Maximum length: 64 characters.

      • Display Name(Optional): maximum length: 128 characters.

      • [Tag](Optional): Click edit, and then enter tag keys and tag values for tag-based user management.

      説明

      Click [Add User] to create multiple RAM users at a time.

    5. In [Access Method] section, choose [Console Access], and configure the console logon password, password reset policy, and MFA policy as needed. For more information, see Console Access.

    6. Click [OK].

  2. CreatePolicies, allowRAMUsersassumeany role.

    1. In the left-side navigation pane, choose Permission Management > Policies.

    2. On the [Policies]page, Click[CreatePolicies].

    3. On the [CreatePolicies]page, Click[Script Editor]tab.

    4. EnterPoliciescontent, and then click[OK].

      {
       "Version": "1",
       "Statement": [
       {
       "Action": "ram:PassRole",
       "Resource": "*",
       "Effect": "Allow"
       }
       ]
      }
    5. On the [CreatePolicies]dialog box, Enter[Policy Name]and[Description], and then click[OK].

  3. Grant permissions to the RAM user.

    1. In the left-side navigation pane, choose Identity Management > Users.

    2. On the [Users]page, ClicktargetRAMUsers[Actions]in the[Add Permissions].

    3. In the [Add Permissions] panel, add the policy created in Step 2 to the RAM user.

    4. Click [Confirm].

    5. Click [Close].

Related Documentation