编程

alibabacloud-polardbx-ops

试用

Manage Alibaba Cloud PolarDB-X instance lifecycle and routine operations via the Aliyun CLI. Use when the user asks to create, delete, restart, scale, modify, monitor, or inspect PolarDB-X instances. Triggers: "polardb-x", "polardbx", "create polardb-x", "delete polardb-x", "restart polardb-x", "scale polardb-x", "upgrade polardb-x", "describe polardb-x", "polardb-x instance", "polardb-x parameters", "polardb-x slow log", "polardb-x performance", "polardb-x binlog"

它能做什么

Manage Alibaba Cloud PolarDB-X instance lifecycle and routine operations via the Aliyun CLI. Use when the user asks to create, delete, restart, scale, modify, monitor, or inspect PolarDB-X instances. Triggers: "polardb-x", "polardbx", "create polardb-x", "delete polardb-x", "restart polardb-x", "scale polardb-x", "upgrade polardb-x", "describe polardb-x", "polardb-x instance", "polardb-x parameters", "polardb-x slow log", "polardb-x performance", "polardb-x binlog"

技能文档

PolarDB-X Instance Management

Manage Alibaba Cloud PolarDB-X instances through the aliyun polardbx CLI: instance lifecycle, scaling, parameter management, monitoring, and logs.

This skill uses intent routing: identify the user's intent, run pre-flight checks, then load the relevant module reference document fully before generating any CLI command.


Architecture

Alibaba Cloud PolarDB-X Instance Management
├── Instance Lifecycle    --> references/instance-lifecycle.md
│   ├── CreateDBInstance
│   ├── DeleteDBInstance
│   ├── RestartDBInstance
│   ├── DescribeDBInstanceAttribute
│   ├── DescribeDBInstances
│   ├── DescribeDBInstanceTopology
│   ├── DescribeTasks
│   ├── ModifyDBInstanceDescription
│   ├── ModifyDBInstanceMaintainTime
│   └── UpgradeDBInstanceKernelVersion
├── Scaling               --> references/scaling.md
│   ├── UpdatePolarDBXInstanceNode
│   ├── ModifyDBInstanceClass
│   └── DescribeScaleOutMigrateTaskList
├── Parameters            --> references/parameters.md
│   ├── DescribeDBInstanceConfig
│   ├── ModifyDBInstanceConfig
│   ├── DescribeParameters
│   ├── ModifyParameter
│   └── DescribeParameterTemplates
├── Instance Specs        --> scripts/spec_lookup.sh (spec code <-> cores/memory)
│   ├── Enterprise CN (CnClass)
│   ├── Enterprise DN (DnClass)
│   ├── Standard DBNodeClass
│   └── Naming Rules
└── Monitoring & Logs     --> references/monitoring-logs.md
    ├── DescribeDBNodePerformance
    ├── DescribeSlowLogRecords
    └── DescribeBinaryLogList

Extended Modules

The following modules cover the full PolarDB-X (2020-02-02) API surface. See each reference file for the complete API spec.

├── Account Management      --> references/account-management.md
├── Database Management     --> references/database-management.md
├── Backup & Restore        --> references/backup-restore.md
├── Security & Access        --> references/security-access.md
├── SQL Audit & Compliance   --> references/sql-audit-compliance.md
├── Operation Tasks & Events --> references/operation-tasks.md
├── HA & Migration           --> references/ha-migration.md
├── Connection & Endpoint    --> references/connection-endpoint.md
├── Tags & Resource Group    --> references/tags-resourcegroup.md
├── Metadata & Query         --> references/metadata-query.md
├── Cold Storage             --> references/cold-storage.md
├── Data Evaluate & Migration--> references/data-evaluate-migration.md
├── SQL Flashback            --> references/sql-flashback.md
├── CDC (Log Engine)         --> references/cdc.md
├── Columnar                 --> references/columnar.md
├── GDN                      --> references/gdn.md
└── Mem0                     --> references/mem0.md

Requirement Analysis

