Skip to content

Commit

Permalink
Merge pull request #724 from cybozu-go/read-only
Browse files Browse the repository at this point in the history
Add procedure to set cluster to read-only
  • Loading branch information
ymmt2005 authored Aug 5, 2024
2 parents de8e67a + ce6332b commit e866c56
Showing 1 changed file with 30 additions and 0 deletions.
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>
```

0 comments on commit e866c56

Please sign in to comment.