¥
立即购买

系统组件维护流程设计

46 浏览
3 试用
0 购买
Dec 11, 2025更新

本提示词专为系统分析师设计,用于生成标准化、可操作的系统组件维护流程文档。通过结构化的工作流程和专业技术写作规范,确保输出的维护方案具备清晰的步骤说明、风险控制措施和验证标准,适用于硬件维护、软件功能更新、数据库优化等多种系统维护场景,帮助提升系统稳定性和运维效率。

维护目标

  • 确保数据中心核心交换机对(核心A/核心B,双机热备,启用VRRP与链路聚合)在承载南北向流量的前提下完成周期性健康检查与验证,避免业务中断。
  • 验证并固化高可用能力:VRRP主备切换可控、链路聚合(LACP)状态一致、控制面邻接稳定。
  • 完成配置与系统状态备份归档,识别潜在隐患并形成整改项。
  • 恢复至既定设计状态(含VRRP优先级/抢占策略),确保监控与告警恢复正常。

前置条件

  • 变更与窗口
    • 已获批准的维护变更单与维护窗口(建议业务低峰,预留回退时间≥维护窗口的30%)。
    • 利益相关方已通知(应用/安全/平台/机房/网络监控),冻结窗口内的其他网络变更。
  • 环境与信息
    • 设备信息:型号、序列号、操作系统版本、许可状态、机框与板卡拓扑、上/下联端口与端口通道清单。
    • 逻辑信息:VRRP实例与VIP清单、VLAN与SVI IP、路由协议与邻接对端(OSPF/BGP/静态)、LACP对端与成员、STP根桥策略、NTP/Syslog/SNMP/AAA配置。
    • 管理与访问:已验证的带外管理(OOB)与Console访问、变更审批账号与只读审计账号、远程存储/跳板机可用性。
  • 工具与资源
    • 运维笔记本(终端/串口客户端/SSH)、Console线、带外管理连通、工单与CMDB访问。
    • 光纤清洁工具与备用模块(常用波长SFP/SFP+/QSFP)、配电接入许可、ESD防护。
    • 监控系统(流量/告警/日志)与观测工具(ping/iperf/流量镜像或采样工具),时钟源可用。
  • 人员与分工
    • 变更负责人(总体把控与决策)、现场网络工程师(执行/回退)、监控工程师(KPI观察)、应用代表(关键业务探针确认)、审批人(必要时授权中止/回退)。
  • 回退策略(明确且可执行)
    • 已完成当前配置与系统状态的完整备份(启动配置、运行配置、license、镜像与启动引导、技术支持信息包)。
    • 预案1:VRRP切换失败或丢包超阈值,立即回切原主;预案2:发现硬件风险不影响当前业务时,保持现状并生成后续更换计划。
  • 安全注意事项
    • 避免在承载VRRP Master的设备上进行高风险操作(如调试级别日志、批量接口变更);严禁启用未经评估的动态调试命令。
    • 光纤拔插前后进行端面清洁,禁止直视光纤端面;静电防护到位。
    • 严禁同时操作两台设备的同一冗余面(如同时调整两端LACP/路由),防止瞬间双断。
    • 两台设备的电源应来自不同配电回路,维护中不得同时断开双路市电/UPS。

操作步骤

