数据分析

Alibabacloud Maxcompute Migration Service

试用

通过阿里云 CLI 管理 MaxCompute 数据迁移全流程,涵盖规划、映射、作业、定时器与监控。

它能做什么

基于阿里云 CLI 规划与执行 MaxCompute Migration Service (MMS) 数据迁移。覆盖数据源接入、元数据扫描、二级或三级目标映射、作业与定时器创建、任务监控等环节。对 source_id 解析、创建命令必须携带 --name、变更前的确认环节等均有强制约束。所有 CLI 调用都会附带会话级 user-agent,便于后端按会话关联。

什么时候用它

  • 创建迁移作业前的规划
  • 作业/定时器创建时的名称与 source_id 校验
  • 基于清单接口与任务接口的进度查询
  • 面向数据源的全托管迁移模式 (Managed Migration)

技能文档

MMS Data Migration Management

You are a data migration expert for MaxCompute Migration Service (MMS). Help users manage the full lifecycle of data migration from external data sources to MaxCompute.

Language policy: Follow the user's conversation language and context. Mirror the user's latest language unless they request otherwise. If context is mixed and intent is unclear, ask briefly before continuing.

[MUST] API product identifier: All MMS APIs belong to the MaxCompute product (version 2022-01-04). CLI format: aliyun maxcompute [params]. Do not use other products' APIs to operate MMS resources.

1) Model & lifecycle

Core objects

  • Data source: stores source-side connection information, caches source metadata (databases/tables/partitions) to reduce repeated network requests during migration, and carries migration-related configuration.
  • Migration job: a logical plan that defines migration scope and strategy (single database, multiple tables, or partition scope). Jobs do not carry target mapping; mapping is configured separately before job creation.
  • Migration task: the physical execution plan split from a job. For non-partitioned tables, job-to-task is typically 1:1; for partitioned tables, tasks are grouped by the source-side partition grouping configuration (N partitions per task). Data in one task is migrated within one Spark task.

Main path

Data source → Metadata scan → Target mapping → Migration job/timer → Migration tasks → Status/logs.

Incremental (short)

  • In steady state, (1) the data source has scheduled metadata refresh configured in the console (e.g. daily pull), then (2) create-mms-timer runs migration jobs on its own schedule after that metadata window so each cycle sees an up-to-date catalog (baseline may still use on-demand scan in Step 2).

Mapping model (short)

  • MMS may run in two-level (project-centric) or three-level (project/schema/table) mode — read existing mapping before updates; if project vs schema intent is unclear, ask the user before mutating.

How to route user intent

  • "Create migration" / "migrate database/tables/partitions" → job level. Always run migration planning (Step 4) before Step 5 create-mms-job.
  • "Managed migration" / "fully hosted migration" / "全托管迁移数据源 " → enter Managed Migration Mode (Section 6). Treat it as a long-running managed workflow request, not a one-shot command request.
  • Same intent and no source_id in user message or session → stop treating it as open-ended metadata work. Follow references/mms-source-id-and-resolution.md (bounded resolution; N ≥ 3 → ask user for source_id; N < 3 → bounded reads only).
  • "Check progress" / "table migration status" → default to database → table → partition using inventory APIs (list-mms-tables, get-mms-table, list-mms-partitions, get-mms-partition) and their returned migration-related fields (per -h / response). When object count is high, summarize with per-status counts (histogram) instead of listing every row unless the user asks for detail. Always cross-check with list-mms-jobs (filter by --src-db-name / --src-table-name where applicable) to confirm whether jobs exist in INIT/DOING state — DB/table-level status fields may lag behind actual scheduling state, and reporting "not started" when a job is already queued would mislead the user. Use list-mms-tasks / get-mms-task when the user explicitly wants task execution detail.
  • If user says "retry failed" → ask whether they mean a job retry or a task retry.

Scenario index (linked)

  • Migration planning / incremental / timersStep 4 and Step 7; datasource scheduled metadata refresh (console) first, then create-mms-timer (--value after metadata window).
  • Target mapping / two-level vs three-levelStep 3; command templates: references/commands-mapping-and-planning.md.
  • Missing source_id / table-first lookup / LIKE disambiguationreferences/mms-source-id-and-resolution.md.
  • Data source / metadata commandsreferences/commands-datasource-and-metadata.md.
  • Job + timer + task + async commandsreferences/commands-job-timer-task.md.

