You can use Alibaba Cloud CLI, a unified command-line tool built on OpenAPI Explorer, to manage and maintain ApsaraDB for HBase from the command line. This topic walks you through calling ApsaraDB for HBase API operations by using Alibaba Cloud CLI.
Prerequisites
Before you begin, familiarize yourself with Alibaba Cloud CLI. For more information, see What is Alibaba Cloud CLI?.
Install Alibaba Cloud CLI
Install Alibaba Cloud CLI on your operating system. Installers are available for Windows, Linux, and macOS.
-
Windows: Install Alibaba Cloud CLI on Windows.
Alternatively, you can use Cloud Shell to debug Alibaba Cloud CLI commands without a local installation. For more information, see What is Cloud Shell?.
Configure Alibaba Cloud CLI
An Alibaba Cloud account has full permissions on all API operations, which poses a high security risk. We recommend that you use a RAM user for API calls and routine O&M.
Before you use Alibaba Cloud CLI, configure your identity credentials and a default region. Alibaba Cloud CLI supports multiple credential types. For more information, see Configure and manage identity credentials. This example uses an AccessKey pair.
-
Create a RAM user and grant it the required permissions. For more information, see Create a RAM user and Manage RAM user permissions.
ImportantFor this example, attach the
AliyunHBaseReadOnlyAccesspolicy to the RAM user. You can also use theAliyunHBaseFullAccesspolicy for full query and modification permissions, or create a custom policy. For more information, see Create custom RAM authorization policies. -
Create an AccessKey pair for the RAM user and record the
AccessKey IDandAccessKey Secret. For more information, see Create an AccessKey pair. -
Obtain a region ID. Alibaba Cloud CLI sends API requests to the specified region. For a list of supported regions, see Request structure.
NoteYou can add the
--regionoption to a command to override the region in your configuration file and environment variables. For more information, see Command-line options. -
Configure a profile with the RAM user's AccessKey pair. This example uses the profile name
AkProfile. For more information, see Configure and manage identity credentials.
Generate a CLI command example
-
Go to the API debugging page for ApsaraDB for HBase in OpenAPI Explorer.
-
On the API Debugging page, search for the target API in the search box on the left. In Parameter Configuration, specify the required parameters, and then click the CLI Example tab to generate a CLI command with your parameters.
-
Click the
icon to open Cloud Shell and debug the command. -
Click the
icon to copy the CLI example to the clipboard. You can then paste it into your local terminal and run it.-
When you run the CLI example in your local shell, verify the parameter format. For more information, see Parameter formats.
-
OpenAPI Explorer adds the
--regionoption by default, which overrides the region in your profile and environment variables. Remove or keep this option as needed.
-
-
Call API operations
Command structure
Alibaba Cloud CLI commands use the following syntax. For more information, see Generate and run CLI commands.
aliyun <command> <subcommand> [options and parameters]
Common command options
Use command-line options to change default behavior or add functionality. Common options include:
-
--profile <profileName>: Runs the command with the specified profile, overriding the default profile and environment variables. -
--help: Displays help information for the command. For more information, see Get help information.
For more information, see Command-line options.
Example
The following example calls the DescribeInstance operation to query a specific ApsaraDB for HBase instance. For more information, see DescribeInstance.
-
Run the command.
aliyun hbase DescribeInstance --region cn-hangzhou --ClusterId 'ld-bp142678b0894****' -
Sample response:
{ "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" }