Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tiproxy: improve deployment instructions for deploying TiProxy (#19904) #19908

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions config-templates/simple-tiproxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ global:
ssh_port: 22
deploy_dir: "/tidb-deploy"
data_dir: "/tidb-data"
<<<<<<< HEAD
=======
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
>>>>>>> b89d2702a2 (tiproxy: improve deployment instructions for deploying TiProxy (#19904))

pd_servers:
- host: 10.0.1.1
Expand All @@ -23,6 +35,22 @@ tikv_servers:

tiproxy_servers:
- host: 10.0.1.11
<<<<<<< HEAD
=======
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" }
>>>>>>> b89d2702a2 (tiproxy: improve deployment instructions for deploying TiProxy (#19904))

monitoring_servers:
- host: 10.0.1.13
Expand Down
73 changes: 71 additions & 2 deletions tiproxy/tiproxy-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -42,8 +44,17 @@ Configuration for SQL port.

+ Default value: `0.0.0.0:6000`
+ Support hot-reload: no
+ SQL gateway address. The format is `<ip>:<port>`.
+ The listening address of the SQL service. The format is `<ip>:<port>`. This configuration item is automatically set when you deploy TiProxy using TiUP or TiDB Operator.

<<<<<<< HEAD
=======
#### `advertise-addr`

+ Default value: `""`
+ Support hot-reload: no
+ 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.

>>>>>>> b89d2702a2 (tiproxy: improve deployment instructions for deploying TiProxy (#19904))
#### `graceful-wait-before-shutdown`

+ Default value: `0`
Expand Down Expand Up @@ -101,6 +112,64 @@ Configurations for HTTP gateway.
+ Possible values: `""`, `"v2"`
+ Enable the [PROXY protocol](https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt) on the port. `"v2"` indicates using the PROXY protocol version 2, and `""` indicates disabling the PROXY protocol.

<<<<<<< HEAD
=======
### balance

Configurations for the load balancing policy of TiProxy.

#### `label-name`

+ Default value: `""`
+ Support hot-reload: yes
+ Specifies the label name used for [label-based load balancing](/tiproxy/tiproxy-load-balance.md#label-based-load-balancing). TiProxy matches the label values of TiDB servers based on this label name and prioritizes routing requests to TiDB servers with the same label value as itself.
+ The default value of `label-name` is an empty string, indicating that label-based load balancing is not used. To enable this load balancing policy, you need to set this configuration item to a non-empty string and configure both [`labels`](#labels) in TiProxy and [`labels`](/tidb-configuration-file.md#labels) in TiDB. For more information, see [Label-based load balancing](/tiproxy/tiproxy-load-balance.md#label-based-load-balancing).

#### `policy`

+ Default value: `resource`
+ Support hot-reload: yes
+ Possible values: `resource`, `location`, `connection`
+ Specifies the load balancing policy. For the meaning of each possible value, see [TiProxy load balancing policies](/tiproxy/tiproxy-load-balance.md#configure-load-balancing-policies).

### ha

High availability configurations for TiProxy.

#### `virtual-ip`

+ Default value: `""`
+ 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.
> - The Linux user running TiProxy must have permission to bind IP addresses.
> - The virtual IP and the IPs of all TiProxy instances must be within the same CIDR range.

#### `interface`

+ Default value: `""`
+ Support hot-reload: no
+ Specifies the network interface to bind the virtual IP to, such as `"eth0"`. The virtual IP will be bound to a TiProxy instance only when both [`ha.virtual-ip`](#virtual-ip) and `ha.interface` are set.

### `labels`

+ Default value: `{}`
+ Support hot-reload: yes
+ Specifies server labels. For example, `{ zone = "us-west-1", dc = "dc1" }`.

>>>>>>> b89d2702a2 (tiproxy: improve deployment instructions for deploying TiProxy (#19904))
### log

#### `level`
Expand Down
6 changes: 6 additions & 0 deletions tiproxy/tiproxy-deployment-topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions tiproxy/tiproxy-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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

Expand All @@ -77,9 +82,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
```

Expand All @@ -94,7 +96,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:

Expand All @@ -103,9 +105,14 @@ This section describes how to deploy and change TiProxy using TiUP. For how to d
tiproxy: "v1.0.0"
server_configs:
tiproxy:
<<<<<<< HEAD
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"
>>>>>>> b89d2702a2 (tiproxy: improve deployment instructions for deploying TiProxy (#19904))
```

4. Start the cluster.
Expand Down
14 changes: 14 additions & 0 deletions tiup/tiup-cluster-topology-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,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`.
Expand All @@ -459,9 +461,18 @@ 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" }
```

<<<<<<< HEAD
### `pump_servers`

`pump_servers` specifies the machines to which the Pump services of TiDB Binlog are deployed. It also specifies the service configuration on each machine. `pump_servers` is an array, and each element of the array contains the following fields:
Expand Down Expand Up @@ -566,6 +577,9 @@ drainer_servers:
- db-name: test
tbl-name: audit
```
=======
For more configuration examples, see [TiProxy Deployment Topology](/tiproxy/tiproxy-deployment-topology.md).
>>>>>>> b89d2702a2 (tiproxy: improve deployment instructions for deploying TiProxy (#19904))

### `kvcdc_servers`

Expand Down
Loading