Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: ansible 如何修改tidb server端口4000为4001
【TiDB Usage Environment】Production Environment
【TiDB Version】4.0
【Reproduction Path】What operations were performed when the issue occurred
【Encountered Issue: Issue Phenomenon and Impact】
【Resource Configuration】Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
【Attachments: Screenshots/Logs/Monitoring】
Just modify the configuration file directly, and reload it after the modification.
I can’t find which configuration file it is in.
To be safe, you can scale out a TiDB node with port 4001 on the same machine, and then scale in the TiDB node with port 4000.
How to use ansible-playbook?
You can directly modify it using tiup cluster edit-config ${cluster-name}
.
You can change the TiDB port by modifying the TiDB configuration file. On the machine where TiDB is deployed, locate the TiDB configuration file conf/tidb.toml
and modify the port
configuration item. For example, to change the TiDB port to 4000:
[server]
port = 4000
After making the changes, you need to restart the TiDB service for the configuration to take effect. You can use the following command to restart TiDB:
ansible-playbook start.yml --tags=tidb
For more information about the TiDB configuration file, you can refer to the official documentation: https://docs.pingcap.com/zh/tidb/stable/config-file-description#tidb-configuration-file
tidb.toml did not find port
tidb.toml (1.4 KB)
If the port is not specified in the configuration file, the default port 4000 will be used. If not configured, you can explicitly specify the port, and it will use the specified port.
You can use the tidb_server_config
module provided by Ansible. Here are the steps to use this module:
-
Open the Ansible playbook file and add the following task in the tasks
section:
- name: Modify TiDB server port
tidb_server_config:
state: present
tidb_server_port: new_port_number
This will use the tidb_server_config
module to update the port number in the tidb-server.toml
configuration file to the new port number you specify.
-
Include the tidb_topology
execution in the deployment process.
- name: Deploy TiDB cluster
hosts: tidb_servers
become: true
roles:
- tidb-deploy
-
Specify vars
in the playbook file to pass the port number you want to change to tidb_server_port
.
- name: Deploy TiDB cluster
hosts: tidb_servers
become: true
vars:
tidb_server_port: 4001
roles:
- tidb-deploy
In this example, the new port number is set to 4001.
-
Run the Ansible playbook file to deploy the TiDB cluster and change the port number.
ansible-playbook deploy.yml
This way, you can use Ansible to change the TiDB server port number to the new port number you specify.
Solved, directly modified the port in scripts/run_tidb.sh.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.