Before routing, analyze the user request:

  1. Identify intent: create / delete / restart / describe / list / scale / modify parameters / view monitoring / view logs.
  2. Extract required parameters: RegionId, instance identifier (DBInstanceName or DBInstanceId), EngineVersion, DBInstanceClass, node counts, time ranges, etc.
  3. If any required parameter is missing, ask the user. Do NOT guess values or APIs.
  4. After intent and parameters are clear, load the matched reference document fully, then construct the CLI command.

Pre-flight Checks

Run these checks at the start of every skill invocation. Only load the referenced document if a check fails. If step 1/2/3/5 fails, read references/cli-installation-guide.md; if step 4 fails, read references/ram-policies.md.

1. aliyun CLI version

aliyun --version

Success: Output contains Alibaba Cloud Command Line Interface Version and the version is >= 3.3.3.

Failure: Read references/cli-installation-guide.md section 1.

2. aliyun CLI plugin and configuration

aliyun configure set --auto-plugin-install true
aliyun plugin update
aliyun configure list

Success: aliyun configure list shows at least one valid profile (AK, STS, or OAuth identity).

Failure: Read references/cli-installation-guide.md sections 2 and 3.

3. Caller identity

aliyun sts get-caller-identity

Success: Returns JSON with AccountId, UserId, and Arn.

Failure: Read references/cli-installation-guide.md section 4.

4. RAM permissions

aliyun polardbx describe-db-instances --biz-region-id  --region  --user-agent AlibabaCloud-Agent-Skills/alibabacloud-polardbx-ops/{session-id}

Success: Returns an instance list or empty list without permission errors.

Failure: Read references/ram-policies.md.

5. jq availability

jq --version

Success: Output contains a version string such as jq-1.7.1.

Failure: Read references/cli-installation-guide.md section 5.


Observability (MUST follow for every aliyun command)

Upon loading this skill, generate a random session ID (32-char lowercase hex string) once for the entire session. Use it as {session-id} below.

Rule: Every aliyun CLI command that calls a cloud API MUST include the --user-agent flag. Local utility commands (e.g. configure, plugin, version) do not support this flag and should be excluded.

--user-agent AlibabaCloud-Agent-Skills/alibabacloud-polardbx-ops/{session-id}

Example (assuming session-id is a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6):

aliyun polardbx describe-db-instances --biz-region-id cn-hangzhou --region cn-hangzhou --user-agent AlibabaCloud-Agent-Skills/alibabacloud-polardbx-ops/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6

Do not skip, alter the format, or omit --user-agent on any aliyun API command invocation.

Script / Terraform execution: When running Python SDK scripts or Terraform commands or bash scripts, inject the session-id via inline environment variable so the code can read it at runtime:

# Python SDK script
SKILL_SESSION_ID={session-id} python3 scripts/deploy.py

# Terraform
SKILL_SESSION_ID={session-id} terraform apply

Scripts and Terraform configs should read SKILL_SESSION_ID from the environment (default to empty string if absent). See references/how-to-implement-by-common-sdk.md for SDK patterns.


Intent Routing

Match the user request to the first matching row, then load the listed reference file and follow its API spec.

