# 升级 TiDB 集群

### 概览
+ In these exercises, you perform an in-place upgrade of the existing TiDB v6.5.0 cluster to TiDB v6.5.1.
+ The following shows the deployment topology diagram of TiDB cluster.

   ![60](https://pingcap-edu.s3.us-west-2.amazonaws.com/quick-demo/TiDBClusterDeploymentTopologyExercise_aa_007_20220914.png)

+ Here are the steps of upgrade a TiDB cluster in production environment. Some of the steps are omitted in our lab. For example, we do not check the DDL and backup status, as there are no backup or DDL jobs in our previous labs.

   ![60](https://pingcap-edu.s3.us-west-2.amazonaws.com/quick-demo/VersionUpgradeProcess_aa_003_20230912.png)

### 注意事项
+ Click the private key file [pe-class-key-oregon.pem](lab-controller/class_303_get_ec2_key_for_lab.php?region=oregon) to download it. It is required to log into the Control Machine for this demo.
+ Commands and SQL statements presented on this page are clickable for easy copy and paste.
+ The required IP addresses for specific commands will be substituted with the actual ones automatically once you have set up the lab environment after Step 1.
+ Your environment may be different with these exercises, including but not limited to IP, port, username, password and directory. Example output is displayed in a gray background in this guide.
+ The `$` in your terminal window is an OS prompt. The `tidb>` or `mysql>` in your terminal window is SQL command prompt.

### 前提条件
+ You have downloaded and secured the TiUP Control Machine private key: `chmod 400 [pe-class-key-oregon.pem](lab-controller/class_303_get_ec2_key_for_lab.php?region=oregon)`
+ The `ssh-agent` is running on your laptop. Windows users please refer to this [guide](https://github.com/pingcap/tidb-course-201-lab/blob/master/README_303_v65_en_class_setup_guide_for_student.md).
+ You have added identity to authentication agent: `ssh-add [pe-class-key-oregon.pem](lab-controller/class_303_get_ec2_key_for_lab.php?region=oregon)`

### 时长
+ This exercise should take you approximately 20 minutes to complete.

## 练习 1
### Upgrade the existing TiDB from v6.5.0 to v6.5.1.

### 步骤
1. Login as user ec2-user on monitor1_address. Enter the following command at the terminal prompt and receive the results shown. The returned message may be slightly different from what is displayed here:
   ```command
   $ ssh -A ec2-user@monitor1_address
   ```
   ```output
      ,     #_
      ~\_  ####_        Amazon Linux 2
     ~~  \_#####\
     ~~     \###|       
     ~~       \#/ ___
      ~~       V~' '->
       ~~~         /    A newer version of Amazon Linux is available!
         ~~._.   _/
            _/ _/       Amazon Linux 2023, GA and supported until 2028-03-15.
          _/m/'           https://aws.amazon.com/linux/amazon-linux-2023/
   ```

2. Check the version of the deployed TiDB cluster. Enter the following command at the terminal prompt and receive the results shown:
   ```command
   $ tiup cluster display tidb-test
   ```
   ```output
   ...
   Cluster version:    v6.5.0
   ...
   ```

3. Upgrade of the existing TiDB v6.5.0 cluster to TiDB v6.5.1. Enter the following command at the terminal prompt and receive the results shown:
   ```command
   $ tiup cluster upgrade tidb-test v6.5.1
   ```
   ```output
   Starting component `cluster`: /home/ec2-user/.tiup/components/cluster/v1.10.1/tiup-cluster upgrade tidb-test v6.5.0
   This operation will upgrade tidb v6.5.0 cluster tidb-test to v6.5.1. 
   Do you want to continue? [y/N]:(default=N) y
   ...
   Upgraded cluster `tidb-test` successfully
   ```

4. Check the version of the deployed TiDB cluster. Enter the following command at the terminal prompt and receive the results shown:
   ```command
   $ tiup cluster display tidb-test
   ```
   ```output
   tiup is checking updates for component cluster ...
   Starting component `cluster`: /home/ec2-user/.tiup/components/cluster/v1.10.1/tiup-cluster display tidb-test
   Cluster type:       tidb
   Cluster name:       tidb-test
   Cluster version:    v6.5.1
   ...
   ```

5. Close all open terminal windows.

## 实验结束