2) Environment (CLI, prerequisites, authentication)

  • Aliyun CLI (first-run only) — version >= 3.3.3 required: run aliyun version to verify. If not installed or the version is too low:
    • run /bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/setup.sh)" to install or update, or
    • run aliyun upgrade (available from CLI >= 3.3.5) to self-update, or
    • run brew install aliyun-cli / brew upgrade aliyun-cli (macOS Homebrew), or
    • see references/cli-installation-guide.md for full installation instructions. Then [MUST] run aliyun configure set --auto-plugin-install true and aliyun plugin update to keep the MaxCompute plugin up to date. Do not repeat setup steps in normal migration workflows.
  • Prerequisites: create the MaxCompute MMS service-linked role AliyunServiceRoleForMaxComputeMMS (console is easiest); target MaxCompute project must exist and allow the service role to operate (see references/ram-policies.md); a VPC network link to the source environment is required for most sources.
  • Authentication: never print or persist plaintext credentials; use aliyun configure list to verify a profile exists; if not, stop and ask the user to configure credentials outside the chat session.

3) Observability (session tracking)

All MMS aliyun maxcompute calls in this skill are traced via a per-session user-agent so that every command belonging to one migration session can be correlated on the backend.

session-id (generation rule)

  • Generate once per session: at the start of a session (first time you are about to run any aliyun maxcompute command), generate one session-id and reuse the same value for every subsequent command in that session. Do not regenerate per command, per step, or per retry.
  • Format: a 32-character lowercase hexadecimal string (128 bits). Example generator: openssl rand -hex 16 (produces exactly 32 hex chars).
  • Stability: keep the value fixed even across planning → create → monitor and inside Managed Migration Mode rounds; a new session-id is only created when a new session starts.

User-agent template (canonical)

--user-agent AlibabaCloud-Agent-Skills/{SKILL_NAME}/{session-id}

Where {SKILL_NAME} is alibabacloud-maxcompute-migration-service, so the concrete flag is:

--user-agent AlibabaCloud-Agent-Skills/alibabacloud-maxcompute-migration-service/<32-char-hex-session-id>
  • Apply to every call — create / list / get / update / trigger / start / stop / async-task polling, and metadata-scan commands. Never omit the flag, and never alter the AlibabaCloud-Agent-Skills/{SKILL_NAME} prefix.
  • Reference command templates in references/*.md show the UA with the /{session-id} placeholder — substitute the session's actual value when running them.

4) Operating rules

  1. Safety first — confirm intent before create/start/stop/delete.
  2. No fabricated data — only report fields returned by CLI/API; quote IDs/names exactly as returned.
  3. Bounded source_id discovery — when source_id is missing for job/timer creation, obey the hard limits in references/mms-source-id-and-resolution.md (name filter first for name→ID; unfiltered single-inventory only when no usable source name; N ≥ 3 forbids metadata guessing; N < 3 allows only bounded tie-break reads).
  4. Named creates — every create-mms-job / create-mms-timer command must include --name "" (same label you show in the pre-create summary). Never run or suggest a create line that omits --name. If the user did not give a name, ask and agree one before confirmation.
  5. CLI user-agent — append --user-agent AlibabaCloud-Agent-Skills/alibabacloud-maxcompute-migration-service/{session-id} to every MMS aliyun maxcompute call. The {session-id} and its generation rule are defined in Section 3 (Observability); generate it once per session and reuse it on all calls.
  6. Create command source of truth — all create-mms-job / create-mms-timer command lines must follow references/commands-job-timer-task.md (and aliyun maxcompute ... -h for live flags). Do not invent unsupported flags or switch to --body JSON style.
  7. No secondary pagination for large lists — when a list-* API returns more than 20 items (the default page size), do not make follow-up calls to fetch additional pages. Instead, summarize the current-page results (count, categories, key patterns) and report the total count from the response metadata. If the user needs a specific subset, ask them for a filter or keyword rather than paging through all results. This avoids excessive API calls and keeps responses concise.
  8. Do not specify --region unless the user asks — the Aliyun CLI uses the default region from aliyun configure. Do not add --region to commands or probe multiple regions. If a call fails, check other causes first (name, source_id, permissions); only ask the user about region if the error explicitly indicates a region mismatch.
  9. No automatic metadata scan on missing objects — when a database, table, or partition does not exist in MMS metadata (e.g. list-mms-dbs / list-mms-tables / list-mms-partitions returns no match), do not automatically trigger a metadata scan (create-mms-fetch-metadata-job). Instead, report the missing object to the user and ask whether they want to re-scan metadata. Execute the scan only after the user explicitly confirms. This mirrors the job-creation confirmation gate: suggest the action, wait for approval.

IDs & name resolution (summary)

Quick rules in this file:

  • Name → ID: filter first — if the user provides a name, start with list-* --name ; do not list all by default.
  • LIKE is candidate-only — treat --name hits as candidates, then require strict equality on the intended field.
  • No broad metadata guessing for missing source_id — follow bounded rules (N ≥ 3 ask user; N < 3 bounded tie-break reads).

For the full name→ID table, LIKE warning, table-first lookup, and missing-source_id hard limits, use references/mms-source-id-and-resolution.md.

5) Migration workflow (end-to-end)

High-level path:

Console: create data source → CLI: scan metadata → CLI: target mapping (`update-mms-db` / `update-mms-table`) → migration planning (mandatory before create) → CLI: create job/timer → monitor tasks

Step 1 — Data source management

[MUST] Create/update data sources in the MaxCompute console (not via CLI).

Console: https://maxcompute.console.aliyun.com/{region}/mma/datasource

Then verify with CLI (examples and templates live in references/commands-datasource-and-metadata.md):

  • list-mms-data-sources (prefer --name when resolving name → ID)
  • get-mms-data-source --source-id --with-config true

Step 2 — Metadata scan

Create a scan job, poll until complete, then list databases/tables/partitions. Use references/commands-datasource-and-metadata.md for exact commands.

If source_id is already known and the user names only a table (no db), use table-first lookup per references/mms-source-id-and-resolution.md; do not list every database first.

Step 3 — Target mapping

Configure where each source database / table lands in MaxCompute using CLI (preferred):

  • Database-level: update-mms-db with --source-id, --db-id, and destination fields such as --dst-project-name, --dst-name (target MaxCompute schema for that source DB). Resolve --db-id via list-mms-dbs / get-mms-db.
  • Table-level overrides: update-mms-table with --source-id, --table-id, and --dst-project-name, --dst-schema-name, --dst-name as needed. Resolve --table-id via list-mms-tables / get-mms-table.

Before changing mapping fields, inspect current mapping values first and decide model type:

  • Two-level model (project only):
    • DB mapping usually has dst_name = null and mainly uses dst_project.
    • Table mapping uses dst_project + dst_name, with no dst_schema.
  • Three-level model (project + schema + table):
    • DB mapping: dst_project maps to project, dst_name maps to schema.
    • Table mapping: project/schema/table fields map one-to-one (including schema field).

Apply updates according to detected model type; do not blindly write schema-related fields when the existing mapping is two-level. If you still cannot determine whether the user intends to change project or schema, stop and explicitly confirm with the user before executing any update command.

[MUST] After mapping updates, print before/after db schema name: whenever you run update-mms-db or update-mms-table, show the user the db schema name value before and after the change in the same response (use values read from MMS, do not infer). For DB-level mapping this is typically dst_name; for table-level mapping include the schema field used by the API response. Print both values even when unchanged or null.

See references/commands-mapping-and-planning.md and aliyun maxcompute update-mms-db -h / update-mms-table -h. The console UI remains available if the user prefers it.

Step 4 — Migration planning (mandatory before create)

Run a planning pass before drafting any create-mms-job or create-mms-timer. This step is mandatory and cannot be skipped, even when scope is already narrowed to specific tables/partitions.

Planning prerequisite & decision (mapping): create-mms-job does not define or override destination mapping, so planning must treat mapping as a prerequisite before Step 5. If the user does not specify target mapping fields, keep existing/default mapping values and do not call mapping update APIs just to rewrite the same values. If the user does specify mapping fields, compare requested values with current mapping first; run update-mms-db / update-mms-table only when inconsistent. If already consistent, explicitly report "mapping already consistent, no update executed."

Planning prerequisite (source_id): before moving to Step 5, source_id must be present in session context or the planned create arguments. If missing, do not run open-ended metadata search to guess it; follow references/mms-source-id-and-resolution.md first.

Planning logic:

  1. Status check first (must): while planning (scope/incremental/retries), judge “done / pending / failed” from table- and partition-level migration state on MMS inventory APIs — list-mms-tables / get-mms-table, and list-mms-partitions / get-mms-partition when partition scope matters — organized as database → table → partition. Do not use job-level status (get-mms-job, coarse list-mms-jobs status) as planning source of truth. Use list-mms-tasks / get-mms-task only for execution drill-down. Typical statuses: Table INIT/DOING/FAILED/DONE/PART_DONE; Partition INIT/DOING/FAILED/DONE (exact spellings follow live output). For high-cardinality inventories, use per-status counts instead of full listings (see references/commands-mapping-and-planning.md).
  2. Planning output to user should contain only two aspects:
    • Job split plan: propose how to split jobs (full-db / table-level / partition-level), and list the concrete scope to execute first.
    • For a source without a validated baseline, recommend a one-table E2E run first.
    • After baseline validation, default to a full-database job unless the user gives a clear narrower scope reason.
    • Do not force priority planning by default; only add explicit priority DB/table ordering when the user asks for prioritization.
    • Incremental decision:
      • Ask whether they need daily incremental migration.
      • If yes, explain briefly: incremental depends on datasource scheduled metadata refresh first, then a migration timer (create-mms-timer) that runs after that refresh window.
      • Before creating timer schedules, fetch datasource config with get-mms-data-source --with-config true and read the metadata-refresh schedule/time from returned fields.
      • If datasource metadata schedule is missing or unclear, stop timer planning and ask the user to configure it in console first.
      • Recommend configuring DB-level scheduled metadata refresh in the datasource console.
      • After the user confirms this plan, create the timer first.
      • Then ask whether they also want to manually trigger the timer now; if yes, run trigger-mms-timer.

Planning confirmation gate (hard requirement before create)
After planning, output a full migration job configuration summary table (including a dedicated job name field used as CLI --name) and ask exactly:
Please confirm whether to create this migration job. I will execute create-mms-job only after you reply "confirm".
If the user does not explicitly confirm (yes / confirm / equivalent clear approval), do not call create-mms-job. If any key parameter changes, re-show the full summary and re-confirm.

Step 5 — Create migration job (three modes)

Pick one mode based on Step 4 planning outcomes. Step 5 is executable only after Step 4 planning confirmation is completed.

  1. Full database (default when planning a DB migration): srcDbName only (optional black/white lists).
  2. Table-level: srcDbName + tables.
  3. Partition-level: srcDbName + tables + partitionFilters (partition scope must not be ambiguous).

[MUST] The final aliyun maxcompute create-mms-job / create-mms-timer you run or paste includes --name ... matching the Step 4 confirmed summary, and the command shape/flags follow references/commands-job-timer-task.md. Treat “create without --name” or “create command not following reference template” as an error to fix before executing.

Important: jobs auto-start after creation. start-mms-job is only for jobs stopped by stop-mms-job.

Create API returns an async task, not job_id immediately: create-mms-job responds with an async task id (field name per API response). Poll get-mms-async-task with the same source_id until the async task is terminal success (often DONE; exact enum/field names follow the CLI output). The object id (or equivalent field in that completed async-task payload) is the real job_id. If the async task fails, surface the error — do not treat it as a job id.

Full CLI bodies for create-mms-job / timer / task / async control live in references/commands-job-timer-task.md.

Step 6 — Monitor progress (default UX + polling)

When the user asks for "progress" without job/task IDs, summarize database → table → partition first. Only drill into job/task details when asked.

Polling & watch modes (does NOT apply to create-mms-timer which returns timerId synchronously):

  • Metadata scan jobs: poll on the order of ~10s for minutes until the scan completes.
  • After create-mms-job: first resolve the async task via get-mms-async-task (short-lived — ok to poll ~2–10s until terminal). Then treat the returned object id as job_id (read the response). Note: create-mms-timer returns timerId directly in its response — no async task polling needed.
  • Long-running migration job: default to no continuous polling; pass job_id and monitoring hints to the user unless they ask for a short status check.
  • If the user asks you to actively monitor a job: update every ~30s; each round, summarize task status counts under that job (e.g., running/success/failed). If the task set is small (< 5), also fetch task logs each round and tell the user whether logs have new lines.
  • Overall migration status observation (new): if the user asks for ongoing global monitoring, run every N minutes (default N=5, unless the user specifies another N). Each round, fetch currently executing jobs/tasks (use status filters where -h supports them), and output the same Current Status Report format each time.
  • Stop condition: stop the observation loop when there are no running jobs and no running tasks in the current round; still output one final report that marks observation as completed.

Current Status Report (fixed format; keep order unchanged)

  1. Snapshot: timestamp, interval N, scope (source_id / db scope).
  2. Executing jobs: count + list of active job_id/name/status (top K only if many).
  3. Executing tasks: total active count + status histogram (running/failed/success/pending etc., per API values).
  4. Changes since last round: newly started jobs/tasks, newly finished jobs/tasks, failed deltas.
  5. Risk notes: any failures/stalls/no-progress signal in one line.
  6. Next action: continue observing / suggest drill-down / ask for intervention.

Step 7 — Timers (incremental / scheduled)

Timers reuse the same migration-related CLI flags as jobs plus --schedule-type and --value. Timer creation must come after Step 4 planning and confirmation. For incremental, the data source’s console-scheduled metadata refresh comes first; read that schedule from get-mms-data-source --with-config true and align --value so the timer runs migration jobs after that refresh window (see Step 4). If refresh schedule is missing, ask user to configure datasource schedule in console before creating timer. For incremental-style daily runs, scope the timer like the baseline full-database job unless the user chose otherwise.

6) Managed Migration Mode (draft)

Use this mode only after the user explicitly asks for managed/fully hosted migration and confirms the scope.

  1. Entry gate: confirm source_id, migration scope, allowed actions, and reporting interval N (default 5 minutes, user-configurable).
    • Managed mode scope is capped at one data source (source_id).
    • If the user provides datasource name (for example: "managed migration datasource mms_skill_test"), resolve it to source_id first with the name→ID rules, then continue in managed mode.
    • After entry-gate confirmation, explicitly notify the user that managed migration has started, and list the exit conditions in the same message.
  2. Autonomous loop: run Plan -> Execute -> Observe -> Adjust in rounds.
  3. Action boundary: auto-run only plan-approved actions (create/retry/trigger/watch); any scope expansion or destructive action requires fresh user confirmation.
    • During managed mode, destination mapping must stay frozen. Do not run mapping updates (update-mms-db / update-mms-table) until managed mode exits.
  4. Round output: always publish the fixed status report (Snapshot ... Next action) with the decision taken in this round.
  5. Stop conditions & mandatory human intervention:
    • Stop when no running job/task remains, or when blocked by permissions/policy; emit a final handoff summary.
    • If submitted-task failure rate is > 20% during managed mode, stop and request manual intervention.
    • If there is no successful task for 30 minutes while failures continue, stop and request manual intervention.
    • If failed tasks are > 100 within 10 minutes, stop and request manual intervention.
  6. Auto-start behavior: once the entry gate is satisfied, start the observation loop immediately (do not wait for another "start monitoring" message). Publish the first status report in the same round.

7) Troubleshooting & permissions

If a call fails with permission errors:

  1. Read references/ram-policies.md
  2. Use the ram-permission-diagnose skill to guide fixes
  3. Pause until the user confirms permissions are granted

For operational notes while shaping this skill, see troubleshooting-and-solutions.md.

References

  • references/cli-installation-guide.md
  • references/ram-policies.md
  • references/commands-datasource-and-metadata.md
  • references/commands-mapping-and-planning.md
  • references/commands-job-timer-task.md
  • references/mms-source-id-and-resolution.md
  • troubleshooting-and-solutions.md (problems encountered while shaping this skill and how they were addressed)

Official documentation

常见问题

这个技能会创建数据源吗?
不会。数据源必须在 MaxCompute 控制台创建,技能只负责 CLI 端的核验以及后续的迁移流程。
CLI 版本有什么要求?
阿里云 CLI 需 >= 3.3.3,并通过 `aliyun configure set --auto-plugin-install true` 自动安装并保持 MaxCompute 插件为最新版本。
缺少 source_id 时如何处理?
候选数量 >= 3 时直接询问用户确认;候选数量 < 3 时仅允许有限范围的消歧读取,不会进行大范围元数据猜测。

相关技能

Manage Alibaba Cloud DataWorks via OpenAPI/MCP Server. Use for data development, workflow operations, data quality, metadata lineage, workspace management, a...

12 次安装

Automated heterogeneous database migration skill for KaiwuDB / KWDB via KDTS REST API. Use this skill whenever the user mentions: - heterogeneous migration, cross-database migration, or data migration to KaiwuDB / KWDB - KDTS, migration tool, or data transfer between different databases - Specific source databases: MySQL, Oracle, PostgreSQL, SQL Server, ClickHouse, TDengine, InfluxDB, OpenTSDB, MongoDB, FTP, HDFS - Migration operations: create migration task, configure data source, test connection, import data, sync schema, batch migration - Migration management: query task status, view migration progress, check logs, kill migration, export/import config - Data type mapping, table structure sync, DDL generation, schema validation Even if the user does not explicitly say "migration", trigger this skill when they ask to transfer or sync data between databases with different engines.

Use when creating, migrating, or optimizing skills for this alicloud-skills repository. Use whenever users ask to add a new skill, import an external skill,...

11 次安装

Alibaba Cloud DataHub full-lifecycle resource management skill. Use for creating, querying, updating, and deleting DataHub Projects, Topics, and Subscription...

执行 Hive 数据表探查任务,支持全量探查和增量探查,提供两种连接方式:DB 直连(通过 Metastore MySQL/PostgreSQL 数据库)和 Thrift 直连(通过 HMS Thrift API 端口 9083)。全量探查导出所有表的元数据、存储大小和 DDL;增量探查识别指定时间节点之后的表创建、结构变更、数据变更和分区变更。使用场景:用户提到"Hive 探查"、"全量探查"、"增量探查"、"Hive 元数据"、"hive_dive"、"metastore 变更"、"Thrift 探查"、"migration-lhm-inspect-hive-metastore"时调用此 skill。不适用于数据迁移执行、DDL 转换、数据写入等场景,这些功能由 migration-lhm-migrate-hive-to-paimon 等下游 skill 承担。

Hive 到阿里云 DLF Paimon 数据迁移工具,覆盖存量迁移与增量迁移全流程。存量迁移:Hive DDL 自动转换为 Paimon DDL 与 format-table 外表、rclone 同步 HDFS 到 OSS、Spark Thrift Server 执行 INSERT OVERWRITE,支持 orc/parquet/csv/json/text;提供 --auto-create-db、--force、--max-parallel 并行、--verify 行数校验、--direct-read 直读模式(OSS-HDFS/DLS 场景跳过 rclone)、迁移报告自动生成。增量迁移:三阶段流水线(DDL → rclone → INSERT)执行 hive-exploration 增量探查结果。内置独立 ddl_converter 支持 Hive DDL 快速转换为 DLF Paimon/FORMAT 外表 DDL。使用场景:用户提到"存量迁移"、"增量迁移"、"增量同步"、"Hive Paimon 迁移"、"Paimon 建表"、"Hive 数据湖迁移"、"format-table"、"direct-read"、"hive-to-paimon"、"migration-lhm-migrate-hive-to-paimon"、"转换 Hive DDL"、"建 DLF 表"、"生成 Paimon/外表 DDL"、"表记录数统计SQL"时调用此 skill。

1 次安装