If the user wants to ...ModuleRequired readingKey APIs
Create / delete / restart / describe / list instances, modify description / maintain time, upgrade kernel, query topology or tasksInstance Lifecyclereferences/instance-lifecycle.mdCreateDBInstance, DeleteDBInstance, RestartDBInstance, DescribeDBInstanceAttribute, DescribeDBInstances, DescribeDBInstanceTopology, DescribeTasks, ModifyDBInstanceDescription, ModifyDBInstanceMaintainTime, UpgradeDBInstanceKernelVersion
Scale nodes / change instance class / view scale-out migration progressScalingreferences/scaling.mdUpdatePolarDBXInstanceNode, ModifyDBInstanceClass, DescribeScaleOutMigrateTaskList
View / modify instance config or parametersParametersreferences/parameters.mdDescribeDBInstanceConfig, ModifyDBInstanceConfig, DescribeParameters, ModifyParameter, DescribeParameterTemplates
Look up CN / DN / DBNodeClass spec codes, or convert between a spec code and its cores/memoryInstance Specsscripts/spec_lookup.sh for spec-code <-> hardware mapping (--code / --cores+--memory; --list to enumerate all specs)spec_lookup.sh --code / --cores/--memory
View performance data / slow logs / binlog listMonitoring & Logsreferences/monitoring-logs.mdDescribeDBNodePerformance, DescribeSlowLogRecords, DescribeBinaryLogList
Manage database accounts (create/delete/list/reset password/privilege)Account Managementreferences/account-management.mdCreateAccount, DeleteAccount, DescribeAccountList, CreateSuperAccount, ResetAccountPassword, ResetAccountPasswordRestrict, ModifyAccountDescription, ModifyAccountPrivilege
Manage databases and tablesDatabase Managementreferences/database-management.mdCreateDB, DeleteDB, DescribeDbList, DescribeDistributeTableList, DescribeArchiveTableList, ModifyDatabaseDescription
Backup / restore / clone instanceBackup & Restorereferences/backup-restore.mdCreateBackup, DescribeBackupPolicy, UpdateBackupPolicy, DescribeBackupSet, DescribeBackupSetList, DescribeOpenBackupSet, RestoreDBInstance
Manage IP whitelist / SSL / TDE / KMS authorizationSecurity & Accessreferences/security-access.mdDescribeSecurityIps, ModifySecurityIps, DescribeDBInstanceSSL, UpdateDBInstanceSSL, DescribeDBInstanceTDE, UpdateDBInstanceTDE, DescribeUserEncryptionKeyList, CheckCloudResourceAuthorized
SQL audit / rights separationSQL Audit & Compliancereferences/sql-audit-compliance.mdEnableSqlAudit, DisableSqlAudit, DescribeSqlAuditInfo, CheckSqlAuditSlsStatus, EnableRightsSeparation, DisableRightsSeparation
View / manage O&M events, maintenance conf, history events, healthOperation Tasks & Eventsreferences/operation-tasks.mdDescribeActiveOperationTasks, DescribeActiveOperationTaskCount, DescribeActiveOperationMaintainConf, ModifyActiveOperationMaintainConf, ModifyActiveOperationTasks, CancelActiveOperationTasks, DescribeEvents, SkipCurrentStep, CheckHealth, DescribeComponentPropeties
HA switch / zone migrationHA & Migrationreferences/ha-migration.mdDescribeDBInstanceHA, SwitchDBInstanceHA, MigrateDBInstance, AlignStoragePrimaryAzone, ConfirmNoConnection, StartSwitchDatabase, DescribeTransformStatus (standard-to-enterprise upgrade not supported)
Manage connection strings / VIP / custom endpointsConnection & Endpointreferences/connection-endpoint.mdDescribeDBInstanceEndpoint, ModifyDBInstanceConnectionString, ModifyDBInstanceVip, CreateCustomEndpoint, DeleteCustomEndpoint, ModifyCustomEndpoint, ModifyCustomEndpointNet, DescribeCustomEndpointList, DescribeDBInstanceViaEndpoint, CreateSubCNInstance, DeleteSubCNInstance
Manage tags / resource groupTags & Resource Groupreferences/tags-resourcegroup.mdTagResources, UntagResources, ListTagResources, DescribeTags, ChangeResourceGroup, UpdateCustinsParam
Query regions / VPC / VSwitch / character set / data nodes / parameter groupsMetadata & Queryreferences/metadata-query.mdDescribeRegions, DescribeAvailableCrossRegions, DescribeEnabledCrossRegions, DescribeRdsVpcs, DescribeRdsVswitches, DescribeCharacterSet, DescribePolarxDataNodes, DescribeParameterGroups
Manage cold-data volume / storage pool / storage usageCold Storagereferences/cold-storage.mdAllocateColdDataVolume, ReleaseColdDataVolume, DescribeColdDataBasicInfo, CreateStoragePool, DescribeStoragePoolInfo, DescribeShowStorageInfo
SQL evaluation / evaluate-import tasks / replication inspection / engine migrationData Evaluate & Migrationreferences/data-evaluate-migration.mdCreateSQLEvaluateTask, DescribeEvaluateAndImportTask, DescribeEvaluateAndImportTasks, DeleteEvaluateAndImportTask, CreateRplInspectionTask, DescribeRplInspectionTask, CloseEngineMigration, ModifyEngineMigration
SQL flashback (row-level recovery)SQL Flashbackreferences/sql-flashback.mdDescribeSqlFlashbackTaskList, PreCheckSqlFlashbackTask, SubmitSqlFlashbackTask
CDC / log engine info, spec, versionCDC (Log Engine)references/cdc.mdDescribeCdcInfo, DescribeCdcClassList, DescribeCdcVersionList, ModifyCdcClass, UpgradeCDCVersion
Columnar (column store) info, spec, versionColumnarreferences/columnar.mdAttachColumnarInstance, DescribeColumnarInfo, DescribeColumnarClassList, DescribeColumnarVersionList, ModifyColumnarClass, UpgradeColumnarVersion
GDN (Global Database Network) managementGDNreferences/gdn.mdCreateGdnInstance, DeleteGdnInstance, DescribeGdnInstances, CreateGdnStandbyMember, SwitchGdnMemberRole
Mem0 (memory engine) managementMem0references/mem0.mdCreateMem0, DeleteMem0, DescribeMem0Info, DescribeMem0SecurityIps, ModifyMem0SecurityIps, ResetMem0AccountPassword, CreateGatewayConsumerForPolarDBX

