Usage
Add labels on BEs
Suppose that one cluster includes six BEs which are distributed evenly across three racks. You can add labels on BEs based on the racks where the BEs are located.SHOW BACKENDS; and view the labels of BEs in the Location field of the returned result.
If you need to modify the labels of BEs, you can execute ALTER SYSTEM MODIFY BACKEND "172.xx.xx.48:9050" SET ("labels.location" = "rack:xxx");.
Use labels to specify table data distribution on BE nodes
If you need to specify the locations to which a table’s data is distributed, for example, distributing a table’s data across two racks, rack1 and rack2, you can add labels to the table. After labels are added, all the replicas of the same tablet in the table are distributed across labels in a Round-Robin approach. Moreover, if multiple replicas of the same tablet exist within the same label, these replicas will be distributed as evenly as possible across different BEs in that label. Note- If the total number of BE nodes associated with the labels is fewer than the number of replicas, the system will preferentially ensure there are enough replicas. In this case, replicas may not be distributed as the label specified.
- The label to be associated with a table must already exist. Otherwise, an error
Getting analyzing error. Detail message: Cannot find any backend with location: rack:xxxwill occur.
At table creation
You can use the property"labels.location" to distribute the table’s data across rack 1 and rack 2 at table creation:
labels.location is *, indicating that replicas are evenly distributed across all labels. If the data distribution of a newly created table does not need to be aware of the geographical locations of servers in the cluster, you can manually set the table property "labels.location" = "".
After table creation
If you need to modify the data distribution location of the table after table creation, for example, modify the location to rack 1, rack 2, and rack 3, you can execute the following statement:Use labels to specify materialized view data distribution on BE nodes
If you need to specify the locations to which an asynchronous materialized view’s data is distributed, for example, distributing data across two racks, rack1 and rack2, you can add labels to the materialized view. After labels are added, all the replicas of the same tablet in the materialized view are distributed across labels in a Round-Robin approach. Moreover, if multiple replicas of the same tablet exist within the same label, these replicas will be distributed as evenly as possible across different BEs in that label. Note- If the total number of BE nodes associated with the labels is fewer than the number of replicas, the system will preferentially ensure there are enough replicas. In this case, replicas may not be distributed as the label specified.
- The labels to be associated with the materialized view must already exist. Otherwise, an error
Getting analyzing error. Detail message: Cannot find any backend with location: rack:xxxwill occur.
At materialized view creation
If you want to distribute the materialized view’s data across rack 1 and rack 2 while creating it, you can execute the following statement:labels.location is *, indicating that replicas are evenly distributed across all labels. If the data distribution of a newly created materialized view does not need to be aware of the geographical locations of servers in the cluster, you can manually set the property "labels.location" = "".