|
1 | | -# Quickstart for NFS backup |
2 | | -## Install NFS server |
| 1 | +English | [简体中文](../zh-cn/deploy_backup_restore_nfs.md) |
3 | 2 |
|
4 | | -### 1. Prepare Storage |
| 3 | +# Quickstart for NFS backups |
5 | 4 |
|
6 | | -Create the NFS PV and SC. |
| 5 | +## Contents |
7 | 6 |
|
8 | | -``` |
9 | | -kubectl apply -f config/samples/nfs_pv.yaml |
10 | | -``` |
| 7 | +* [Install NFS server and resources](#install-nfs-server-and-resources) |
| 8 | + * [1. Install by Helm](#1-install-by-helm) |
| 9 | + * [2. Install by kubectl](#2-install-by-kubectl) |
| 10 | +* [Obtain `nfsServerAddress`](#obtain-nfsserveraddress) |
| 11 | +* [Create an NFS backup](#create-an-nfs-backup) |
| 12 | + * [1. Configure the NFS server address](#1-configure-the-nfs-server-address) |
| 13 | + * [2. Create a backup](#2-create-a-backup) |
| 14 | + * [3. Verify the backup](#3-verify-the-backup) |
| 15 | +* [Restore the cluster from the NFS backup](#restore-the-cluster-from-the-nfs-backup) |
11 | 16 |
|
12 | | -> You can specify the PVC you created by modifying the `persistentVolumeClaim.claimName` in the `config/samples/nfs_server.yaml`. |
13 | | -
|
14 | | -### 2. Create nfs server |
15 | | - |
16 | | -Create ReplicationController and Service. |
| 17 | +## Install NFS server and resources |
17 | 18 |
|
| 19 | +### 1. Install by Helm |
| 20 | +```shell |
| 21 | +helm install demo charts/mysql-operator --set nfsBackup.installServer=true --set nfsBackup.volume.createLocalPV=true |
18 | 22 | ``` |
19 | | -kubectl apply -f config/samples/nfs_server.yaml |
| 23 | +Or manually create the PVC and run: |
| 24 | +```shell |
| 25 | +helm install demo charts/mysql-operator --set nfsBackup.installServer=true --set nfsBackup.volume.specifiedPVC=XXXX |
20 | 26 | ``` |
| 27 | +> `XXX` stands for the PVC name. |
21 | 28 |
|
22 | | -Get `NFSServerAddress`. |
| 29 | +In this way, you can install the Pod and Service of the NFS server in the cluster while installing the operator. |
23 | 30 |
|
| 31 | +### 2. Install by kubectl |
| 32 | +```shell |
| 33 | +kubectl apply -f config/samples/nfs_pv.yaml |
| 34 | + kubectl apply -f config/samples/nfs_server.yaml |
24 | 35 | ``` |
25 | | -# example |
| 36 | + |
| 37 | +## Obtain `nfsServerAddress` |
| 38 | +For example: |
| 39 | +```shell |
| 40 | + |
26 | 41 | kubectl get svc nfs-server --template={{.spec.clusterIP}} |
27 | 42 | 10.96.253.82 |
28 | 43 | ``` |
| 44 | +You can use `ClusterIp` to perform NFS backup. The cluster IP address in the example is `10.96.253.82`. |
29 | 45 |
|
30 | | -## Create a NFS backup |
31 | | - |
32 | | -### 1. Configure address of NFS Server. |
| 46 | +## Create an NFS backup |
| 47 | +### 1. Configure the NFS server address |
33 | 48 |
|
34 | 49 | ```yaml |
35 | 50 | # config/samples/mysql_v1alpha1_backup.yaml |
36 | 51 | nfsServerAddress: "10.96.253.82" |
37 | 52 | ``` |
38 | 53 |
|
39 | 54 | ### 2. Create a backup |
40 | | -
|
41 | 55 | ```shell |
42 | 56 | kubectl apply -f config/samples/mysql_v1alpha1_backup.yaml |
43 | 57 | ``` |
| 58 | +> Note: The backup CRD and MySQL cluster CRD must be in the same namespace. |
44 | 59 |
|
45 | | -> Notice: backup cr and mysqlcluster cr must be in the same namespace. |
46 | | -### 3. Verify your backup |
47 | | - |
48 | | -You can find the backup folder called `<cluster name>_<timestamp>`. |
| 60 | +### 3. Verify the backup |
| 61 | +View the backup directory `<cluster name>_<timestamp>` as follows. |
49 | 62 |
|
50 | 63 | ``` |
51 | 64 | kubectl exec -it <pod name of nfs server> -- ls /exports |
52 | 65 | index.html initbackup sample_2022419101946 |
53 | 66 | ``` |
54 | 67 |
|
55 | | - ## Restore cluster from exist NFS backup |
| 68 | + ## Restore the cluster from the NFS backup |
56 | 69 |
|
57 | | -Configure the `mysql_v1alpha1_cluster.yaml`, uncomment the `nfsServerAddress` field and fill in your own configuration. |
| 70 | +Configure the `nfsServerAddress` attribute to the NFS server address in the `mysql_v1alpha1_cluster.yaml` file. |
58 | 71 |
|
59 | 72 | ```yaml |
60 | 73 | ... |
61 | 74 | restoreFrom: "sample_2022419101946" |
62 | 75 | nfsServerAddress: 10.96.253.82 |
63 | 76 | ``` |
64 | 77 | |
65 | | - > Notice: restoreFrom is the folder name of a backup. You can find it on the path mounted in NFS Server. |
| 78 | + > Notice: `restoreFrom` stands for the pathname of the backup. You can get it by checking the path loaded by the NFS server. |
66 | 79 |
|
67 | | - Create cluster from NFS server backup copy: |
| 80 | +Restore cluster from NFS backup as follows. |
68 | 81 |
|
69 | 82 | ``` |
70 | 83 | kubectl apply -f config/samples/mysql_v1alpha1_cluster.yaml |
71 | | - ``` |
72 | | - |
73 | | - ## Build your own image |
74 | | - |
75 | | - ``` |
76 | | - docker build -f Dockerfile.sidecar -t acekingke/sidecar:0.1 . && docker push acekingke/sidecar:0.1 |
77 | | - docker build -t acekingke/controller:0.1 . && docker push acekingke/controller:0.1 |
78 | | - ``` |
79 | | -> You can replace acekingke/sidecar:0.1 with your own tag |
80 | | -
|
81 | | - ## Deploy your own manager |
82 | | -```shell |
83 | | -make manifests |
84 | | -make install |
85 | | -make deploy IMG=acekingke/controller:0.1 KUSTOMIZE=~/radondb-mysql-kubernetes/bin/kustomize |
86 | | -``` |
| 84 | + ``` |
0 commit comments