以下步骤默认核心A为当前VRRP Master,核心B为Backup。若现场状态相反,请对调角色描述。每步包含操作说明与预期结果。

  1. 维护前基线采集与告警确认

    • 操作:
      • 在核心A/B上分别采集:CPU/内存/转发表与TCAM利用率、环境电源/风扇/温度、接口与端口通道状态、光模块DOM、错误计数(CRC/丢包/重传)、VRRP状态(实例/优先级/抢占/定时器)、LACP对端与成员一致性、STP角色与阻塞端口、路由邻接与收敛计数(BGP/OSPF/静态)、ARP/ND表项规模与老化、NTP/Syslog/SNMP/AAA状态、关键日志(近24h)。
      • 确认监控平台无未处理的红色告警;若有,评估是否阻断维护。
    • 预期结果:基线数据完整留存,无影响维护的未决告警。
  2. 配置与镜像备份(双机)

    • 操作:
      • 备份运行配置与启动配置至远端安全存储;记录校验值(MD5/SHA256)。
      • 备份当前系统镜像、BootLoader版本信息、license与硬件清单;导出技术支持信息包(show tech/diag)。
    • 预期结果:备份可用且可追溯,校验一致。
  3. 维护期VRRP策略固化(防抖动)

    • 操作:
      • 在当前Master(核心A)上临时关闭VRRP抢占功能,记录现有优先级与追踪策略;保持Backup(核心B)不变。
      • 确认两个设备的VRRP定时器一致;检查FHRP相关告警为空。
    • 预期结果:VRRP状态稳定,维护期间不会因抢占导致业务反复切换。
  4. 计划性主备倒换(验证高可用,控制分流)

    • 操作:
      • 将核心A的对应VRRP实例优先级临时下调至低于核心B(或触发追踪对象降权),监控VRRP状态转换为Backup。
      • 观察LACP聚合上行/下行端口通道在核心B上转为转发状态,确认端口成员无单臂或不一致。
      • 通过探针与监控验证关键业务连续性(建议多VLAN、多VRF探测),允许短暂丢包在可接受阈值内(常见1–3个VRRP周期)。
    • 预期结果:核心B成为VRRP Master,业务连续,监控KPI在阈值内,无异常告警持续。
  5. 备机侧(当前Backup:核心A)硬件巡检与轻量纠正

    • 操作:
      • 检查电源/风扇/温度/背板/板卡/堆叠或虚拟机箱状态,无红色告警;必要时清洁风道与光口端面(不停流)。
      • 检查光模块DOM(电/光功率、温度、电流),对接收功率接近灵敏度阈值或误码率上升链路,进行纤芯清洁与跳纤替换;必要时更换备件(不涉及汇聚关键上联时可现场更换,涉及关键上联需另行窗口)。
      • 记录异常接口与错误计数,抓取近时段流量峰值与丢弃原因(队列/拥塞/策略)。
    • 预期结果:备机硬件健康,错误计数得到解释或清零后观察,未引入新的告警。
  6. 备机侧(核心A)系统与配置巡检

    • 操作:
      • 核对系统版本与既定基线;若有厂商安全公告或强制补丁需求,形成后续独立升级变更,不在本次周期维护中实施。
      • 校验NTP对时、Syslog送集、SNMP Trap/采集、AAA可用性;确认未启用高频调试日志。
      • 校验关键控制面:BGP/OSPF邻接稳定、路由前缀计数与策略(过滤/重分发/社区)与上次基线一致;检查BFD状态(如有)。
      • 校验二层:STP根桥角色符合设计(数据中心常固定根),Root Guard/Loop Guard/BPDU Guard策略在关键口启用;LACP系统ID/速率/超时一致。
      • 归档差异:与备份配置做差异比对,确认无配置漂移。
    • 预期结果:系统与配置符合基线;差异均有来源说明或生成整改单。
  7. 受控恢复或保持(视策略)

    • 操作:
      • 若设计要求核心A为常态Master,按计划将核心A优先级恢复并手动切回;若常态无主从要求,则保持核心B为Master,稍后在步骤10统一恢复。
      • 切回时同样进行探针/监控观察,确认丢包在阈值内。
    • 预期结果:切回成功或策略保持,业务连续。
  8. 对另一台设备(当前Backup或Master:核心B)重复步骤5–6

    • 操作:按照相同检查与纠正策略在另一台设备上执行,确保过程中保持单点受控,不做双端同时操作。
    • 预期结果:双机硬件与系统均通过巡检。
  9. VRRP与LACP综合一致性校验与恢复设计态

    • 操作:
      • 按设计恢复VRRP优先级与抢占策略;核对追踪对象(上联、关键下联、BFD)状态正常。
      • 复核所有Port-Channel聚合状态、成员一致性、速率/双工/MTU匹配;确认无单臂转发。
    • 预期结果:VRRP状态与设计一致,LACP全绿。
  10. 维护后备份与归档

  • 操作:
    • 备份两台设备的运行/启动配置与技术信息包;与维护前备份比对,归档差异说明。
    • 更新CMDB与运维记录,提交隐患与整改清单。
  • 预期结果:备份完整,审计可追踪。
  1. 观察期与关闭变更
  • 操作:
    • 维持30–60分钟观察期:监控CPU/内存、接口误码、丢包、路由邻接抖动、VRRP/端口通道稳定度、关键业务探针与日志告警。
    • 无异常后关闭变更;如有异常,按回退或故障单流程处理。
  • 预期结果:KPI稳定,无新告警;变更关闭。

注:CLI命令名称与路径以具体厂商设备为准。标准参考指令包括但不限于:show environment/power/fan, show interfaces counters/transceiver, show port-channel/lacp, show vrrp brief, show spanning-tree, show ip route/bgp/ospf neighbor, show arp/nd, show logging, show platform resources/forwarding utilization, show ntp associations, show snmp/syslog status。

