Skip to content

Commit ffc0b60

Browse files
authored
refine ti-cli quick start (#23935)
1 parent c53928b commit ffc0b60

1 file changed

Lines changed: 24 additions & 39 deletions

File tree

‎ai/ti/ti-quick-start.md‎

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Get Started with TiDB Cloud CLI
3-
summary: Install and configure TiDB Cloud CLI, then create and use a file system or query a TiDB Cloud Starter database.
3+
summary: Install and configure TiDB Cloud CLI, then create and use a file system or manage and query a TiDB Cloud Starter database.
44
---
55

66
# Get Started with TiDB Cloud CLI
@@ -86,73 +86,58 @@ Depending on your operating system, take the following steps to install TiDB Clo
8686

8787
2. Provide the following information:
8888

89-
- A default region for CLI operations, specified as a region code (such as `aws-us-east-1`). For a list of regions that are supported by TiDB Cloud CLI, see [Supported regions](/ai/ti/reference/ti-regions-security-and-limitations.md#supported-regions).
89+
- A default region for CLI operations, specified as a region code (such as `aws-us-west-2`). For a list of regions that are supported by TiDB Cloud CLI, see [Supported regions](/ai/ti/reference/ti-regions-security-and-limitations.md#supported-regions).
9090
- Your TiDB Cloud API public key and private key.
9191

9292
3. Run a read-only command to verify that the CLI can access TiDB Cloud using the saved credentials:
9393

9494
```bash
95-
ti db list-db-clusters --db-cluster-type starter --output text
95+
ti fs list-file-systems
9696
```
9797

9898
Example output:
9999

100100
```bash
101101
{
102-
"profile": "default",
103-
"region_code": "aws-us-east-1",
104-
"credentials_stored": true
102+
"region_code": "aws-us-west-2",
103+
"file_systems": []
105104
}
106105
```
107106

108107
## Step 3. Choose a workflow
109108

110-
Complete either of the following workflows.
109+
Proceed with either of the following workflows based on your needs:
111110

112-
- [Option A: Create and use a file system](/ai/ti/ti-quick-start.md#option-a-create-and-use-a-file-system)
113-
- [Option B: Create a TiDB Cloud Starter instance and query the database](/ai/ti/ti-quick-start.md#option-b-create-a-tidb-cloud-starter-instance-and-query-the-database)
111+
- [Option A: TiDB Cloud Filesystem](/ai/ti/ti-quick-start.md#option-a-tidb-cloud-filesystem)
112+
- [Option B: TiDB Cloud Starter](/ai/ti/ti-quick-start.md#option-b-tidb-cloud-starter)
114113

115-
### Option A: Create and use a file system
114+
### Option A: TiDB Cloud Filesystem
116115

117116
TiDB Cloud Filesystem is a persistent, shareable cloud file system that you can use across local machines, CI jobs, sandboxes, and other ephemeral environments.
118117

119-
1. Create a file system, wait until it is ready, and save its server-assigned ID:
118+
1. Create a file system and obtain the default access token (typically performed outside the sandbox):
120119

121120
```bash
122-
export TI_FS_FILE_SYSTEM_ID="$(ti fs create-file-system \
123-
--wait \
124-
--query file_system_id \
125-
--output text)"
121+
export TI_FS_TOKEN="$(ti fs create-file-system --display-name agent-workspace --wait --query fs_token --output text --region aws-us-west-2)"
126122
```
127123

128-
`ti` stores the file system credential locally, so you do not need to provide it for subsequent file operations.
129-
130-
2. Write a file to the file system, and then read the file:
124+
2. Mount the file system to a local path and use it as a normal POSIX-compliant file system (typically performed within the sandbox):
131125

132126
```bash
133-
printf 'hello from ti\n' | ti fs copy-file \
134-
--from-stdin \
135-
--to-remote /hello.txt
136-
137-
ti fs read-file \
138-
--path /hello.txt
139-
```
140-
141-
Expected output:
142-
143-
```text
144-
hello from ti
127+
export TI_FS_TOKEN=$TI_FS_TOKEN
128+
mkdir ~/mnt-test
129+
ti fs mount-file-system --file-system-name agent-workspace --mount-path ~/mnt-test --region aws-us-west-2
130+
echo 'Hello Sandbox Workspace' >> ~/mnt-test/hello.txt
131+
ls -l ~/mnt-test/hello.txt
145132
```
146133

147-
3. Delete the file system:
134+
3. Unmount the file system to release the workspace before passing it to another sandbox (typically performed within the sandbox):
148135

149136
```bash
150-
ti fs delete-file-system \
151-
--file-system-id "$TI_FS_FILE_SYSTEM_ID"
152-
unset TI_FS_FILE_SYSTEM_ID
137+
ti fs unmount-file-system --mount-path ~/mnt-test --region aws-us-west-2
153138
```
154139

155-
### Option B: Create a TiDB Cloud Starter instance and query the database
140+
### Option B: TiDB Cloud Starter
156141

157142
1. Create a TiDB Cloud Starter instance and save its ID:
158143

@@ -180,13 +165,13 @@ TiDB Cloud Filesystem is a persistent, shareable cloud file system that you can
180165

181166
The `ti db execute-sql-statement` command executes the query through the HTTPS SQL API. The output includes `ready = 1`.
182167

183-
3. Delete the TiDB Cloud Starter instance:
168+
3. Generate the connection string:
184169

185170
```bash
186-
ti db delete-db-cluster \
171+
DATABASE_URL=$(ti db format-db-connection-string \
187172
--db-cluster-id "$TI_DB_CLUSTER_ID" \
188-
--wait
189-
unset TI_DB_CLUSTER_ID
173+
--read-write --query connection_string \
174+
--output text)
190175
```
191176

192177
## What's next

0 commit comments

Comments
 (0)