|
1 | 1 | --- |
2 | 2 | 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. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # Get Started with TiDB Cloud CLI |
@@ -86,73 +86,58 @@ Depending on your operating system, take the following steps to install TiDB Clo |
86 | 86 |
|
87 | 87 | 2. Provide the following information: |
88 | 88 |
|
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). |
90 | 90 | - Your TiDB Cloud API public key and private key. |
91 | 91 |
|
92 | 92 | 3. Run a read-only command to verify that the CLI can access TiDB Cloud using the saved credentials: |
93 | 93 |
|
94 | 94 | ```bash |
95 | | - ti db list-db-clusters --db-cluster-type starter --output text |
| 95 | + ti fs list-file-systems |
96 | 96 | ``` |
97 | 97 |
|
98 | 98 | Example output: |
99 | 99 |
|
100 | 100 | ```bash |
101 | 101 | { |
102 | | - "profile": "default", |
103 | | - "region_code": "aws-us-east-1", |
104 | | - "credentials_stored": true |
| 102 | + "region_code": "aws-us-west-2", |
| 103 | + "file_systems": [] |
105 | 104 | } |
106 | 105 | ``` |
107 | 106 |
|
108 | 107 | ## Step 3. Choose a workflow |
109 | 108 |
|
110 | | -Complete either of the following workflows. |
| 109 | +Proceed with either of the following workflows based on your needs: |
111 | 110 |
|
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) |
114 | 113 |
|
115 | | -### Option A: Create and use a file system |
| 114 | +### Option A: TiDB Cloud Filesystem |
116 | 115 |
|
117 | 116 | TiDB Cloud Filesystem is a persistent, shareable cloud file system that you can use across local machines, CI jobs, sandboxes, and other ephemeral environments. |
118 | 117 |
|
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): |
120 | 119 |
|
121 | 120 | ```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)" |
126 | 122 | ``` |
127 | 123 |
|
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): |
131 | 125 |
|
132 | 126 | ```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 |
145 | 132 | ``` |
146 | 133 |
|
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): |
148 | 135 |
|
149 | 136 | ```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 |
153 | 138 | ``` |
154 | 139 |
|
155 | | -### Option B: Create a TiDB Cloud Starter instance and query the database |
| 140 | +### Option B: TiDB Cloud Starter |
156 | 141 |
|
157 | 142 | 1. Create a TiDB Cloud Starter instance and save its ID: |
158 | 143 |
|
@@ -180,13 +165,13 @@ TiDB Cloud Filesystem is a persistent, shareable cloud file system that you can |
180 | 165 |
|
181 | 166 | The `ti db execute-sql-statement` command executes the query through the HTTPS SQL API. The output includes `ready = 1`. |
182 | 167 |
|
183 | | -3. Delete the TiDB Cloud Starter instance: |
| 168 | +3. Generate the connection string: |
184 | 169 |
|
185 | 170 | ```bash |
186 | | - ti db delete-db-cluster \ |
| 171 | + DATABASE_URL=$(ti db format-db-connection-string \ |
187 | 172 | --db-cluster-id "$TI_DB_CLUSTER_ID" \ |
188 | | - --wait |
189 | | - unset TI_DB_CLUSTER_ID |
| 173 | + --read-write --query connection_string \ |
| 174 | + --output text) |
190 | 175 | ``` |
191 | 176 |
|
192 | 177 | ## What's next |
|
0 commit comments