Promo Center

50% off for new user

Direct Mail-46% off

Learn More

Use Alibaba Cloud CLI to manage AnalyticDB for MySQL

Updated at: 2024-11-22 05:54

Alibaba Cloud CLI is a universal command-line tool that is developed based on APIs. You can use Alibaba Cloud CLI to automate the management and maintenance of AnalyticDB for MySQL. This topic describes how to use Alibaba Cloud CLI to call the API operations of AnalyticDB for MySQL.

Before you begin

Get yourself familiar with Alibaba Cloud CLI. For more information, see What is Alibaba Cloud CLI?

Install Alibaba Cloud CLI

Before you can use Alibaba Cloud CLI, you must install Alibaba Cloud CLI. You can install Alibaba Cloud CLI on Windows, Linux, and macOS operating systems. Select an installation package of Alibaba Cloud CLI based on the operating system of your device. For more information, see the following topics:

  • Windows operating system: Windows.

  • Linux operating system: Linux.

  • macOS operating system: macOS.

You can also use Alibaba Cloud Cloud Shell to debug the commands that you want to run in Alibaba Cloud CLI. For more information, see What is Cloud Shell?

Configure Alibaba Cloud CLI

Important

An Alibaba Cloud account has permissions to manage and access the APIs of all Alibaba Cloud services. If you use an Alibaba Cloud account to call API operations, security risks may arise. We recommend that you use a Resource Access Management (RAM) user to call API operations or perform routine O&M.

Before you use Alibaba Cloud CLI, you must configure information such as identity credentials and a region ID in Alibaba Cloud CLI. Alibaba Cloud CLI supports various identity credentials. For more information, see the "Credential types" section of the Configure profiles topic. In this example, AccessKey credentials are used. To use AccessKey credentials, perform the following steps:

  1. Create a RAM user and grant the required permissions to the RAM user. For more information, see Create a RAM user and Grant permissions to a RAM user.

    Important

    In this example, you need to attach the AliyunADBFullAccess policy to the RAM user. Before you call API operations as a RAM user, grant the required permissions to the RAM user based on your business requirements.

  2. Create an AccessKey pair for the RAM user and record the AccessKey ID and AccessKey secret for the configuration of identity credentials. For more information, see the "Create an AccessKey pair for a RAM user" section of the Create an AccessKey pair topic.

  3. Obtain and record the ID of an available region for the configuration of identity credentials. Alibaba Cloud CLI uses the region ID that you specify to initiate API calls. For information about regions in which Data Lakehouse Edition is available, see Endpoints.

    Note

    When you use Alibaba Cloud CLI, you can use the --region option to run a command in a specific region. If you use the option, Alibaba Cloud CLI ignores the region information in the default credential configurations and environment variable settings. For more information, see Command line options for API calls.

  4. Use the AccessKey pair of the RAM user to configure identity credentials in the configuration file named AkProfile. For more information, see the "Configuration examples" section of the Configure profiles topic.

Generate a CLI command

  1. Go to the Debugging page of the AnalyticDB for MySQL Data Lakehouse Edition API.

  2. In the left-side search box on the Debugging page, search for the API operation that you want to call. On the Parameters tab, specify parameter values based on the API document of the API operation. Then, click the CLI Example tab in the right-side pane to view the CLI command that is generated with the specified parameters.image

    • Click the image icon. You are directed to Cloud Shell. You can debug the command in Cloud Shell.

    • Click the image icon to copy the CLI command to the clipboard and paste the command to the local shell.

      • When you paste the sample command to your shell for debugging, take note of the formats of parameters. For information about the parameter formats of Alibaba Cloud CLI, see Parameter formats.

      • By default, OpenAPI Explorer adds the --region option to the generated CLI command. When you paste the command to your shell, Alibaba Cloud CLI ignores the region information in the default identity credential configurations and environment variable settings, and preferentially runs the command in the specified region. You can delete or retain the option based on your business requirements.

Call API operations

Syntax

In Alibaba Cloud CLI, you can use the following syntax to run commands. For more information, see the "Syntax" section of the Generate and run CLI commands topic.

aliyun <command> <subcommand> [options and parameters]

Command options

When you use Alibaba Cloud CLI, you can specify command options to change the behaviors of commands or implement additional features of commands. In most cases, the following command options are used:

  • --profile <profileName>: You can use the --profile option and the profileName parameter to specify a configuration profile. After you specify a valid configuration profile, Alibaba Cloud CLI ignores the information in the default credential configurations and environment variable settings and preferentially uses the configurations that you specify to run commands.

  • --help: You can use the --help option to obtain the help information about a command. For more information, see Use the help command.

For more information, see Command line options for API calls.

Example

The following example shows how to use Alibaba Cloud CLI to call the DescribeDBClusterAttribute operation of AnalyticDB for MySQL to query the information about an AnalyticDB for MySQL Data Lakehouse Edition cluster. For more information about the DescribeDBClusterAttribute operation, see DescribeDBClusterAttribute.

  1. Run the following command:

    aliyun adb DescribeDBClusterAttribute --region cn-hangzhou --DBClusterId 'amv-bp15yg4o68****' --version 2021-12-01 --method POST --force
  2. View the command output.

    {
            "Items": {
                    "DBCluster": [
                            {
                                    "ClickhouseEngineCacheSize": -1,
                                    "ClickhouseEngineEnabled": false,
                                    "CommodityCode": "ads",
                                    "ComputeResource": "0ACU",
                                    "ComputeResourceTotal": "0ACU",
                                    "ConnectionString": "amv-bp15yg4o68****.ads.aliyuncs.com",
                                    "CreationTime": "2024-09-26T05:25:46Z",
                                    "DBClusterDescription": "amv-bp15yg4o68****",
                                    "DBClusterId": "amv-bp15yg4o68****",
                                    "DBClusterNetworkType": "VPC",
                                    "DBClusterStatus": "Running",
                                    "DBClusterType": "Common",
                                    "DBVersion": "5.0",
                                    "Engine": "3.2.2.2",
                                    "EngineVersion": "3.2.2.2",
                                    "ExpireTime": "",
                                    "KmsId": "",
                                    "LockMode": "Unlock",
                                    "LockReason": "",
                                    "MaintainTime": "15:00Z-16:00Z",
                                    "Mode": "flexible",
                                    "PayType": "Postpaid",
                                    "Port": "3306",
                                    "ProductForm": "IntegrationForm",
                                    "ProductVersion": "EnterpriseVersion",
                                    "RegionId": "cn-hangzhou",
                                    "ReservedACU": "0ACU",
                                    "ReservedNodeCount": 3,
                                    "ReservedNodeSize": "8ACU",
                                    "ResourceGroupId": "rg-acfmz7u4zzrngoa",
                                    "StorageResource": "24ACU",
                                    "StorageResourceTotal": "24ACU",
                                    "SupportedFeatures": {
                                            "AutoMC": true,
                                            "ClickhouseEngine": true
                                    },
                                    "UserENIStatus": false,
                                    "VPCId": "vpc-bp15lqdl91m0fdc****",
                                    "VSwitchId": "vsw-bp1k9jdi0yznq****",
                                    "ZoneId": "cn-hangzhou-k"
                            }
                    ]
            },
            "RequestId": "C42A167C-620C-5CF4-B016-663E3****"
    }

  • On this page (1, T)
  • Before you begin
  • Install Alibaba Cloud CLI
  • Configure Alibaba Cloud CLI
  • Generate a CLI command
  • Call API operations
  • Syntax
  • Command options
  • Example
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare