Skip to content
This repository was archived by the owner on Nov 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 30bb51f

Browse files
committedSep 20, 2024·
1 parent 3070ea2 commit 30bb51f

File tree

9 files changed

+873
-32
lines changed

9 files changed

+873
-32
lines changed
 
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: 'Cluster configuration'
3+
subtitle: 'Create and manage sharded and unsharded keyspaces for your database.'
4+
date: '2024-09-20'
5+
---
6+
7+
{% callout type="warning" %}
8+
Misconfiguration can cause availability issues. We recommend thoroughly reading through the documentation in the [Sharding section](/docs/sharding/overview) of the docs prior to making any changes. If you have any questions, please [reach out to our support team](https://support.planetscale.com).
9+
{% /callout %}
10+
11+
## Overview
12+
13+
The **Cluster configuration** tab in your PlanetScale dashboard allows you to create and manage sharded and unsharded keyspaces.
14+
15+
From here, you can:
16+
17+
- Create a sharded or unsharded keyspace
18+
- Adjust the instance sizes for keyspaces
19+
- Adjust the number of replicas for keyspaces
20+
- Adjust the VSchema
21+
22+
These are advanced configuration settings that expose some of the underlying Vitess configuration of your cluster.
23+
24+
This documentation will cover how to use everything in this cluster configuration page. For a full walkthrough with an example of setting up a sharded keyspace, refer to the [Sharding quickstart](/docs/sharding/sharding-quickstart).
25+
26+
## Limitations
27+
28+
Before you adjust any cluster configuration settings, it is important that you read through the following limitations:
29+
30+
- This feature can currently only be used to shard **new** tables.
31+
- If you are an existing PlanetScale customer with already sharded tables, you can use the Cluster configuration settings to adjust the instance size, number of replicas, and VSchema for **already sharded tables**.
32+
- Sharded keyspaces are not currently supported on databases that have foreign key constraints enabled.
33+
34+
If you have existing tables that need sharding, or if you would like additional support from our expert team, our [Enterprise plan](/docs/concepts/planetscale-plans#planetscale-enterprise-plan) may be a good fit. [Get in touch](/contact) for a quick assessment.
35+
36+
## Create a keyspace
37+
38+
To create a new [keyspace](/docs/sharding/keyspaces):
39+
40+
1. Select the database you want to configure.
41+
2. Click "Cluster configuration" in the left nav.
42+
3. You should see the existing unsharded keyspace for your database here.
43+
4. Click "New keyspace".
44+
5. Enter the keyspace name. For example, if your existing unsharded keyspace is named `books`, you may create a sharded keyspace named `books-sharded`.
45+
6. Select whether you want to keep it unsharded, or, if not, select the number of shards you to exist in this keyspace. In most cases, you will be adding a new sharded keyspace. Adding a new unsharded keyspace is not a common use case.
46+
47+
**Note**: The cost of adding this additional keyspace largely depends on the number of shards you choose, the cluster size, and if you'd like to add additional replicas.
48+
49+
7. Choose the cluster sizes you would like to use for this keyspace. Keep in mind, if you are creating a sharded keyspace, this will spin up multiple clusters of the selected size. For example, if you are creating 4 shards and choose the `PS-80` cluster size, we will create 4 `PS-80`s, each with 1 primary and 2 replicas.
50+
8. Select the number of _additional_ replicas, if any, that you'd like to add to each cluster. Each cluster comes with 2 replicas by default, so any number you choose will be in addition to those 2.
51+
9. Review the new monthly cost for this keyspace below. This is in addition to your existing unsharded keyspace, as well as any other keyspaces you add.
52+
10. Once satisfied, click "Create keyspace".
53+
54+
## Modify the VSchema of a keyspace via cluster configuration tab
55+
56+
**Note**: You can modify the VSchema on your development branch either in the cluster configuration tab, using the []`ALTER VSCHEMA` command](/docs/sharding/vschema#modifying-vschema), or with the pscale CLI using [`pscale keyspace vschema update`](/docs/reference/keyspace).
57+
58+
Once you have created your keyspace, you will see a new tab: **VSchema**. The VSchema contains information about how the keyspace is sharded, sequence tables, and other Vitess schema information. The VSchema tab allows you to configure the Vschema for your new keyspace or modify it for existing keyspaces.
59+
60+
We do not recommend modifying the VSchema directly on your production branch. In fact, it is not possible to do if you have [safe migrations](/docs/concepts/safe-migrations) enabled (as recommended). Instead, to modify the VSchema, you should first [create a new development branch](/docs/concepts/branching). Once you have your branch ready, follow these steps:
61+
62+
1. To update the VSchema in the cluster configuration panel, select your new development branch from the dropdown at the top, and then select the keyspace below that has the VSchema you'd like to modify.
63+
2. Next, click the tab labeled "VSchema".
64+
3. Modify the VSchema configuration JSON file as needed. Refer to the [VSchema documentation](/docs/sharding/vschema) for more information about the available options.
65+
4. When finished, click "Save changes". We will validate your VSchema, and if it is valid, the changes will be saved. If there are errors, we will warn you here to change them before saving.
66+
5. Go back to your "Branches" tab and click on the development branch that you modified. You should see a note on the right that says "Updated VSchema configuration" which lets you know the VSchema(s) for this branch has been modified.
67+
6. From here, go through the normal [deploy request process](/docs/concepts/deploy-requests) to deploy this change to production.
68+
69+
Once your change is deployed to production, you can come back to the cluster configuration page, switch to your production branch, and view the updates to your VSchema. You can also click the "Changes" tab to see information, such as the resize event, status, and start/end time for any previous changes to the VSchema.
70+
71+
## Modify routing rules
72+
73+
This configuration setting is currently only available for some Enterprise customers. To modify your routing rules, click "Manage routing rules" on the bottom left of the keyspace configuration panel.
74+
75+
Again, you will need to create a new branch to modify routing rules, as described in the "Modify the VSchema of a keyspace" section above.

‎docs/navigation/standard.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@
202202
items:
203203
- label: 'Cluster sizing'
204204
slug: '/docs/concepts/cluster-sizing'
205+
- label: 'Cluster configuration'
206+
slug: '/docs/concepts/cluster-configuration'
205207
- label: 'Replicas'
206208
slug: '/docs/concepts/replicas'
207209
- label: 'Read-only regions'
@@ -214,8 +216,14 @@
214216
items:
215217
- label: 'Sharding with PlanetScale'
216218
slug: '/docs/sharding/overview'
217-
- label: 'View and update VSchema'
219+
- label: 'Sharding quickstart'
220+
slug: '/docs/sharding/sharding-quickstart'
221+
- label: 'VSchema'
218222
slug: '/docs/sharding/vschema'
223+
- label: 'Vindexes'
224+
slug: '/docs/sharding/vindexes'
225+
- label: 'Keyspaces'
226+
slug: '/docs/sharding/keyspaces'
219227
- label: 'Creating sequence tables'
220228
slug: '/docs/sharding/sequence-tables'
221229

@@ -306,6 +314,8 @@
306314
slug: '/docs/reference/data-imports'
307315
- label: 'deploy-request'
308316
slug: '/docs/reference/deploy-request'
317+
- label: 'keyspace'
318+
slug: '/docs/reference/keyspace'
309319
- label: 'org'
310320
slug: '/docs/reference/org'
311321
- label: 'password'

‎docs/reference/branch.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'PlanetScale CLI commands: branch'
33
subtitle: 'Use the PlanetScale CLI “branch” command to create, delete, diff, and manage branches from your terminal.'
4-
date: '2023-04-05'
4+
date: '2020-09-20'
55
meta:
66
title: 'CLI reference: branch'
77
---
@@ -22,21 +22,20 @@ pscale branch <SUB-COMMAND> <FLAG>
2222

2323
### Available sub-commands
2424

25-
| **Sub-command** | **Sub-command flags** | **Description** |
26-
| ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
27-
| `create <DATABASE_NAME> <BRANCH_NAME>` | `--from <SOURCE_BRANCH>`, `--region <BRANCH_REGION>`, `--restore <BACKUP_NAME>`, `--seed-data`, `--wait` | Create a new branch on the specified database |
28-
| `delete <DATABASE_NAME> <BRANCH_NAME>` | `--force` | Delete the specified branch from the a database |
29-
| `diff <DATABASE_NAME> <BRANCH_NAME>` | `--web` | Show the diff of the specified branch against the parent branch. |
30-
| `keyspaces <DATABASE_NAME> <BRANCH_NAME>` | | Show information for sharded keyspaces. |
31-
| `list <DATABASE_NAME>` | `--web` | List all branches of a database |
32-
| `promote <DATABASE_NAME> <BRANCH_NAME>` | | Promote a database branch to production |
33-
| `refresh-schema <DATABASE_NAME> <BRANCH_NAME>` | | Refresh the schema for a database branch |
34-
| `safe-migrations enable <DATABASE_NAME> <BRANCH_NAME>` | | Enables safe migrations for a database branch |
35-
| `safe-migrations disable <DATABASE_NAME> <BRANCH_NAME>` | | Disables safe migrations for a database branch |
36-
| `schema <DATABASE_NAME> <BRANCH_NAME>` | `--web` | Show the schema of a branch |
37-
| `show <DATABASE_NAME> <BRANCH_NAME>` | `--web` | Show a specific backup of a branch |
38-
| `switch <BRANCH_NAME> --database <DATABASE_NAME>` | `--database <DATABASE_NAME>`\*, `--create`, `parent-branch <BRANCH_NAME>` | Switch to the specified branch |
39-
| `vschema <DATABASE_NAME> <BRANCH_NAME>` | | Show the vschema for a sharded keyspace. Empty on non-sharded keyspaces. |
25+
| **Sub-command** | **Sub-command flags** | **Description** |
26+
| ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
27+
| `create <DATABASE_NAME> <BRANCH_NAME>` | `--from <SOURCE_BRANCH>`, `--region <BRANCH_REGION>`, `--restore <BACKUP_NAME>`, `--seed-data`, `--wait` | Create a new branch on the specified database |
28+
| `delete <DATABASE_NAME> <BRANCH_NAME>` | `--force` | Delete the specified branch from the a database |
29+
| `diff <DATABASE_NAME> <BRANCH_NAME>` | `--web` | Show the diff of the specified branch against the parent branch. |
30+
| `keyspaces <DATABASE_NAME> <BRANCH_NAME>` | | Show information for sharded keyspaces. |
31+
| `list <DATABASE_NAME>` | `--web` | List all branches of a database |
32+
| `promote <DATABASE_NAME> <BRANCH_NAME>` | | Promote a database branch to production |
33+
| `refresh-schema <DATABASE_NAME> <BRANCH_NAME>` | | Refresh the schema for a database branch |
34+
| `safe-migrations enable <DATABASE_NAME> <BRANCH_NAME>` | | Enables safe migrations for a database branch |
35+
| `safe-migrations disable <DATABASE_NAME> <BRANCH_NAME>` | | Disables safe migrations for a database branch |
36+
| `schema <DATABASE_NAME> <BRANCH_NAME>` | `--web` | Show the schema of a branch |
37+
| `show <DATABASE_NAME> <BRANCH_NAME>` | `--web` | Show a specific backup of a branch |
38+
| `switch <BRANCH_NAME> --database <DATABASE_NAME>` | `--database <DATABASE_NAME>`\*, `--create`, `parent-branch <BRANCH_NAME>` | Switch to the specified branch |
4039

4140
> \* _Flag is required_
4241

‎docs/reference/keyspace.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: 'PlanetScale CLI commands: keyspace'
3+
subtitle: 'Use the PlanetScale CLI "keyspace" command to create and modify keyspaces and VSchemas from the pscale CLI.'
4+
date: '2024-09-20'
5+
meta:
6+
title: 'CLI reference: keyspace'
7+
---
8+
9+
## Getting started
10+
11+
Make sure to first [set up your PlanetScale developer environment](/docs/concepts/planetscale-environment-setup). Once you've installed the `pscale` CLI, you can interact with PlanetScale and manage your databases straight from the command line.
12+
13+
## The `keyspace` command
14+
15+
This command allows you to view your keyspaces and view or update your VSchemas.
16+
17+
**Usage:**
18+
19+
```bash
20+
pscale keyspace <SUB-COMMAND> <FLAG>
21+
```
22+
23+
### Available sub-commands
24+
25+
| **Sub-command** | **Sub-command flags** | **Description** |
26+
| -------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------ |
27+
| `list <DATABASE_NAME> <BRANCH_NAME>` ` | | List all keyspaces within a database branch. |
28+
| `show <DATABASE_NAME> <BRANCH_NAME> <KEYSPACE_NAME>` | | Show a specific keyspace within a database branch. |
29+
| `vschema show <DATABASE_NAME> <BRANCH_NAME> <KEYSPACE_NAME>` | | Show the VSchema for a sharded keyspace. Empty on non-sharded keyspaces. |
30+
| `vschema update <DATABASE_NAME> <BRANCH_NAME> <KEYSPACE_NAME>` | `--vschema <FILE>`\* | Update a VSchema of a keyspace. |
31+
32+
> \* _Flag is required_
33+
34+
#### Sub-command flag descriptions
35+
36+
| **Sub-command flag** | **Description** | **Applicable sub-commands** |
37+
| -------------------- | ------------------------------------------------- | --------------------------- |
38+
| `--vschema <FILE>` | `<FILE>` is the path to the updated VSchema file. | `vschema update` |
39+
40+
### Available flags
41+
42+
| **Flag** | **Description** |
43+
| --------------------------- | ------------------------------------- |
44+
| `-h`, `--help` | View help for auth command |
45+
| `--org <ORGANIZATION_NAME>` | The organization for the current user |
46+
47+
### Global flags
48+
49+
| **Command** | **Description** |
50+
| ------------------------------- | ------------------------------------------------------------------------------------ |
51+
| `--api-token <TOKEN>` | The API token to use for authenticating against the PlanetScale API. |
52+
| `--api-url <URL>` | The base URL for the PlanetScale API. Default is `https://api.planetscale.com/`. |
53+
| `--config <CONFIG_FILE>` | Config file. Default is `$HOME/.config/planetscale/pscale.yml`. |
54+
| `--debug` | Enable debug mode. |
55+
| `-f`, `--format <FORMAT>` | Show output in a specific format. Possible values: `human` (default), `json`, `csv`. |
56+
| `--no-color` | Disable color output. |
57+
| `--service-token <TOKEN>` | The service token for authenticating. |
58+
| `--service-token-id <TOKEN_ID>` | The service token ID for authenticating. |

‎docs/sharding/keyspaces.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: 'What is a keyspace'
3+
subtitle: 'Learn about what a keyspace is and how to modify them on your PlanetScale database.'
4+
date: '2024-09-20'
5+
---
6+
7+
A keyspace is a logical database that maps directly to your database in PlanetScale. Once you begin sharding, you will create a new keyspace, or keyspaces, where your shards will exist. These sharded keyspaces map to new logical databases in your PlanetScale database.
8+
9+
To get a better sense of this, click on your [Cluster configuration](/docs/concepts/cluster-configuration) tab in your dashboard. If you have an existing unsharded database, you'll see that database listed there as an unsharded keyspace. If you click "New keyspace", you're able to configure a brand new keyspace here.
10+
11+
The most common use case for creating a new keyspace is to shard one or multiple tables.
12+
13+
All of your keyspaces are separate databases. And, again, sharded keyspaces hold multiple databases. However, with the power of Vitess, your application views these all as a single database. It uses the VTGate load balancer to route queries to the correct keyspace, and then the correct shard, and finally the correct primary or replica, as configured.
14+
15+
For more information about modifying a keyspace, please see the [Cluster configuration documentation](/docs/concepts/cluster-configuration).
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
This repository has been archived.