风险与应对

  • VRRP双主/震荡
    • 风险:抢占/优先级配置不一致或L2中断导致VRRP组分裂。
    • 预防:维护前统一定时器与抢占策略;维护期关闭抢占;确认组播/多播泛洪正常;保留对端心跳路径稳定。
    • 处置:立即将一侧优先级降至最低并核对二层连通,恢复后再渐进提升。
  • LACP不一致/单臂黑洞
    • 风险:一侧聚合参数变化或成员端口异常,导致散列失败或单端转发。
    • 预防:维护中不改动聚合关键参数(系统ID、速率、超时);先检查再操作;逐成员验证。
    • 处置:将异常成员置为down,保持最小有序成员数;修复后再加入聚合。
  • STP拓扑震荡/环路
    • 风险:根桥漂移、接口误接或环路导致广播风暴。
    • 预防:在接入层启用Root/Loop/BPDU Guard;核心层固化根桥;维护期间不调整STP优先级。
    • 处置:立即阻断可疑环路端口,定位源端,恢复后渐进放通。
  • 路由邻接抖动/黑洞
    • 风险:BGP/OSPF参数漂移或接口 flap 导致收敛异常。
    • 预防:维护前冻结路由策略变更;不清空邻接;观察BFD/keepalive。
    • 处置:必要时手工抑制通告(如对等体shutdown)并引导至冗余路径,恢复后再放通。
  • 光模块/链路衰耗异常
    • 风险:DOM接收功率接近阈值导致间歇性丢包。
    • 预防:定期清洁与功率测量;阈值告警接入监控。
    • 处置:更换跳纤/模块或调整链路预算,必要时调整波长/速率与均衡。
  • 配置漂移/人为误操作
    • 风险:多工程师并发或会话异常导致配置漂移。
    • 预防:单操作者锁定、命令行确认模式、变更步骤列表化;全程会话记录。
    • 处置:使用维护前备份一键回退;变更回放审计定位问题点。
  • 电源/环境双点同时失效
    • 风险:两台设备接入同一配电回路或维护中同时操作。
    • 预防:确认A/B电源来自不同回路;严格单侧操作。
    • 处置:立即恢复至少一路供电;监测温度与风扇转速,必要时降载。

验证方法

  • 功能与业务
    • 多VLAN/多VRF跨段探测:对VRRP VIP与关键服务器进行ICMP探测(包长含MTU-头部,验证碎片),期望丢包为0、时延与抖动在基线±20%内。
    • 南北向关键交易/接口探针:应用侧确认核心业务交易成功率、时延在SLA内。
  • 控制面
    • VRRP:所有实例状态与设计一致(Master/Backup/优先级/抢占),切换时间在预期内。
    • LACP:聚合口Up,成员一致,无Individual/Defaulted状态,散列分布均衡无单向。
    • 路由:BGP/OSPF邻接稳定,收敛后前缀计数与策略与维护前一致;BFD会话Up。
    • 二层:STP根桥未变化,TCN计数无异常飙升;MAC/ARP/ND学习速率正常。
  • 数据平面与资源
    • 接口错误计数:CRC/丢弃/重传保持在告警阈值以下,清零后持续观察无递增异常。
    • 资源:CPU/内存/转发表/TCAM利用率在基线范围内,无异常尖峰。
  • 运维与合规
    • NTP同步、Syslog完整送达、SNMP采集正常,告警清零。
    • 配置差异已归档说明,备份校验通过。
  • 验收标准(建议)
    • 维护全过程单次切换丢包不超过3个VRRP周期;无持续告警5分钟以上;控制面邻接在3分钟内稳定;核心业务探针通过率=100%。

相关文档

  • 网络高层与低层设计文档(拓扑、VLAN/VRF、IP规划、STP根桥策略、路由策略基线)
  • 高可用设计说明(VRRP实例与优先级/抢占策略、追踪对象定义、故障域划分)
  • 设备资产与配置基线(型号、序列号、操作系统版本、许可清单)
  • 监控与告警标准(KPI阈值、告警路由与升级路径)
  • 变更管理流程与回退预案(变更单、沟通名单、窗口审批记录)
  • 厂商技术参考(硬件安装与安全手册、CLI参考、MIB参考、安全公告/推荐补丁)
  • 维护记录与审计归档(维护前后备份、差异报告、隐患与整改清单)

Maintenance Objectives

  • Upgrade the Order Settlement microservice (Spring Boot) to a new functional version while maintaining compatibility with the Payment Gateway v2 API.
  • Perform a controlled gray/canary release to ensure zero/minimal downtime and preserve existing SLAs.
  • Verify backward/forward API compatibility for upstream/downstream consumers and the payment gateway.
  • Ensure data integrity, idempotency, and safe database evolution during the rollout.
  • Provide a verified rollback path.