If multiple intents are present, handle them sequentially: route -> execute -> verify -> next route. If the intent does not match any row, ask the user to clarify; do NOT guess an API.


Global Conventions

These conventions apply to every aliyun polardbx CLI command produced by this skill.

Command format

aliyun polardbx  --biz-region-id  --region  [other parameters]

[MUST] Always pass BOTH --biz-region-id AND the global flag --region with the same value. --biz-region-id is only a business-level parameter; the CLI resolves the API endpoint from the profile default region or the global --region flag. Without --region, every request is sent to the profile's default-region endpoint (e.g. polardbx.cn-hangzhou.aliyuncs.com), so instances/VPCs in other regions return InvalidDBInstance.NotFound / InvalidParameter.VpcId.VSwitchId.

  • The aliyun CLI returns JSON by default. Do NOT add --output unless the user explicitly asks for table format.
  • Read operations append --connect-timeout 3 --read-timeout 10.
  • Write operations append --connect-timeout 3 --read-timeout 30 --client-token .

Command style: plugin mode

This skill uses the aliyun CLI plugin mode for PolarDB-X:

ExampleParameter namingRegion parameters
aliyun polardbx create-db-instance--biz-region-id, --vpc-id, --vswitch-id--biz-region-id + --region (global, same value)
  • All action names are lowercase words connected with hyphens (describe-db-instances).
  • All parameter flags are kebab-case (--db-instance-name, --client-token).
  • Do NOT mix plugin mode with the legacy PascalCase API style within a single command.
  • If a parameter is rejected, fall back to aliyun polardbx --help to verify the exact parameter name.

CN spec naming

PolarDB-X CN node specs follow the pattern polarx.xN... The `` field determines the core multiplier:

SuffixCoresMemoryExample (x4)
largeN (1x)4N GBpolarx.x4.large.2e = 4C16G
xlarge2N (2x)8N GBpolarx.x4.xlarge.2e = 8C32G
  • large is NOT a small size; it is the base (1x) multiplier.
  • xlarge doubles the core count and memory.
  • When the user says "4-core 16G", select large; do NOT select xlarge.
  • For full spec list, run aliyun polardbx create-db-instance --help.

Output parsing

  • Pipe the default JSON output to jq and extract only the fields the user needs.
  • Avoid dumping large raw JSON blocks; prefer concise jq filters.
  • Example:
aliyun polardbx describe-db-instances \
  --biz-region-id cn-hangzhou \
  --region cn-hangzhou \
  --connect-timeout 3 --read-timeout 10 \
  --user-agent AlibabaCloud-Agent-Skills/alibabacloud-polardbx-ops/{session-id} \
  | jq '.DBInstances[] | {DBInstanceName, Status, Description}'

Table output

If the user explicitly requests table format, use --output with cols and rows:

aliyun polardbx describe-db-instances \
  --biz-region-id cn-hangzhou \
  --region cn-hangzhou \
  --output cols=DBInstanceName,Status,Description,rows=DBInstances \
  --user-agent AlibabaCloud-Agent-Skills/alibabacloud-polardbx-ops/{session-id}

