From 86752db12024ab5d26b141a4f2a610ae73b1273b Mon Sep 17 00:00:00 2001 From: Masayuki Ishii Date: Mon, 5 Aug 2024 11:17:17 +0900 Subject: [PATCH 1/2] Add procedure to set cluster to read-only Signed-off-by: Masayuki Ishii --- docs/usage.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 48a5c21d..82e2e7f6 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -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 @@ -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 +$ kubectl moco mysql -u moco-admin -- -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 -- -e "SHOW GLOBAL VARIABLES like 'super_read_only'" ++-----------------+-------+ +| Variable_name | Value | ++-----------------+-------+ +| super_read_only | ON | ++-----------------+-------+ +``` + +If you want to leave read-only mode, restart clustering as follows. Then, MOCO will make the cluster writable. + +```console +$ kubectl moco start clustering +``` From ce6332b5eb3d6df2770a0cada58f6dd4d4d7788c Mon Sep 17 00:00:00 2001 From: Masayuki Ishii Date: Mon, 5 Aug 2024 13:18:30 +0900 Subject: [PATCH 2/2] Use SELECT --- docs/usage.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 82e2e7f6..264ab7f7 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -822,12 +822,12 @@ $ kubectl moco mysql -u moco-admin -- -e "SET GLOBAL super_read_o You can check whether the cluster is read-only with the following command. ```console -$ kubectl moco mysql -it -- -e "SHOW GLOBAL VARIABLES like 'super_read_only'" -+-----------------+-------+ -| Variable_name | Value | -+-----------------+-------+ -| super_read_only | ON | -+-----------------+-------+ +$ kubectl moco mysql -it -- -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.