Prerequisites

  • Environments: non-production (Dev/QA/Staging) and Production available and isolated.
  • Access and roles:
    • Release Manager: change window ownership and approval.
    • Service Owner/Developers: code, build, and application-level validation.
    • QA: test execution and sign-off.
    • SRE/Operations: deployment, traffic control, monitoring, and rollback execution.
  • Tooling:
    • Source control and CI/CD pipeline (e.g., Git-based repository with a build pipeline).
    • Container registry and runtime (containerized Spring Boot service).
    • Deployment platform supporting traffic splitting (e.g., Kubernetes + ingress/service mesh or load balancer with weighted routing).
    • Observability stack: metrics (e.g., Prometheus), logs (e.g., ELK), tracing (e.g., OpenTelemetry).
    • API contract tools: OpenAPI spec, openapi-diff (or equivalent), consumer-driven contract testing tool (e.g., Pact).
    • Database migration tool: Flyway or Liquibase.
    • Feature flagging capability (built-in or managed service).
  • Documentation and artifacts:
    • Versioned OpenAPI specification for the microservice and documented Payment Gateway v2 interface.
    • Proposed database schema change scripts (forward and rollback where feasible).
    • Runbook with alert thresholds, SLOs, and escalation paths.
    • Payment gateway v2 sandbox credentials and production credentials safely stored in a secret manager.
  • Change window approved and communicated to stakeholders.
  • Freeze on unrelated changes to the service and its database during the maintenance window.

Safety notes:

  • Do not introduce non-backward-compatible schema or API changes without a staged deprecation plan.
  • Do not log payment card data or sensitive PII; ensure logs are redacted/anonymized.
  • Validate that retry policies and idempotency keys are in place before increasing traffic.
  • Validate timeouts and circuit breakers when calling the payment gateway to avoid cascading failures.

Operating Steps

  1. Design and Impact Analysis

    • Action: Document all functional changes, identify affected endpoints, workflows, message schemas, and database entities. Map dependencies: payment gateway v2, message broker topics (if any), and downstream consumers.
    • Expected result: Approved impact assessment including API change inventory, data model changes, and dependency list with compatibility status (backward/forward).
  2. API Compatibility Planning

    • Action: Update the OpenAPI spec. Define compatibility strategy:
      • Backward-compatible changes only (additive fields/endpoints).
      • For any breaking changes, provide dual-version endpoints or feature-flagged behavior; publish deprecation notice.
    • Expected result: Versioned OpenAPI spec with compatibility notes and deprecation timeline.
  3. Contract and Compatibility Tests

    • Action:
      • Run openapi-diff to compare old vs new specs; confirm no breaking changes or document mitigation if present.
      • Execute consumer-driven contract tests with upstream/downstream services.
      • Validate Payment Gateway v2 contract using sandbox with the new client code (authentication, headers, error codes, timeouts).
    • Expected result: Contract tests pass; any deviations are resolved or mitigated by shims/feature flags.
  4. Database Migration Preparation

    • Action:
      • Design forward-only, backward-compatible migrations (e.g., add nullable columns before code depends on them; avoid destructive changes).
      • Prepare rollback scripts where safe (for additive changes, rollback may be a no-op).
      • Review locking/long-running migration risks; plan online/partitioned or phased migrations.
    • Expected result: Migration scripts reviewed, tested on a schema copy, and stored in version control.
  5. Implementation and Feature Flags

    • Action:
      • Implement code changes with toggles for new behaviors (e.g., new settlement logic or payment handling) so old behavior can be re-enabled without redeploy.
      • Ensure idempotency keys on settlement and payment requests; confirm retry/backoff policy and circuit breaker thresholds (e.g., with resilience4j).
    • Expected result: Build integrates feature flags and resilience policies; both paths covered by tests.
  6. Build and Static Checks

    • Action:
      • Build artifact with reproducible versioning (e.g., semver tag, commit SHA).
      • Run unit tests, static analysis, dependency checks (e.g., OWASP dependency scan).
    • Expected result: Clean build, security checks pass, artifact published to registry.
  7. Staging Deployment and Data Migration (Pre-Prod)

    • Action:
      • Deploy database migrations to staging.
      • Deploy the new service version to staging. Keep new behavior disabled by feature flags where applicable.
      • Run integration tests against a payment gateway sandbox, including success/failure, timeouts, and edge cases (duplicate payments, partial refunds).
    • Expected result: All tests pass in staging; no schema or runtime regressions observed.
  8. Performance and Resilience Validation (Staging)

    • Action:
      • Execute load tests at baseline and peak loads; measure success rate, p95/p99 latency, and resource utilization.
      • Validate circuit breaker and retry behavior against induced gateway failures in staging/sandbox.
    • Expected result: Metrics within SLO targets; no resource saturation or instability.
  9. Production Readiness Review

    • Action:
      • Confirm monitoring dashboards, alerts, and log filters for the new version/feature flags.
      • Confirm runbook, rollback plan, and on-call coverage for the change window.
      • Verify production secrets and configuration (keys, endpoints, timeouts) are correct.
    • Expected result: Go/No-Go approval recorded.
  10. Pre-Deployment in Production (Zero-Impact)

    • Action:
      • Apply database migrations in production (backward-compatible, online). Monitor for locks and replication lag.
      • Pre-provision the new version deployment as a canary instance(s) with 0% traffic. Health checks must pass.
    • Expected result: Production schema ready; new pods/instances healthy and idle.
  11. Canary Release and Traffic Ramp

    • Action:
      • Route 1% production traffic to the canary. Gate on the following for at least 15–30 minutes:
        • HTTP success rate >= 99.5% (or team SLO), 5xx error rate ≤ baseline + 0.1%.
        • p95 latency within 10% of baseline.
        • No increase in payment declines unrelated to user behavior; no spike in settlement retries.
      • If healthy, increase to 5% (30–60 minutes), then 25%, 50%, and 100%, monitoring at each step.
      • Keep new feature flags OFF initially; then enable flags gradually at 25–50% stage to validate new behavior.
    • Expected result: Traffic increases without breaching guardrails; logs and metrics remain within thresholds.
  12. Validation During Rollout

    • Action:
      • Perform live checks on key flows: order creation, settlement, payment authorization/capture, idempotent retries, refund/reversal if applicable.
      • Confirm no schema-related errors and no serialization issues across services.
    • Expected result: Live validations succeed; no elevated customer-impacting errors.
  13. Rollback Procedure (If Any Guardrail Breached)

    • Action:
      • Immediately disable new feature flags (revert behavior).
      • Reduce canary traffic to 0% or route all traffic back to previous stable version.
      • If code rollback required, scale down new version and scale up previous version deployment.
      • Database: since changes are backward-compatible, leave schema as-is; if an emergency rollback of a destructive change were required, execute pre-approved rollback script only if it is safe and tested.
    • Expected result: Service returns to stable baseline within the error budget; incident documented.
  14. Full Rollout and Post-Deployment Tasks

    • Action:
      • After 100% traffic is stable for an agreed period (e.g., 2–4 hours), finalize rollout.
      • Tune autoscaling back to normal if modified for the canary.
      • Remove temporary debug logging; keep PII redaction enforced.
      • Create deprecation notices for any endpoints scheduled for removal in later versions.
    • Expected result: New version fully operational at steady state.
  15. Post-Change Review

    • Action:
      • Review metrics for 24–48 hours: error rates, payment gateway timeouts, settlement throughput, queue backlogs.
      • Reconcile a sample set of settlements vs payment transactions to confirm no duplication or loss.
      • Update documentation and close the change ticket with evidence.
    • Expected result: Post-change validation completed; documentation updated.

