How to Modify the Default Ports of Each Component in TiDB

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TIDB如何修改各组件的默认端口

| username: TiDBer_HXL

How to modify the default ports of each component in TiDB?

| username: ddhe9527 | Original post link

Use the following command to edit the cluster configuration file, the port configurations are all inside:
tiup cluster edit-config
After editing, save and then reload.

| username: TiDBer_HXL | Original post link

So simple? What about the directories named after ports, do they need to be modified?

[root@localhost tidb-data]# ls -al
total 8
drwxr-xr-x 12 tidb tidb 208 Jun 14 14:46 .
dr-xr-xr-x. 35 root root 4096 May 18 13:56 …
drwxr-xr-x 2 tidb tidb 35 Jul 4 16:30 alertmanager-9093
drwxr-xr-x 3 tidb tidb 20 Jun 14 10:48 dm-master-8261
drwxr-xr-x 2 tidb tidb 6 Jun 14 10:43 dm-worker-8262
drwxr-xr-x 2 tidb tidb 6 May 25 16:46 drainer-8249
drwxr-xr-x 2 tidb tidb 6 May 18 13:57 monitor-9100
drwxr-xr-x 5 tidb tidb 84 Jul 4 16:34 pd-2379
drwxr-xr-x 24 tidb tidb 4096 Jul 4 15:00 prometheus-9090
drwxr-xr-x 4 tidb tidb 42 May 25 15:11 pump-8250
drwxr-xr-x 10 tidb tidb 140 Jun 2 08:43 tiflash-9000
drwxr-xr-x 6 tidb tidb 201 Jul 4 03:44 tikv-20160
[root@localhost tidb-data]# pwd

| username: ddhe9527 | Original post link

Oh, I made a mistake. The port number cannot be changed directly; it needs to be replaced using scaling in and out. For example, if you want to change the TiDB port from 4000 to 4001, you can first scale out to add a 4001 port, and then scale in to remove the 4000 port.

| username: TiDBer_HXL | Original post link

How can we scale out without extra machines?

| username: ddhe9527 | Original post link

Rebuilding PD is also an option, but it’s best to perform tests and backups first.

| username: TiDBer_HXL | Original post link

I found that changing a port or IP is a big project.

| username: caiyfc | Original post link

Because the instance is determined based on the port, directly modifying it would make it indistinguishable.

| username: TiDBer_HXL | Original post link

I feel that this increases the maintenance cost for operations.

| username: ddhe9527 | Original post link

Yes, so it’s best to plan ahead.

| username: TiDBer_HXL | Original post link

In fact, adjusting IP and port is a very common requirement, especially when network adjustments are made.

| username: caiyfc | Original post link

Actually, I feel it’s okay because, except for TiKV, scaling other components is very convenient. Moreover, under one IP, it’s fine to scale up first and then scale down.

| username: CuteRay | Original post link

How should I put it, you are still using the mindset of a traditional single-node database to evaluate a distributed database structure. You can compare it with other distributed systems, not just databases. As long as it is distributed, the IP and port need to be planned at the initial deployment stage. Changing them after deployment is very troublesome. Changing the port on a single-node system is very simple, but implementing it in a distributed system is not necessarily easy. Distributed systems have their advantages, but they also come with such minor drawbacks. Since you have chosen it, don’t bring the single-node mindset into it.

| username: system | Original post link

This topic was automatically closed 1 minute after the last reply. No new replies are allowed.