You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/databases/mysql/cross-site-replication-of-mysql-db-on-lke/index.md
+55-52Lines changed: 55 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ external_resources:
15
15
16
16
Cross-site replication is a database pattern where changes written to a primary database in one location are copied to one or more replica databases in another location. In MySQL, this is commonly used to maintain a remote read-only copy of production data for disaster recovery testing, reporting, analytics, or standby capacity.
17
17
18
-
This guide uses Skupper to provide cross-site connectivity across Linode Kubernetes Engine (LKE) clusters in different regions. Skupper creates a secure application network between Kubernetes clusters. It allows workloads in one cluster to reach selected services in another cluster without requiring direct Pod-to-Pod networking or a custom VPN. In this guide, Skupper exposes the writable MySQL primary in `site-1` to the MySQL Pods in `site-2` by using a shared service name.
18
+
This guide uses Skupper to connect Linode Kubernetes Engine (LKE) clusters in different regions. Skupper creates a secure application network between Kubernetes clusters. It allows workloads in one cluster to reach selected services in another cluster without requiring direct Pod-to-Pod networking or a custom VPN. In this guide, Skupper exposes the writable MySQL primary in `site-1` to the MySQL Pods in `site-2` by using a shared service name.
19
19
20
20
This solves a specific problem for MySQL deployed across LKE regions. The source and destination databases live in separate Kubernetes clusters with separate internal networks. The approach in this guide combines Skupper for connectivity, the MySQL Clone plugin for initial seeding, and GTID-based replication for ongoing change streaming.
21
21
@@ -47,7 +47,7 @@ This guide demonstrates a one-way replication setup from site-1 to site-2. It do
47
47
48
48
### Placeholders
49
49
50
-
This tutorial contains a number of placeholders that are intended to be replaced by values from your own environment. The table below lists these placeholders, what they represent, and the example values used in this guide:
50
+
Replace the following placeholders with values from your own environment:
51
51
52
52
| Placeholder | Description | Example |
53
53
| -- | -- | -- |
@@ -68,7 +68,7 @@ Additionally, this guide uses the following fixed example values consistently th
68
68
69
69
### Configure `kubectl` Contexts
70
70
71
-
If you followed the guides linked above, you should have already installed`kubectl` and set up kubeconfig. For simplicity, rename these contexts to `site-1` and `site-2`, respectively.
71
+
If you followed the guides linked above, you should already have`kubectl`installed and both cluster contexts available in your local kubeconfig. For simplicity, rename these contexts to `site-1` and `site-2`, respectively.
72
72
73
73
1. Use `kubectl` to list your context names:
74
74
@@ -139,13 +139,13 @@ This tutorial uses Skupper v2. The commands in this section are not compatible w
139
139
```
140
140
141
141
```output
142
-
COMPONENTVERSION
143
-
router3.4.2
144
-
controller2.1.3
145
-
network-observer2.1.3
146
-
cli2.1.3
147
-
prometheusv2.42.0
148
-
origin-oauth-proxy4.14.0
142
+
COMPONENTVERSION
143
+
router3.4.2
144
+
controller2.1.3
145
+
network-observer2.1.3
146
+
cli2.1.3
147
+
prometheusv2.42.0
148
+
origin-oauth-proxy4.14.0
149
149
```
150
150
151
151
{{< note >}}
@@ -214,7 +214,7 @@ If you are using a Cloud Firewall, ensure that site-1 allows inbound TCP port `9
214
214
```output
215
215
Waiting for token status ...
216
216
217
-
Grant "site-1-a4c9d2f3-7b81-4e6a-9d2f-3c7b8e1a6f40" is ready
217
+
Grant "<grant-id>" is ready
218
218
Token file ~/site1.token created
219
219
220
220
Transfer this file to a remote site. At the remote site,
@@ -233,7 +233,7 @@ If you are using a Cloud Firewall, ensure that site-1 allows inbound TCP port `9
233
233
234
234
```output
235
235
Waiting for token status ...
236
-
Token "site-1-a4c9d2f3-7b81-4e6a-9d2f-3c7b8e1a6f40" has been redeemed
236
+
Token "<grant-id>" has been redeemed
237
237
```
238
238
239
239
1. Before deploying the MySQL replication components, verify that the Skupper link between the clusters is active:
@@ -246,7 +246,7 @@ If you are using a Cloud Firewall, ensure that site-1 allows inbound TCP port `9
246
246
247
247
```output
248
248
NAME STATUS COST MESSAGE
249
-
site-1-a4c9d2f3-7b81-4e6a-9d2f-3c7b8e1a6f40 Ready 1 OK
249
+
<grant-id> Ready 1 OK
250
250
```
251
251
252
252
## Deploy MySQL Configuration
@@ -319,7 +319,7 @@ The MySQL configuration is stored in a Kubernetes ConfigMap so that both cluster
319
319
mysql 2 25s
320
320
```
321
321
322
-
## Deploy the MySQL Services
322
+
## Deploy MySQL Services
323
323
324
324
The MySQL Service provides the stable network identity required by the StatefulSets in each cluster. The headless `mysql` Service provides predictable DNS names for each Pod so that MySQL instances can communicate directly for replication and management tasks.
325
325
@@ -382,7 +382,7 @@ The MySQL Service provides the stable network identity required by the StatefulS
382
382
383
383
At this point, both clusters have the same Service layout. The StatefulSets in the next steps use the headless `mysql` Service for stable Pod-to-Pod communication and replication traffic within each cluster.
384
384
385
-
## Deploy MySQL StatefulSet (site-1)
385
+
## Deploy site-1 MySQL StatefulSet
386
386
387
387
Deploy the MySQL StatefulSet in site-1 to create the primary MySQL cluster. In this cluster, `mysql-0` is configured as the writable primary, while`mysql-1` and `mysql-2` are configured as replica candidates. Replication is configured in a later section after the required MySQL users are created.
388
388
@@ -494,19 +494,16 @@ Deploy the MySQL StatefulSet in site-1 to create the primary MySQL cluster. In t
Before configuring replication between the clusters, create the MySQL accounts required for replication and cloning. This guide uses the account names `repl` and `cloner` throughout:
507
-
508
-
- A replication user that replicas use to read binary logs from the primary.
509
-
- A clone user used by the MySQL Clone plugin when seeding replicas.
506
+
Before configuring replication between the clusters, create the MySQL accounts required for replication and cloning. This guide uses the account names `repl` and `cloner` throughout.
510
507
511
508
These users are created on the primary database (`mysql-0`) in site-1.
512
509
@@ -592,11 +589,11 @@ These users are created on the primary database (`mysql-0`) in site-1.
592
589
repl %
593
590
```
594
591
595
-
## Configure Clone Initialization (site-2)
592
+
## Prepare Site-2 for Cloning
596
593
597
594
The site-2 Pods rely on a MySQL initialization script to install the Clone plugin and configure cloning during first startup. Because MySQL initialization scripts only run when the data directory is first created, this ConfigMap must be created before deploying the site-2 StatefulSet.
598
595
599
-
This guide also uses the fixed listener name `mysql-primary` and the fixed clone user name `cloner` throughout the remaining sections.
596
+
This guide also uses the fixed listener name `mysql-primary`.
600
597
601
598
1. Create a ConfigMap containing the site-2 initialization SQL (e.g., `mysql-site2-init-configmap.yaml`):
602
599
@@ -625,6 +622,8 @@ This guide also uses the fixed listener name `mysql-primary` and the fixed clone
625
622
FLUSH PRIVILEGES;
626
623
```
627
624
625
+
When done, save and close the file.
626
+
628
627
1. Apply the site-2 initialization ConfigMap:
629
628
630
629
```command
@@ -635,7 +634,7 @@ This guide also uses the fixed listener name `mysql-primary` and the fixed clone
635
634
configmap/mysql-site2-init created
636
635
```
637
636
638
-
## Deploy MySQL StatefulSet (site-2)
637
+
## Deploy site-2 MySQL StatefulSet
639
638
640
639
Deploy the MySQL StatefulSet in site-2 to create the secondary MySQL cluster. In this cluster, all three Pods are configured as replica candidates. Each Pod starts with its MySQL configuration and persistent storage in place, but replication is configured after the replica data is seeded (covered later). This StatefulSet mounts the initialization ConfigMap so that each Pod is fully prepared for cloning upon first startup.
641
640
@@ -748,10 +747,10 @@ Deploy the MySQL StatefulSet in site-2 to create the secondary MySQL cluster. In
1. Run the clone operation on one Pod first (mysql-0):
@@ -806,18 +805,18 @@ The MySQL Clone plugin is used to seed the site-2 Pods with data from the primar
806
805
This is expected. The clone operation replaces the data directory and triggers a restart. In this environment, Kubernetes handles that restart instead of MySQL.
807
806
{{< /note >}}
808
807
809
-
1. Check if`mysql-0` restarted and waitfor the Pod to return to the `Running` state:
808
+
1. Wait for`mysql-0` to return to the `Running` state:
@@ -852,7 +851,7 @@ The MySQL Clone plugin is used to seed the site-2 Pods with data from the primar
852
851
"
853
852
```
854
853
855
-
1. Check if`mysql-1` restarted and waitfor`mysql-1` to return to the `Running` state.
854
+
1. Waitfor`mysql-1` to return to the `Running` state.
856
855
857
856
```command
858
857
kubectl --context site-2 get pods
@@ -868,6 +867,8 @@ The MySQL Clone plugin is used to seed the site-2 Pods with data from the primar
868
867
"
869
868
```
870
869
870
+
Confirm the same values shown for`mysql-0`.
871
+
871
872
1. Run the clone operation on `mysql-2`:
872
873
873
874
```command
@@ -877,7 +878,7 @@ The MySQL Clone plugin is used to seed the site-2 Pods with data from the primar
877
878
"
878
879
```
879
880
880
-
1. Check if`mysql-2` restarted and waitfor`mysql-2` to return to the `Running` state:
881
+
1. Waitfor`mysql-2` to return to the `Running` state:
881
882
882
883
```command
883
884
kubectl --context site-2 get pods
@@ -893,6 +894,8 @@ The MySQL Clone plugin is used to seed the site-2 Pods with data from the primar
893
894
"
894
895
```
895
896
897
+
Confirm the same values shown for`mysql-0`.
898
+
896
899
Only after `mysql-0`, `mysql-1`, and `mysql-2` have each been cloned and individually verified with `performance_schema.clone_status` should you proceed to the replication section.
897
900
898
901
## Enable Cross-Site Replication
@@ -931,7 +934,7 @@ After cloning the site-2 Pods from the primary in site-1, configure each site-2
931
934
mountPath: /mnt/config-map
932
935
```
933
936
934
-
Save and close the file when done.
937
+
When done, save and close the file.
935
938
936
939
1. Apply the updated StatefulSet definition:
937
940
@@ -1050,9 +1053,9 @@ After cross-site replication is enabled, verify that each site-2 Pod is actively
1050
1053
1051
1054
```output
1052
1055
Server_Id Host Port Source_Id Replica_UUID
1053
-
202 3306 100 11da6a2e-270c-11f1-984d-5a8c68140dd6
1054
-
201 3306 100 fc258ddf-270b-11f1-8cc5-1a122ea3d965
1055
-
200 3306 100 e603a9da-270b-11f1-a0f4-76730864de28
1056
+
202 3306 100 <replica-uuid>
1057
+
201 3306 100 <replica-uuid>
1058
+
200 3306 100 <replica-uuid>
1056
1059
```
1057
1060
1058
1061
1. Create a test database and table on the primary in site-1, then insert a row:
@@ -1076,7 +1079,7 @@ After cross-site replication is enabled, verify that each site-2 Pod is actively
1076
1079
1077
1080
```output
1078
1081
id message
1079
-
1 replication works
1082
+
1 replication works
1080
1083
```
1081
1084
1082
1085
If site-1 reports all three replicas and the test row appears on site-2, cross-site replication is working successfully.
0 commit comments