From 68fb8f774f472d898a8bf1fe43c81e169a9688f9 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Tue, 7 Jan 2025 09:44:04 +0800 Subject: [PATCH] tiproxy: improve deployment instructions for deploying TiProxy (#19904) (#19910) --- config-templates/simple-tiproxy.yaml | 15 +++++++++++++++ tiproxy/tiproxy-configuration.md | 17 ++++++++++++++--- tiproxy/tiproxy-deployment-topology.md | 6 ++++++ tiproxy/tiproxy-overview.md | 15 +++++++-------- tiup/tiup-cluster-topology-reference.md | 12 ++++++++++++ 5 files changed, 54 insertions(+), 11 deletions(-) diff --git a/config-templates/simple-tiproxy.yaml b/config-templates/simple-tiproxy.yaml index 5e5bb5b28f0ea..e05afa98762a1 100644 --- a/config-templates/simple-tiproxy.yaml +++ b/config-templates/simple-tiproxy.yaml @@ -8,9 +8,12 @@ global: component_versions: tiproxy: "v1.2.0" server_configs: + tidb: + graceful-wait-before-shutdown: 15 tiproxy: ha.virtual-ip: "10.0.1.10/24" ha.interface: "eth0" + graceful-wait-before-shutdown: 15 pd_servers: - host: 10.0.1.1 @@ -29,7 +32,19 @@ tikv_servers: tiproxy_servers: - host: 10.0.1.11 + deploy_dir: "/tiproxy-deploy" + data_dir: "/tiproxy-data" + port: 6000 + status_port: 3080 + config: + labels: { zone: "east" } - host: 10.0.1.12 + deploy_dir: "/tiproxy-deploy" + data_dir: "/tiproxy-data" + port: 6000 + status_port: 3080 + config: + labels: { zone: "west" } monitoring_servers: - host: 10.0.1.13 diff --git a/tiproxy/tiproxy-configuration.md b/tiproxy/tiproxy-configuration.md index 87242e84a17f5..28bbdcabd4cc7 100644 --- a/tiproxy/tiproxy-configuration.md +++ b/tiproxy/tiproxy-configuration.md @@ -5,7 +5,9 @@ summary: Learn how to configure TiProxy. # TiProxy Configuration File -This document introduces the configuration parameters related to the deployment and use of TiProxy. The following is an example configuration: +This document introduces the configuration parameters related to the deployment and use of TiProxy. For the configurations of TiUP deployment topology, see [tiproxy-servers configurations](/tiup/tiup-cluster-topology-reference.md#tiproxy_servers). + +The following is an example configuration: ```toml [proxy] @@ -43,13 +45,13 @@ Configuration for SQL port. + Default value: `0.0.0.0:6000` + Support hot-reload: no -+ SQL gateway address. The format is `:`. ++ The listening address of the SQL service. The format is `:`. This configuration item is automatically set when you deploy TiProxy using TiUP or TiDB Operator. #### `advertise-addr` + Default value: `""` + Support hot-reload: no -+ Specifies the address that clients use to connect to this TiProxy instance. This configuration item is automatically set when you deploy TiProxy using TiUP or TiDB Operator. If not set, the external IP address of the TiProxy instance is used. ++ Specifies the address that other components use to connect to this TiProxy instance. This address only contains the host name, not the port. This address might be different from the host name in [`addr`](#addr). For example, if the `Subject Alternative Name` in TiProxy's TLS certificate contains only the domain name, other components will fail to connect to TiProxy via IP. This configuration item is automatically set when you deploy TiProxy using TiUP or TiDB Operator. If not set, the external IP address of the TiProxy instance is used. #### `graceful-wait-before-shutdown` @@ -136,6 +138,15 @@ High availability configurations for TiProxy. + Support hot-reload: no + Specifies the virtual IP address in the CIDR format, such as `"10.0.1.10/24"`. In a cluster with multiple TiProxy instances, only one instance binds to the virtual IP. If this instance goes offline, another TiProxy instance will automatically bind to the IP, ensuring clients can always connect to an available TiProxy through the virtual IP. +The following is an example configuration: + +```yaml +server_configs: + tiproxy: + ha.virtual-ip: "10.0.1.10/24" + ha.interface: "eth0" +``` + > **Note:** > > - Virtual IP is only supported on Linux operating systems. diff --git a/tiproxy/tiproxy-deployment-topology.md b/tiproxy/tiproxy-deployment-topology.md index ccee9f4f5d7f6..c8781945a94b2 100644 --- a/tiproxy/tiproxy-deployment-topology.md +++ b/tiproxy/tiproxy-deployment-topology.md @@ -7,6 +7,12 @@ summary: Learn the deployment topology of TiProxy based on the minimal TiDB topo This document describes the deployment topology of [TiProxy](/tiproxy/tiproxy-overview.md) based on the minimal TiDB topology. +For other deployment methods, refer to the following documents: + +- To deploy TiProxy using TiDB Operator, see the [TiDB Operator](https://docs.pingcap.com/zh/tidb-in-kubernetes/stable/deploy-tiproxy) documentation. +- To quickly deploy TiProxy locally using TiUP, see [Deploy TiProxy](/tiup/tiup-playground.md#deploy-tiproxy). +- To deploy TiProxy using TiUP, see [Installation and usage](/tiproxy/tiproxy-overview.md#installation-and-usage). + TiProxy is a L7 proxy server for TiDB, which can balance connections and migrate sessions when possible. ## Topology information diff --git a/tiproxy/tiproxy-overview.md b/tiproxy/tiproxy-overview.md index 5ae207e7b77d4..a35a83608e27e 100644 --- a/tiproxy/tiproxy-overview.md +++ b/tiproxy/tiproxy-overview.md @@ -61,7 +61,12 @@ It is recommended that you use TiProxy for the scenarios that TiProxy is suitabl ## Installation and usage -This section describes how to deploy and change TiProxy using TiUP. For how to deploy TiProxy using TiDB Operator in Kubernetes, see [TiDB Operator documentation](https://docs.pingcap.com/tidb-in-kubernetes/stable/deploy-tiproxy). +This section describes how to deploy and change TiProxy using TiUP. + +For other deployment methods, refer to the following documents: + +- To deploy TiProxy using TiDB Operator, see the [TiDB Operator](https://docs.pingcap.com/zh/tidb-in-kubernetes/stable/deploy-tiproxy) documentation. +- To quickly deploy TiProxy locally using TiUP, see [Deploy TiProxy](/tiup/tiup-playground.md#deploy-tiproxy). ### Deploy TiProxy @@ -83,9 +88,6 @@ This section describes how to deploy and change TiProxy using TiUP. For how to d tidb: security.session-token-signing-cert: "/var/sess/cert.pem" security.session-token-signing-key: "/var/sess/key.pem" - security.ssl-ca: "/var/ssl/ca.pem" - security.ssl-cert: "/var/ssl/cert.pem" - security.ssl-key: "/var/ssl/key.pem" graceful-wait-before-shutdown: 15 ``` @@ -100,7 +102,7 @@ This section describes how to deploy and change TiProxy using TiUP. For how to d It is recommended to specify the version number of TiProxy in the topology configuration so that TiProxy will not be upgraded when you upgrade the TiDB cluster through [`tiup cluster upgrade`](/tiup/tiup-component-cluster-upgrade.md). Otherwise, the client connection might be disconnected during TiProxy upgrade. - To configure TiProxy configuration items, see [TiProxy configuration](/tiproxy/tiproxy-configuration.md). + To configure TiProxy configuration items, see [TiProxy configuration](/tiproxy/tiproxy-configuration.md). For more configurations of TiUP deployment topology, see [tiproxy-servers configurations](/tiup/tiup-cluster-topology-reference.md#tiproxy_servers). A configuration example is as follows: @@ -109,9 +111,6 @@ This section describes how to deploy and change TiProxy using TiUP. For how to d tiproxy: "v1.2.0" server_configs: tiproxy: - security.server-tls.ca: "/var/ssl/ca.pem" - security.server-tls.cert: "/var/ssl/cert.pem" - security.server-tls.key: "/var/ssl/key.pem" ha.virtual-ip: "10.0.1.10/24" ha.interface: "eth0" ``` diff --git a/tiup/tiup-cluster-topology-reference.md b/tiup/tiup-cluster-topology-reference.md index 924a38bb63aed..d57df126435c8 100644 --- a/tiup/tiup-cluster-topology-reference.md +++ b/tiup/tiup-cluster-topology-reference.md @@ -435,6 +435,8 @@ tiflash_servers: - `port`: The listening port of the TiProxy SQL services. The default value is `6000`. +- `status_port`: The listening port of the TiProxy status service. It is used to view the status of the TiProxy services from the external via HTTP requests. The default value is `3080`. + - `deploy_dir`: Specifies the deployment directory. If it is not specified or specified as a relative directory, the directory is generated based on the `deploy_dir` directory configured in `global`. - `data_dir`: Specifies the data directory. If it is not specified or specified as a relative directory, the directory is generated based on the `data_dir` directory configured in `global`. @@ -461,9 +463,19 @@ A `tiproxy_servers` configuration example is as follows: ```yaml tiproxy_servers: - host: 10.0.1.21 + port: 6000 + status_port: 3080 + config: + labels: { zone: "zone1" } - host: 10.0.1.22 + port: 6000 + status_port: 3080 + config: + labels: { zone: "zone2" } ``` +For more configuration examples, see [TiProxy Deployment Topology](/tiproxy/tiproxy-deployment-topology.md). + ### `kvcdc_servers` `kvcdc_servers` specifies the machines to which the [TiKV-CDC](https://tikv.org/docs/7.1/concepts/explore-tikv-features/cdc/cdc/) services are deployed. It also specifies the service configuration on each machine. `kvcdc_servers` is an array. Each array element contains the following fields: