# Labels Configuration

+ A special label key, **`region`**, is employed to facilitate the data geo-location placement feature

```7
tikv_servers:
  - host: 10.63.10.30
    config:
      server.labels: { dc: "1", ~!@zone: "1"@!~, rack: "1", host: "1" }
  - host: 10.64.10.31
    config:
      server.labels: { dc: "2", zone: "2", rack: "3", host: "6" }
  - host: 10.65.10.32
    config:
      server.labels: { dc: "3", zone: "3", rack: "5", host: "9" }
```

![`smart`](LabelConfiguration_aa_003_20220509.png)

------------------------------------------------------------
Above, everyone has understood the concept and feature of labels, next let's look at how to set labels.
First, in the PD node, the format information of the label, i.e. the source information, should be identified, as follows:

```
[replication]                     
location-labels = ["dc", "zone", "rack", "host"] 
```

`dc`, `rack` and `host` respectively represent data center, rack and host, which are physical locations or devices, very easy to understand.

However, the concept of "zone" is actually a logical concept used to represent the smallest location where replicas can be isolated. Its quantity is always consistent with the replicas. For example, if we have the default 3 replicas, and if there are 3 data centers (DCs), then we set 3 zones, each zone corresponding to a data center (DC), and the replicas are also placed in different zones. If there is only 1 data center, but there are 3 racks, then we also set 3 zones, each zone corresponding to a rack, and the replicas are also placed in different zones.

Secondly, let's take a look at the configuration of TiKV. In the configuration of TiKV,

```
tikv_servers:
  - host: 10.63.10.30
    config:
      server.labels: { dc: "1", zone: "1", rack: "1", host: "1" }
  - host: 10.64.10.31
    config:
      server.labels: { dc: "2", zone: "2", rack: "3", host: "6" }
  - host: 10.65.10.32
    config:
      server.labels: { dc: "3", zone: "3", rack: "5", host: "9" }
```

Host: 10.63.10.30 located in dc1 Data Center's rack1, host number is 1, zone number is 1.
Host: 10.64.10.31 located in dc2 Data Center's rack3, host number is 6, zone number is 2.
Host: 10.65.10.32 located in dc3 Data Center's rack5, host number is 9, zone number is 3.

When PD perceives the locations of 3 hosts, the three replicas of the Region can be placed on the 3 hosts, so that the highest availability can be achieved.

A special label key, `region`, is employed to facilitate the data geo-location placement feature. It will be discussed in unit 8 - New Features of TiDB v6.0.

