title | summary |
---|---|
TiProxy Command-Line Flags |
Learn the command-line startup flags of TiProxy. |
This document introduces the command-line flags that you can use when you launch TiProxy. It also introduces flags of tiproxyctl
.
This section lists the flags of the server program tiproxy
.
- Specifies the address that clients use to connect to this TiProxy instance.
- Type:
string
- Default:
""
- This flag 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 path of the TiProxy configuration file.
- Type:
string
- Default:
""
- You must specify the configuration file. For detailed configuration items, refer to Configure TiProxy. Note that TiProxy automatically reloads the configuration when the configuration file is modified. Therefore, do not directly modify the configuration file. It is recommended to modify the configuration by executing
tiup cluster edit-config
orkubectl edit tc
.
This section introduces the installation methods, syntax, options, and commands of the client program tiproxyctl
.
You can install TiProxy Control using one of the following two methods.
Note:
TiProxy Control is specifically designed for debugging purposes and might not be fully compatible with future capabilities introduced in TiProxy. It's not recommended to include this tool in application or utility development to get information.
After installing TiUP, you can use the tiup install tiproxy
command to download and install the binary programs for TiProxy and TiProxy Control. After installation, you can use tiup --binary tiproxy
to view the installation path of TiProxy. TiProxy Control is located in the same directory as TiProxy.
For example:
tiup install tiproxy
# download https://tiup-mirrors.pingcap.com/tiproxy-v1.3.0-linux-amd64.tar.gz 22.51 MiB / 22.51 MiB 100.00% 13.99 MiB/s
ls `tiup --binary tiproxy`ctl
# /root/.tiup/components/tiproxy/v1.3.0/tiproxyctl
Compilation environment requirement: Go 1.21 or later
Compilation procedures: Go to the root directory of the TiProxy project, use the make
command to compile and generate tiproxyctl
.
git clone https://github.com/pingcap/tiproxy.git
cd tiproxy
make
ls bin/tiproxyctl
tiproxyctl [flags] [command]
For example:
tiproxyctl --host 127.0.0.1 --port 3080 config get
- Specifies the TiProxy server address.
- Type:
string
- Default:
localhost
- Specifies the port number of the TiProxy API gateway.
- Type:
int
- Default:
3080
-
Specifies the log format of
tiproxyctl
. -
Type:
string
-
Default:
"tidb"
-
It defaults to the same log format of TiDB. However, you can also specify it as one of the following:
console
: a more human-readable formatjson
: a structured log format
- Specifies the log level of tiproxyctl.
- Type:
string
- Default:
"warn"
- You can specify
debug
,info
,warn
,error
,panic
.
- Specifies whether to skip TLS CA verification when dialing to the server.
- Type:
boolean
- Default:
false
- Used for testing.
- Specifies the CA when dialing to the server.
- Type:
string
- Default:
""
- Specifies the certificate when dialing to the server.
- Type:
string
- Default:
""
The tiproxyctl config set
command reads a TOML-formatted configuration file from standard input and sets these configuration items to TiProxy. Unspecified configuration items will remain unchanged, so you only need to specify the items that you want to modify.
The following example sets log.level
as 'warning'
, while leaving other configuration items unchanged.
$ cat test.toml
[log]
level='warning'
$ cat test.toml | tiproxyctl config set
""
$ tiproxyctl config get | grep level
level = 'warning'
The tiproxyctl config get
command is used to get the current TiProxy configuration in TOML format.
The tiproxyctl health
command is used to get the health status of TiProxy and the checksum of the configuration. When TiProxy is running normally, it returns the checksum of the configuration. When TiProxy is shutting down or offline, it returns an error.
Example output:
{"config_checksum":3006078629}
The tiproxyctl traffic capture
command is used to capture traffic.
Options:
--output
: (required) specifies the directory to store traffic files.--duration
: (required) specifies the duration of capture. The unit is one ofm
(minutes),h
(hours), ord
(days). For example,--duration=1h
captures traffic for one hour.
Example:
The following command connects to the TiProxy instance at 10.0.1.10:3080
, captures traffic for one hour, and saves it to the /tmp/traffic
directory on the TiProxy instance:
tiproxyctl traffic capture --host 10.0.1.10 --port 3080 --output="/tmp/traffic" --duration=1h
The tiproxyctl traffic replay
command is used to replay captured traffic.
Options:
--username
: (required) specifies the database username for replay.--password
: (optional) specifies the password for the username. The default value is an empty string""
.--input
: (required) specifies the directory containing traffic files.--speed
: (optional) specifies the replay speed multiplier. The range is[0.1, 10]
. The default value is1
, indicating replay at the original speed.
Example:
The following command connects to the TiProxy instance at 10.0.1.10:3080
using username u1
and password 123456
, reads traffic files from the /tmp/traffic
directory on the TiProxy instance, and replays the traffic at twice the original speed:
tiproxyctl traffic replay --host 10.0.1.10 --port 3080 --username="u1" --password="123456" --input="/tmp/traffic" --speed=2
The tiproxyctl traffic cancel
command is used to cancel the current capture or replay task.
The tiproxyctl traffic show
command is used to display historical capture and replay tasks.
The status
field in the output indicates the task status, with the following possible values:
done
: the task completed normally.canceled
: the task was canceled. You can check theerror
field for the reason.running
: the task is running. You can check theprogress
field for the completion percentage.
Example output:
[
{
"type": "capture",
"start_time": "2024-09-01T14:30:40.99096+08:00",
"end_time": "2024-09-01T16:30:40.99096+08:00",
"duration": "2h",
"output": "/tmp/traffic",
"progress": "100%",
"status": "done"
},
{
"type": "capture",
"start_time": "2024-09-02T18:30:40.99096+08:00",
"end_time": "2024-09-02T19:00:40.99096+08:00",
"duration": "2h",
"output": "/tmp/traffic",
"progress": "25%",
"status": "canceled",
"error": "canceled manually"
},
{
"type": "capture",
"start_time": "2024-09-03T13:31:40.99096+08:00",
"duration": "2h",
"output": "/tmp/traffic",
"progress": "45%",
"status": "running"
}
]