Tair 数据库 AI 助手

本 Skill 聚焦阿里云 Tair(兼容 Redis OSS)数据库智能运维,通过 aliyun CLI DAS 插件调用 get-yao-chi-agent API 进行诊断和分析。

架构阿里云 CLIDAS 插件(Signature V3)get-yao-chi-agent API → Tair 智能诊断

支持的能力

能力说明
实例列表查询按地域、类型、状态列出和过滤 Tair/Redis 实例
内存使用分析内存消耗拆解、碎片率、淘汰统计
热点 Key 检测热 Key 识别、访问频率分析、缓存优化
大 Key 分析大 Key 检测、内存分布分析、优化建议
延迟诊断命令延迟分析、慢命令检测、网络延迟排查
慢日志分析慢命令日志查询、高延迟操作识别
参数调优实例参数解释、配置建议、性能影响分析
连接会话分析连接数监控、客户端会话排查、连接池优化
备份状态检查备份完成验证、保留策略、时间点恢复
性能监控QPS/TPS/命中率/带宽等核心指标分析
即将过期实例查询订阅实例到期提醒
安全配置审计白名单、SSL/TLS、密码策略、安全审计
存储优化数据结构优化、TTL 策略、内存效率提升
代理诊断代理层性能分析、连接路由、带宽瓶颈检测

安装

预检查:需要 Aliyun CLI >= 3.3.1
运行 aliyun version 验证 >= 3.3.1。如果未安装或版本过低,
参阅 references/cli-installation-guide.md 获取安装说明。
然后 [必须] 运行 aliyun configure set --auto-plugin-install true 启用插件自动安装。

安装 aliyun CLI

curl -fsSL https://aliyuncli.alicdn.com/install.sh | bash

aliyun version # 验证 >= 3.3.1

启用插件自动安装

aliyun configure set --auto-plugin-install true

安装 DAS 插件(get-yao-chi-agent 需要插件支持 Signature V3)

aliyun plugin install --names aliyun-cli-das

更新所有已安装插件到最新版本

aliyun plugin update

安装 jq(用于 JSON 响应解析)

macOS:

brew install jq

Ubuntu/Debian:

sudo apt-get install jq

参数确认

重要:参数确认 —— 在执行任何命令或 API 调用之前,
所有用户可自定义参数(例如 RegionId、实例名、CIDR 块、
密码、域名、资源规格等)都必须与用户确认。
未经用户明确批准,不要假设或使用默认值。
参数必填/可选说明默认值
query必填自然语言查询内容(包括地域、实例信息)-
--session-id可选多轮对话的会话 ID-
--profile可选aliyun CLI profile 名称default

认证

本 Skill 依赖 aliyun CLI 默认凭证链进行认证——Skill 工作流中无需显式处理 AK/SK。

CLI 按以下优先级自动解析凭证:

  1. 命令行上的 --profile flag
  2. ALIBABA_CLOUD_PROFILE 环境变量
  3. ALIBABA_CLOUD_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_SECRET 环境变量
  4. 配置文件 ~/.aliyun/config.json(当前 profile)
  5. ECS 实例 RAM 角色(如果在 ECS 上运行)

凭证设置和配置模式(OAuth、AK、StsToken、RamRoleArn、EcsRamRole 等)见 references/cli-installation-guide.md

RAM 策略

references/ram-policies.md

核心工作流

所有智能运维操作都通过 scripts/call_yaochi_agent.sh 调用,它封装了 aliyun das get-yao-chi-agent(DAS 插件 kebab-case 命令,支持 Signature V3)并解析流式响应。

执行任何 CLI 命令之前必须启用 AI-Mode;工作流结束后必须禁用:

[必须] 在执行 CLI 命令前启用 AI-Mode

aliyun configure ai-mode enable

aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-tair-ai-assistant"

实例管理

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "List Tair instances in Hangzhou region"

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Show detailed configuration of instance r-xxx"

性能诊断

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Analyze instance r-xxx performance in the last hour"

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Show slow commands of instance r-xxx"

内存分析

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Analyze memory usage of instance r-xxx"

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Detect big keys in instance r-xxx"

热点 Key 检测

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Find hotspot keys in instance r-xxx"

参数调优

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "How to tune maxmemory-policy for instance r-xxx"

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Explain hz parameter"

连接与会话

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "How to troubleshoot high connection count in instance r-xxx"

备份恢复

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Show backup status of instance r-xxx"

多轮对话(使用上次响应中的会话 ID)

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "Continue analysis" --session-id "<session-id>"

指定 profile

bash $SKILL_DIR/scripts/call_yaochi_agent.sh "List instances" --profile myprofile

从 stdin 读取

echo "List instances" | bash $SKILL_DIR/scripts/call_yaochi_agent.sh -

[必须] 工作流结束后禁用 AI-Mode

aliyun configure ai-mode disable


### 示例问题

| 场景 | 示例问题 |
|----------|------------------|
| 实例管理 | List Tair instances in Beijing region |
| 性能诊断 | How to troubleshoot high CPU usage in instance r-xxx |
| 慢日志分析 | Show slow commands in instance r-xxx in the last hour |
| 内存分析 | Analyze memory fragmentation of instance r-xxx |
| 大 Key 检测 | Detect big keys in instance r-xxx and suggest optimization |
| 热点 Key | Find hotspot keys in instance r-xxx |
| 参数调优 | What does maxmemory-policy parameter mean |
| 主从复制 | How to handle high replication delay in instance r-xxx |
| 备份恢复 | When was the latest backup of instance r-xxx |
| 连接排查 | Instance r-xxx connections are full |
| 安全审计 | Check security configuration of instance r-xxx |

成功验证

references/verification-method.md

清理

本 Skill 聚焦查询和诊断能力,不创建任何资源,无需清理。

以下操作不在本 Skill 范围内:

  • 创建/删除 Tair 实例
  • 更改实例规格
  • 购买/续费实例

API 与命令表

references/related-apis.md

最佳实践

  1. 实例 ID 格式:Tair/Redis 实例 ID 通常以 r- 开头,查询中包含完整实例 ID
  2. 地域指定:在自然语言查询中明确指定地域(例如“Hangzhou region”、“Beijing region”)以提高查询准确性
  3. 多轮对话:复杂诊断场景使用 --session-id 保持上下文连续性
  4. 并发限制:每账号最多 2 个并发会话,避免发起多个并行调用
  5. 高风险操作:对于涉及参数变更、主从切换的操作,始终提醒用户先在测试环境验证
  6. 限流处理:如果遇到 Throttling.UserConcurrentLimit 错误,等待上一次查询完成后再重试
  7. 凭证安全:使用 aliyun configure 管理凭证,绝不在脚本中硬编码 AK/SK

参考链接

参考说明
references/cli-installation-guide.mdAliyun CLI 安装和配置指南
references/related-apis.md相关 API 和 CLI 命令列表
references/ram-policies.mdRAM 权限策略列表
references/verification-method.md成功验证方法
references/acceptance-criteria.md验收标准

文档 2 / 6:alibabacloud-sas-multiaccount-manage