Risks and Mitigations

  • API incompatibility with payment gateway v2
    • Mitigation: Sandbox integration tests; strict contract testing; timeouts and circuit breakers; staged feature enablement.
  • Breaking changes for upstream/downstream consumers
    • Mitigation: Backward-compatible API design; versioned endpoints; consumer-driven contract tests; deprecation schedule.
  • Irreversible database changes
    • Mitigation: Use additive migrations; avoid destructive changes; test migrations on a copy; prepare safe rollbacks where possible.
  • Data duplication or loss during retries
    • Mitigation: Idempotency keys for settlement and payment operations; at-least-once processing safeguards; deduplication at persistence layer where applicable.
  • Elevated error rates during canary
    • Mitigation: Strict guardrails and rapid rollback; limit ramp increments; real-time monitoring and alerting.
  • Performance regressions
    • Mitigation: Pre-production load tests; production ramp with latency/error gates; capacity headroom verification.
  • Misconfiguration of credentials/endpoints
    • Mitigation: Use secret manager and environment-specific configs; peer review and pre-flight checks; configuration validation on startup.
  • Logging of sensitive data
    • Mitigation: Enforce log redaction; disable verbose request/response logging for payment payloads; verify by sampling logs in staging and production.
  • Gateway rate limits or throttling
    • Mitigation: Backoff and retry policies aligned with provider guidance; error handling for 429/5xx; coordination with provider if traffic profile changes.

Validation Methods

  • Contract validation
    • OpenAPI diff report: No breaking changes or documented mitigations.
    • Consumer-driven contract tests: Pass for all registered consumers.
    • Payment gateway v2 sandbox tests: Pass for auth/capture/refund, timeout, and error-path scenarios.
  • Functional validation
    • Test cases: order settlement happy path, retry path, duplicate request idempotency, partial failures, refund workflows, reconciliation reports.
  • Observability checks
    • Metrics: success rate, 4xx/5xx, p95/p99 latency, JVM heap/GC, thread pools, DB connection pool usage, outbound call latency to gateway.
    • Logs: no sensitive fields, error signatures stable, no new exceptions at scale.
    • Traces: end-to-end latency within SLO; no abnormal spans for payment calls.
  • Performance validation
    • Load test in staging meets throughput/latency targets.
    • Production canary guardrails not breached at each ramp step.
  • Data integrity
    • Reconciliation: sample of orders vs payments and settlements; no duplicates or gaps.
    • Schema verification: new columns/tables populated as expected; no serialization errors.
  • Rollback drill (optional but recommended pre-prod)
    • Demonstrate canary rollback in staging with automated scripts.

