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

Add procedure to set cluster to read-only #724

Merged
merged 2 commits into from
Aug 5, 2024
Merged
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
30 changes: 30 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ After [setting up MOCO](setup.md), you can create MySQL clusters with a custom r
- [Upgrading mysql version](#upgrading-mysql-version)
- [Re-initializing an errant replica](#re-initializing-an-errant-replica)
- [Stop Clustering and Reconciliation](#stop-clustering-and-reconciliation)
- [Set to Read Only](#set-to-read-only)

## Basics

Expand Down Expand Up @@ -805,3 +806,32 @@ moco_cluster_healthy{name="test",namespace="default"} NaN
moco_cluster_ready_replicas{name="test",namespace="default"} NaN
moco_cluster_errant_replicas{name="test",namespace="default"} NaN
```

### Set to Read Only

When you want to set MOCO's MySQL to read-only, use the the following commands.

MOCO makes the primary instance writable in the clustering process.
Therefore, please be sure to stop clustering when you set it to read-only.

```console
$ kubectl moco stop clustering <CLSUTER_NAME>
$ kubectl moco mysql -u moco-admin <CLSUTER_NAME> -- -e "SET GLOBAL super_read_only=1"
```

You can check whether the cluster is read-only with the following command.

```console
$ kubectl moco mysql -it <CLSUTER_NAME> -- -e "SELECT @@super_read_only"
+-------------------+
| @@super_read_only |
+-------------------+
| 1 |
+-------------------+
```

If you want to leave read-only mode, restart clustering as follows. Then, MOCO will make the cluster writable.

```console
$ kubectl moco start clustering <CLSUTER_NAME>
```
Loading