Alibaba Cloud CLI is a general-purpose command-line tool that is developed based on OpenAPI. You can use Alibaba Cloud CLI to automate management and maintenance in ApsaraDB for Hbase. This topic describes how to use Alibaba Cloud CLI to call ApsaraDB for Hbase API operations.
Before you start
For more information about Alibaba Cloud CLI, see What is Alibaba Cloud CLI?
Install Alibaba Cloud CLI
You must install Alibaba Cloud CLI before you can use Alibaba Cloud CLI. You can install Alibaba Cloud CLI on the 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:
You can also use Cloud Shell provided by Alibaba Cloud to debug the commands that you want to run in Alibaba Cloud CLI. For more information about Cloud Shell, see What is Cloud Shell?
Configure Alibaba Cloud CLI
An Alibaba Cloud account has the permissions to manage and access the API operations 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 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. Perform the following steps to use AccessKey credentials:
Create a RAM user and grant the RAM user the required permissions. For more information, see Create a RAM user and Grant permissions to a RAM user.
ImportantIn this example, you attach the
AliyunHBaseReadOnlyAccess
policy to the RAM user. You can also select theAliyunHBaseFullAccess
policy to grant the RAM user full permissions to query and modify ApsaraDB for HBase instances or select a custom policy based on your business requirements. For more information, see Customize a RAM policy.Create an AccessKey pair for the RAM user and record the
AccessKey ID
andAccessKey secret
for the subsequent configuration of identity credentials. For more information, see Create an AccessKey pair.Obtain and record the ID of an available region for the subsequent configuration of identity credentials. Alibaba Cloud CLI uses the specified region ID to initiate API calls. For more information about the available regions, see Request structure.
NoteWhen you use Alibaba Cloud CLI, you can specify the
--region
option to run a command in a specific region. If you specify this 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.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
Go to the API debugging page of ApsaraDB for HBase.
In the left-side search box of the API debugging page, search for the API operation that you want to call. On the Parameters tab, enter parameter values based on the API document of the API operation. Then, click the CLI Example tab on the right side of the Parameters tab to generate an example that contains configured parameters.
Click the icon to start Cloud Shell and debug the command in Cloud Shell.
Click the icon to copy the sample command to the clipboard. Then, paste the sample command into your local shell to run the sample command.
Pay attention to the parameter formats when you copy and paste the CLI command into your local shell. For more 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 copy the command to your local shell, Alibaba Cloud CLI ignores the region information in the default 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 default behaviors of commands or implement extended features of commands. The following command options are frequently used:
--profile <profileName>
: You can use the--profile
option and theprofileName
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 specify 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 describes how to use Alibaba Cloud CLI to call the DescribeInstance
operation of ApsaraDB for HBase to query the information about an ApsaraDB for HBase instance. For more information about DescribeInstance
, see DescribeInstance.
Run the following command:
aliyun hbase DescribeInstance --region cn-hangzhou --ClusterId 'ld-bp142678b0894****'
View the command output.
{ "BackupStatus": "open", "ClusterId": "ld-bp142678b0894****", "ClusterName": "hbaseue_test", "ClusterType": "cluster", "ColdStorageSize": 0, "ColdStorageStatus": "open", "ConfirmMaintainTime": false, "CoreDiskCount": 4, "CoreDiskSize": 100, "CoreDiskType": "cloud_ssd", "CoreInstanceType": "hbase.sn2.2xlarge", "CoreNodeCount": 4, "CreatedTime": "2024-08-06T11:20:36", "CreatedTimeUTC": "2024-08-06T03:20:36Z", "EnableHbaseProxy": false, "EncryptionType": "NoEncryption", "Engine": "hbaseue", "InstanceId": "ld-bp142678b0894****", "InstanceName": "hbaseue_test", "IsDeletionProtection": false, "IsHa": true, "IsLatestVersion": false, "IsMultiModel": true, "MaintainEndTime": "06:00:00", "MaintainStartTime": "02:00:00", "MajorVersion": "2.0", "MasterDiskSize": 0, "MasterDiskType": "", "MasterInstanceType": "hbase.sn1.large", "MasterNodeCount": 2, "ModuleId": 0, "ModuleStackVersion": "2.0", "NeedUpgrade": false, "NeedUpgradeComps": { "Comps": [] }, "NetworkType": "VPC", "PayType": "Postpaid", "RegionId": "cn-hangzhou", "RequestId": "FBEE6642-D79E-5***-****-C4AF1******", "ResourceGroupId": "rg-acfmz7u4zzr****", "Status": "ACTIVATION", "Tags": { "Tag": [] }, "TaskProgress": "0", "TaskStatus": "running", "VpcId": "vpc-bp1ov7as4yvz4kxei****", "VswitchId": "vsw-bp1wh6lp1abs3fi0h****", "ZoneId": "cn-hangzhou-b" }