Acceptance criteria:

  • All contract and functional tests pass in staging.
  • Canary rollout completes with metrics within thresholds and no abnormal log patterns.
  • No increase in payment failures attributable to the service.
  • Reconciliation checks pass; no data loss/duplication detected.
  • Runbook, diagrams, and API specs updated.
  • Architecture overview: Order Settlement microservice and dependency map.
  • OpenAPI specifications: current and target versions with change log.
  • Payment Gateway v2 integration guide and SLA/limits.
  • Database schema and migration plan (Flyway/Liquibase scripts).
  • Runbook: alerts, dashboards, SLOs, escalation procedures.
  • Deployment playbook: CI/CD pipeline, canary configuration, rollback steps.
  • Security and compliance guidelines (e.g., PCI DSS logging and data handling).
  • Post-implementation report template and reconciliation checklist.

维护目标(メンテナンス目標)

  • クエリ性能の安定化と短縮(計画の最適化、ディスクI/Oの削減)
  • テーブル・インデックスの肥大化抑制(不要タプルの回収、インデックス再構築)
  • 統計情報の鮮度維持(ANALYZE による最新化)
  • ストリーミングレプリケーションの整合性維持(遅延とロック影響の最小化)

前置条件(前提条件)

  • 対象: PostgreSQL プライマリ/スタンバイ構成。作業はプライマリで実施し、スタンバイへのWAL適用で反映される。
  • バージョン:
    • 推奨: PostgreSQL 12 以上(REINDEX CONCURRENTLY が利用可能)
    • 12 未満の場合: 非同期再作成(CREATE INDEX CONCURRENTLY → DROP INDEX CONCURRENTLY)で代替。制約(PRIMARY/UNIQUE)に紐づくインデックスはオンラインで安全に代替しにくいため計画停止が必要。
  • 権限: 対象DBの所有者またはスーパーユーザ相当の権限
  • 監視・安全:
    • 直近のフルバックアップまたはPITR復旧点の有効性を確認済み
    • 空きディスク容量: 再索引する最大インデックスサイズの約1.2〜2倍
    • 監視: レプリケーション遅延、ロック待ち、ディスクI/O、CPU使用率の可視化
  • メンテナンス時間帯: 低負荷帯を確保(長時間ロックが発生する可能性のある操作は停止時間を考慮)
  • 影響範囲: VACUUM/ANALYZE/REINDEXはWAL出力量を増加させるため、スタンバイ遅延しやすい

操作步骤(操作手順)

  1. 準備・通知
  • 操作説明:
    • 作業ウィンドウと対象スキーマ/テーブル/インデックスを確定し、関係者へ通知
    • ベースライン取得のための計測条件を定義(対象クエリ、指標、期間)
    • 一時設定(推奨):セッション単位で lock_timeout/statement_timeout を短めに設定
  • 予期結果:
    • 作業スコープとリスク共有が完了し、タイムアウトが適用される

例:

SET lock_timeout = '5s';
SET statement_timeout = '15min';
SET application_name = 'maint_reindex_vacuum';
  1. ベースライン採取
  • 操作説明:
    • バージョンとレプリケーション遅延確認(プライマリで実行)
    • 大きい/スキャン頻度の低いインデックス、不要タプルが多いテーブルを抽出
    • ディスク空き容量確認(OS側コマンドで実施)
  • 予期結果:
    • メンテ対象の候補リストが作成され、リソース状況が把握できる

例:

-- レプリケーション遅延概要
SELECT application_name, state, sync_state, replay_lag
FROM pg_stat_replication;

-- 大きいインデックスの上位
SELECT schemaname, relname AS table_name, indexrelname AS index_name,
       pg_size_pretty(pg_relation_size(indexrelid)) AS index_size, idx_scan
FROM pg_stat_user_indexes
ORDER BY pg_relation_size(indexrelid) DESC
LIMIT 20;

-- デッドタプルが多いテーブル
SELECT schemaname, relname, n_live_tup, n_dead_tup
FROM pg_stat_all_tables
ORDER BY n_dead_tup DESC
LIMIT 20;
  1. 手動VACUUM(ANALYZEを含めて実施)
  • 操作説明:
    • オンライン維持を優先し、VACUUM (ANALYZE) を対象テーブルへ実施
    • 複数テーブルは vacuumdb で並列化(-j)可能
    • 進捗は pg_stat_progress_vacuum で確認
  • 予期結果:
    • 不要タプルが回収され、テーブル統計情報が更新される