In zsh, quote the --output value to prevent glob expansion: --output 'cols=DBInstanceName,Status,Description,rows=DBInstances'.

Required user input

  • RegionId: MUST be explicitly provided by the user. NEVER guess. NEVER use a default region.
  • Instance identifier: DBInstanceName or DBInstanceId depending on the API. MUST be explicitly provided.

Idempotency

For write APIs (CreateDBInstance, RestartDBInstance, UpdatePolarDBXInstanceNode, ModifyDBInstanceClass, ModifyDBInstanceMaintainTime, ModifyDBInstanceConfig, ModifyParameter, UpgradeDBInstanceKernelVersion), use --client-token.

DeleteDBInstance does NOT support --client-token; do not append it.

CLIENT_TOKEN=$(uuidgen)   # reuse on retry

On timeout / failure, retry with the same ClientToken.

Pagination

For all paginated read operations (DescribeDBInstances, DescribeTasks, DescribeSlowLogRecords, DescribeBinaryLogList, etc.), use --page-size 100 unless the user explicitly requests a different size.

  • PolarDB-X APIs typically enforce a maximum PageSize of 100.
  • Use --page-number to iterate through pages when more than 100 results exist.

Security constraints

  • NEVER expose the instance to the public internet.
  • NEVER recommend AllocateInstancePublicConnection or any public-network command.
  • NEVER ask users to provide AK/SK directly in the conversation.
  • NEVER echo credential values.

Error & Timeout Handling

When a CLI command fails, handle it according to the following rules.

Network timeout / connect-timeout / read-timeout

  • Retry up to 3 times with exponential backoff: 5s / 10s / 20s.
  • For idempotent write operations, reuse the same --client-token on retry.
  • If all retries fail, prompt the user to check local network and Region availability.

API business errors (Code/Message)

Error codeHandling
InvalidDBInstanceId.NotFound / InvalidDBInstance.NotFoundVerify DBInstanceName / DBInstanceId and RegionId
Forbidden.RAM / NoPermissionRead references/ram-policies.md
ThrottlingBack off exponentially, then retry; reduce call frequency
InternalErrorRetry up to 3 times; if still failing, suggest opening a support ticket
MissingParameter / InvalidParameterRe-read the relevant reference file and confirm all required parameters

Asynchronous tasks

For operations that return a TaskId or order ID (create / delete / restart / scale / upgrade / class change):

  1. Poll task status with DescribeTasks.
  2. Poll interval: 10 seconds.
  3. Timeout: 30 minutes (configurable).
  4. On task failure, output TaskErrorCode and TaskErrorMessage.

Preferred: Use the bundled polling script:

./scripts/poll_task.sh \
  --region  \
  --instance-id  \
  --start-time  \
  --end-time  \
  --session-id {session-id}

Manual alternative:

aliyun polardbx describe-tasks \
  --biz-region-id  \
  --region  \
  --db-instance-id  \
  --start-time  \
  --end-time  \
  --page-number 1 \
  --page-size 100 \
  --connect-timeout 3 --read-timeout 10 \
  --user-agent AlibabaCloud-Agent-Skills/alibabacloud-polardbx-ops/{session-id} \
  | jq '.Items[] | {TaskId, Status, TaskAction, TaskErrorCode, TaskErrorMessage}'

DescribeTasks returns the task list in .Items[] (NOT .Tasks[]). Each item has Status (e.g. "8" finished, RUNNING/FAILED), TaskAction, TaskId, BeginTime, FinishTime, and optional TaskErrorCode/TaskErrorMessage. A task with a non-empty FinishTime has ended; check Status for success or failure.

Unexpected output

  • If the output is empty or fields are missing, first run the command without | jq ... to check whether the default JSON output is valid.
  • If jq fails, verify the filter against the raw JSON output.
  • Use --cli-query carefully; verify the JMESPath expression against the raw JSON output.
  • All fields shown to the user SHOULD be extracted via jq filters.

