# Online Scale Out (TiDB/TikV/PD)

__*TiDB online scale out*__
__*TiDB Server online scale out*__
__*TiKV online scale out*__
__*PD online scale out*__

+ Step 1: Edit the scale-out topology (scale-out topology)
```
vi scale-out.yaml

 - host: 10.0.1.5
    ssh_port: 22
    port: 4000
    status_port: 10080
    deploy_dir: /data/deploy/install/deploy/tidb-4000
    log_dir: /data/deploy/install/log/tidb-4000
```
+ Step 2: Run scale out command
  + `tiup cluster scale-out <cluster-name> scale-out.yaml`

+ Step 3: Confirm whether the new node has joined
  + `tiup cluster display <cluster-name>`

-------------------------------------------------------------
TiDB clusters can be scaled without interrupting scale out. Scale TiDB, TiKV, PD, or TiFlash nodes in a cluster by using TiUP. If you do not have TiUP installed, please refer to the TiDB Cluster Deployment course.

Since the scaling method of TiDB/PD/TiKV is similar, here, we will scale out a node with an IP address of 10.0.1.5 in the cluster as an example.

Step 1: Edit the scale-out topology (scale-out topology)

vi scale-out.yaml

The scale out configuration file for tidb_servers is:
tidb_servers:
  - host: 10.0.1.5
    ssh_port:22
    port: 4000
    status_port:10080
    deploy_dir: /data/deploy/install/deploy/tidb-4000
    log_dir: /data/deploy/install/log/tidb-4000

The scale out profile for tikv_servers is:
tikv_servers:
  - host: 10.0.1.5
    ssh_port:22
    port:20160
    status_port:20180
    deploy_dir: /data/deploy/install/deploy/tikv-20160
    data_dir: /data/deploy/install/data/tikv-20160
    log_dir: /data/deploy/install/log/tikv-20160

The scale out configuration file for pd_servers is:
pd_servers:
  - host: 10.0.1.5
    ssh_port:22
    name: pd-1
    client_port:2379
    peer_port:2380
    deploy_dir: /data/deploy/install/deploy/pd-2379
    data_dir: /data/deploy/install/data/pd-2379
    log_dir: /data/deploy/install/log/pd-2379

You can use tiup cluster edit-config to <cluster-name>view the configuration information of the current cluster, because the global and server_configs parameter configurations are inherited by scale-out.yaml by default, so it will also be displayed in scale- It takes effect in out.yaml.

Step 2: Run scale out command

Before executing the scale-out command, use the check and check —apply commands to check and automatically fix the potential risks of the cluster:
(1) Check the potential risks of the cluster:
tiup cluster check <cluster-name>scale-out.yaml —cluster —user root [-p] [-i /home/root/.ssh/gcp_rsa]

(2) Potential risks of automatically repairing clusters:
tiup cluster check <cluster-name>scale-out.yaml —cluster —apply —user root [-p] [-i /home/root/.ssh/gcp_rsa]

Run scale out command:
tiup cluster scale-out <cluster-name>scale-out.yaml

Appears after successful execution: "scaled cluster <cluster-name>out of expansion" indicates successful scale out. As for TiKV clusters, data is automatically rebalanced (rebalanced).

Step 3: Confirm whether the new node has joined

Check the cluster status to confirm that the new nodes have joined, as follows:
tiup cluster display <cluster-name>

Please refer to the documentation: https://docs.pingcap.com/zh/tidb/stable/scale-tidb-using-tiup