例:

-- 個別実行
VACUUM (VERBOSE, ANALYZE) schema.table1;
VACUUM (VERBOSE, ANALYZE) schema.table2;

-- 複数テーブルを並列で(シェルから)
vacuumdb -d <DB名> -j 4 -z -t schema.table1 -t schema.table2

-- 進捗確認
SELECT relid::regclass AS table_name, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed
FROM pg_stat_progress_vacuum;

注意: オンライン運用中は VACUUM FULL は使用しない(全表再書き込みと長時間ロックが発生)。

  1. 統計情報の更新(必要に応じて追加ANALYZE)
  • 操作説明:
    • 列の分布が偏っているテーブルで計画が安定しない場合、ANALYZE を追加実行
  • 予期結果:
    • 最新の統計がプランナに反映

例:

ANALYZE (VERBOSE) schema.table1;
  1. インデックス再構築(REINDEX)
  • 操作説明:
    • 候補インデックスへ REINDEX CONCURRENTLY を実施(PostgreSQL 12+)
    • 1回に実施する本数を制限し、負荷とレプリケーション遅延を監視
    • 失敗時に無効インデックスが残らないか確認(pg_index.indisvalid)
  • 予期結果:
    • ロック時間を最小化してインデックス肥大を解消

例(12+):

-- 単一インデックス
REINDEX INDEX CONCURRENTLY schema.idx_target;

-- テーブル配下の全インデックス(必要に応じて)
REINDEX TABLE CONCURRENTLY schema.table1;

-- 実行後、無効インデックスの有無を確認
SELECT i.relname AS index_name, ix.indisvalid
FROM pg_index ix
JOIN pg_class i ON i.oid = ix.indexrelid
WHERE i.relname = 'idx_target';

代替(12未満、非制約インデックスのみ):

-- 定義確認
SELECT pg_get_indexdef(indexrelid)
FROM pg_stat_user_indexes
WHERE indexrelname = 'idx_target';

-- 新規作成(新しい名前で)
CREATE INDEX CONCURRENTLY idx_target_new ON schema.table1 (col1, col2);

-- 旧インデックスを削除
DROP INDEX CONCURRENTLY schema.idx_target;

-- 新インデックス名をリネーム
ALTER INDEX schema.idx_target_new RENAME TO idx_target;

注意:

  • 制約に紐づくインデックス(PRIMARY/UNIQUE)はオンライン手順が複雑なため、停止時間を確保するか、PostgreSQL のメジャーバージョン更新後に REINDEX CONCURRENTLY を使用
  • REINDEX/CREATE INDEX はトランザクションブロック内で実行しない(BEGIN/COMMITで囲まない)
  • スタンバイでは実行不可(読み取り専用)
  1. 再度のANALYZE(任意)
  • 操作説明:
    • 大規模な再索引後、対象テーブルに ANALYZE を再実施
  • 予期結果:
    • プランナが新しいインデックス状態を踏まえた最適計画を選択

例:

ANALYZE schema.table1;
  1. 終了処理・記録
  • 操作説明:
    • 一時的に変更したセッション設定を元に戻す
    • 実施内容(対象、時刻、実行時間、サイズ変化、エラー)を記録
  • 予期結果:
    • 追跡可能な作業ログが残る

风险与应对(リスクと対応)

  • 長時間ロック
    • 対応: CONCURRENTLY を使用、lock_timeout 設定、対象を小分けに実行、低負荷時間に実施
  • ディスク不足
    • 対応: 事前に対象インデックスサイズを把握し、空き容量を確保(最大インデックスの1.2〜2倍)。不足時は対象を分割または順延
  • レプリケーション遅延の増大
    • 対応: 作業中に pg_stat_replication の遅延を監視、閾値超過で一時停止。必要に応じ vacuum_cost_limit を控えめに
  • 自動VACUUM/他バッチとの競合
    • 対応: スケジュール調整、対象テーブルの同時VACUUM回避。メンテ窓での大量更新を抑制
  • REINDEX失敗・中断
    • 対応: 実行後に pg_index.indisvalid を確認。無効インデックスが残存する場合は DROP INDEX を実施。再試行は負荷が落ち着いてから
  • 誤対象の操作
    • 対応: 実行前に対象一覧をレビュー、テスト環境で手順検証、ロールベースの最小権限で実施

