# 使用 TiUP 进行补丁升级（HotFix）

__*TiDB 补丁升级*__
__*TiUP HotFix*__
__*tiup cluster patch*__

+ 升级集群上的所有 TiDB 实例
  + `tiup cluster patch ${cluster-name} /tmp/tidb-hotfix.tar.gz -R tidb`

+ 替换其中一个 TiDB 实例
  + `tiup cluster patch ${cluster-name} /tmp/tidb-hotfix.tar.gz -N ${Node_IP}:${Node_Port}`

-------------------------------------------------------------
在某些场景下（例如 Debug）,可能需要用一个支持团队提供的临时的包替换正在运行的组件,此时可以用 TiUP 的 patch 命令:

tiup cluster patch --help
Replace the remote package with a specified package and restart the service

Usage:
  tiup cluster patch <cluster-name> <package-path> [flags]

Flags:
  -h, --help                   帮助信息
  -N, --node strings           指定被替换的节点
      --overwrite              在未来的 scale-out 操作中使用当前指定的临时包
  -R, --role strings           指定被替换的服务类型
      --transfer-timeout int   transfer leader 的超时时间

Global Flags:
      --native-ssh        使用系统默认的 SSH 客户端
      --wait-timeout int  等待操作超时的时间
      --ssh-timeout int   SSH 连接的超时时间
  -y, --yes               跳过所有的确认步骤

例如,有一个 TiDB 实例的 hotfix 包放在 /tmp/tidb-hotfix.tar.gz目录下。如果此时想要替换集群上的所有 TiDB 实例,则可以执行以下命令:
tiup cluster patch ${cluster-name} /tmp/tidb-hotfix.tar.gz -R tidb

或者只替换其中一个 TiDB 实例:
tiup cluster patch ${cluster-name} /tmp/tidb-hotfix.tar.gz -N ${Node_IP}:${Node_Port}