# Online Scaling Out `TiDB/TiKV/PD` Nodes (On-premises)

__*TiDB online scale out*__
__*TiDB Server online scale out*__
__*TiKV online scale out*__
__*PD online scale out*__
__*zz-Issue-Diagram-Needed*__

+ **Step 1:** Place the scale-out topology to a `yaml` file
+ **Step 2:** Run scale out command
+ **Step 3:** Verify that the new node has joined the cluster
+ For example, `TiKV` node scaling out:

```
~!@// Step 1@!~
$ vi scale-out.yaml

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

~!@// Step 2@!~
$ tiup cluster ~!@scale-out@!~ {cluster-name} scale-out.yaml

~!@// Step 3@!~
$ tiup cluster display {cluster-name}
```

![`smart`](./student-guide/diagram/OnlineScalingOutTiKVNodes_aa_001_20220923.png)
-------------------------------------------------------------
`TiDB` clusters can be scaled horizontally online. You can scale `TiDB`, `TiKV`, `PD`, or `TiFlash` nodes in a cluster by using `TiUP`.

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:

```
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 {cluster-name}` to view the configuration information of the current cluster.

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:

- Check the potential risks:
```
tiup cluster check {cluster-name} scale-out.yaml --cluster --user root [-p] [-i /home/root/.ssh/rsa_key]
```

- Automatically fix the cluster:
```
tiup cluster check {cluster-name} scale-out.yaml --cluster --apply --user root [-p] [-i /home/root/.ssh/rsa_key]
```

- Run `scale out` command:
```
tiup cluster scale-out {cluster-name} scale-out.yaml
```

Step 3: Verify that the scaling operation has been successful:
```
tiup cluster display {cluster-name}
```

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