验证方法(検証方法)

  • 機能・整合性
    • レプリケーション: pg_stat_replication の state/sync_state と遅延(replay_lag)が平常範囲
    • インデックス有効性: indisvalid = true、重複/無効インデックスがない
  • 効果(サイズ・統計)
    • デッドタプル減少:
      SELECT schemaname, relname, n_dead_tup
      FROM pg_stat_all_tables
      WHERE relname IN ('table1','table2')
      ORDER BY n_dead_tup DESC;
      
    • インデックスサイズ変化:
      SELECT relname AS index_name, pg_size_pretty(pg_relation_size(oid)) AS size
      FROM pg_class
      WHERE relkind = 'i' AND relname IN ('idx_target')
      ORDER BY pg_relation_size(oid) DESC;
      
  • 性能(クエリ)
    • 代表クエリの実行計画確認(インデックス利用を確認)
      EXPLAIN (ANALYZE, BUFFERS)
      SELECT ... WHERE 条件;
      
    • 主要クエリの実行時間・I/O・バッファヒット率の比較(作業前後で同条件)
  • 進捗・副作用
    • VACUUM進捗/残タスク: pg_stat_progress_vacuum と autovacuum のログを確認
    • エラーログ: REINDEX/ANALYZE のエラー・警告の有無

合否基準(例):

  • 対象クエリの中央値レイテンシが目標比で改善または維持
  • 対象テーブルの n_dead_tup が大幅に減少
  • 対象インデックスのサイズ縮小または idx_scan の増加傾向
  • レプリケーション遅延が許容範囲内で収束

相关文档(関連ドキュメント)

注意:

  • 本手順はオンライン維持を優先した基本手順。VACUUM FULL や制約付きインデックスの置換など、長時間ロックを伴う操作は停止時間を前提に個別計画を作成すること。

示例详情

解决的问题

用一次输入,快速产出可直接落地的系统维护流程方案,让复杂维护变简单、可控、可复用。

  • 将零散经验固化为标准流程,显著降低人为失误与停机风险
  • 一键生成包含目标、前置条件、操作步骤、风险预控与验收标准的完整方案
  • 覆盖硬件检修、功能更新、数据库优化、网络配置等常见场景
  • 支持按技术深度与语言输出,满足跨团队协作与评审要求
  • 缩短变更准备时间,提升运维效率与合规性,促进知识沉淀与新人上手

适用用户

系统分析师

快速搭建各类组件维护流程框架,统一文档结构与术语,输出覆盖步骤、风险与验证的完整方案,减少跨团队反复修改。

运维工程师

一键生成变更计划、详细步骤与回滚路径,提前锁定风险点和注意事项,在维护窗口内高效执行并降低故障率。

数据库管理员

快速产出索引优化、备份恢复与参数调整的可操作流程,附带效果验证与回退标准,稳定性能并缩短停机时间。

特征总结

输入组件与维护类型,即刻生成标准化流程,覆盖目标、前置、步骤、验证与文档归档
自动拆解复杂维护为可执行清单,每步含期望结果,降低沟通成本与误操作风险
内置风险识别与预防提示,自动补充安全注意事项,帮助通过审计与合规检查
一键生成维护前后验证方案,支持回滚判定与效果评估,让上线与恢复更可控
适配硬件、软件、数据库与网络等场景,按需选择技术深度与语言,轻松跨团队协作
提供模板化章节结构与示例表格,快速统一文档格式,减少评审与交接所耗时间
支持维护资源与人员分工规划,自动列出工具清单和窗口安排,避免遗漏与冲突
将历史经验沉淀为可复用模板,复用成功案例,缩短新项目准备时间并提升稳定性
实时提示关键禁行操作与审批点,防止未验证方法流入生产,保障业务连续性

如何使用购买的提示词模板

1. 直接在外部 Chat 应用中使用

将模板生成的提示词复制粘贴到您常用的 Chat 应用(如 ChatGPT、Claude 等),即可直接对话使用,无需额外开发。适合个人快速体验和轻量使用场景。

2. 发布为 API 接口调用

把提示词模板转化为 API,您的程序可任意修改模板参数,通过接口直接调用,轻松实现自动化与批量处理。适合开发者集成与业务系统嵌入。

3. 在 MCP Client 中配置使用

在 MCP client 中配置对应的 server 地址,让您的 AI 应用自动调用提示词模板。适合高级用户和团队协作,让提示词在不同 AI 工具间无缝衔接。

AI 提示词价格
¥20.00元
先用后买,用好了再付款,超安全!

您购买后可以获得什么

获得完整提示词模板
- 共 449 tokens
- 4 个可调节参数
{ 系统组件 } { 维护类型 } { 输出语言 } { 技术深度 }
获得社区贡献内容的使用权
- 精选社区优质案例,助您快速上手提示词
使用提示词兑换券,低至 ¥ 9.9
了解兑换券 →
限时半价

不要错过!

半价获取高级提示词-优惠即将到期

17
:
23
小时
:
59
分钟
:
59