ReferenceDescription
references/instance-lifecycle.mdInstance lifecycle APIs
references/scaling.mdScaling and class-change APIs
references/parameters.mdConfig and parameter APIs
references/monitoring-logs.mdPerformance, slow log, and binlog APIs
references/account-management.mdDatabase account management APIs
references/database-management.mdDatabase and table management APIs
references/backup-restore.mdBackup policy, backup set, and restore APIs
references/security-access.mdIP whitelist, SSL, TDE, KMS authorization APIs
references/sql-audit-compliance.mdSQL audit and rights-separation APIs
references/operation-tasks.mdO&M events, maintenance config, history events APIs
references/ha-migration.mdHA switch, zone migration, transform APIs
references/connection-endpoint.mdConnection string, VIP, custom endpoint APIs
references/tags-resourcegroup.mdTag and resource-group APIs
references/metadata-query.mdRegion, VPC/VSwitch, character set, data node APIs
references/cold-storage.mdCold-data volume and storage pool APIs
references/data-evaluate-migration.mdSQL evaluation and engine migration APIs
references/sql-flashback.mdSQL flashback (row-level recovery) APIs
references/cdc.mdCDC / log engine APIs
references/columnar.mdColumnar (column store) APIs
references/gdn.mdGlobal Database Network (GDN) APIs
references/mem0.mdMem0 memory engine APIs
references/cli-installation-guide.mdCLI installation, plugin, credential, and identity checks
references/ram-policies.mdRAM permissions and troubleshooting
references/index.mdReference overview and routing index
Official API ReferencePolarDB-X OpenAPI documentation

Scripts

ScriptDescription
scripts/poll_task.shPoll async task status with timeout and exponential backoff
scripts/spec_lookup.shConvert between a PolarDB-X spec code and its hardware config (cores/memory), in both directions; supports --category/--disk/--type filters and --json

Runtime dependencies (bash >= 4.0, aliyun CLI >= 3.3.3, jq >= 1.6) are declared in each script's header comments. spec_lookup.sh only needs bash + awk (no CLI/jq).

Spec code <-> hardware lookup

To resolve a spec code to cores/memory, or to find spec codes for a target hardware size, call scripts/spec_lookup.sh:

# Spec code -> hardware
./scripts/spec_lookup.sh --code polarx.x4.large.2e

# Hardware -> matching spec code(s) (filter by module / disk / type as needed)
./scripts/spec_lookup.sh --cores 8 --memory 32 --category cn --disk local

# Machine-readable output for the agent
./scripts/spec_lookup.sh --code mysql.n4.medium.25 --json
  • --category: cn (enterprise compute) / dn (enterprise storage) / standard.
  • --disk: local (custom_local_ssd) / cloud (cloud_auto).
  • --type: general / dedicated.
  • Exit codes: 0 found, 3 invalid args, 4 no match.

相关技能

Query and manage Alibaba Cloud RDS instances in the user's own account through Alibaba Cloud CLI and official RDS, VPC, BssOpenApi, and DAS OpenAPIs. Use for listing or inspecting RDS instances, zones, classes, performance, logs, parameters, databases, accounts, networks, whitelists, bills, and SQL insight statistics, or for explicitly requested instance creation, parameter/specification/description changes, account creation, whitelist changes, public endpoint allocation, whitelist-template attachment, tagging, restart, and instance deletion. Do not use this skill to diagnose incidents, troubleshoot performance anomalies, or perform root-cause analysis; it only queries current RDS instance state and executes the explicitly supported instance-management operations.

1 次安装

Use when users need command-line operations on Alibaba Cloud resources (list/query/create/update/delete), credential/profile setup, region/endpoint selection...

15 次安装

Health inspection for Alibaba Cloud PolarDB MySQL instances, generating visual HTML reports. Supports five inspection dimensions: 1. Resource Monitoring — CP...

1 次安装

Use when managing Alibaba Cloud AnalyticDB for MySQL (ADB) via OpenAPI/SDK, including the user needs AnalyticDB resource lifecycle and configuration operatio...

15 次安装

Pre-release SQL assessment and optimization for PolarDB MySQL. Combines 28+ static lint rules with Alibaba Cloud DAS dynamic diagnosis. Detects full table sc...