Il prodotto descritto in questa documentazione, Anthos Clusters on AWS (generazione precedente), è ora in modalità di manutenzione. Tutte le nuove installazioni devono utilizzare l'attuale prodotto di generazione, Cluster Anthos on AWS.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina mostra come eseguire il backup del datastore etcd per l'installazione GKE su AWS per il recupero da eventi che potrebbero danneggiare i dati etcd del cluster.
Limitazioni
L'utilizzo di un file di backup per ripristinare i dati etcd è l'ultima risorsa. Non consigliamo di eseguire il ripristino da un file di backup, a meno che il cluster non sia completamente danneggiato. Contatta l'Assistenza Google per decidere la strategia migliore.
Questa procedura non esegue il backup dei dati dei carichi di lavoro, inclusi i volumi permanenti.
Questo backup non può essere utilizzato per ripristinare un cluster da una versione diversa di GKE su AWS.
Eseguire il backup di un cluster utente
Un backup del cluster utente è uno snapshot dello spazio dati etcd del cluster utente.
Lo spazio dati etcd contiene tutti gli oggetti Kubernetes e personalizzati
che rappresentano lo stato del cluster. Lo snapshot contiene i
dati necessari per ricreare i carichi di lavoro senza stato del cluster.
Per creare uno snapshot del datastore etcd, svolgi i seguenti passaggi:
Apri una shell nell'istanza del servizio di gestione che esegue etcd per il cluster.
Trova l'indirizzo IP dell'istanza del servizio di gestione del cluster.
Crea una directory per archiviare i dati di backup di etcd.
mkdir ./etcd-backups
Utilizza lo strumento a riga di comando ps per trovare l'ID processo del processo etcd sull'istanza.
ps -e | grep etcd
L'output mostra i dettagli del processo etcd. Il primo elemento è l'ID processo di etcd. Nei passaggi che seguono, sostituisci ETCD_PID con questo ID processo.
Crea uno script all'interno del file system del contenitore etcd per acquisire uno snapshot.
Questo script esegue etcdctl per connettersi al daemon etcd ed eseguire uno snapshot per eseguire il backup del database etcd.
cat << EOT > /tmp/etcdbackup.sh
# Extract a snapshot of the anthos-gke etcd state database
export ETCDCTL_API=3
etcdctl \
--endpoints=https://127.0.0.1:2379 \
--cacert=/secrets/server-ca.crt \
--cert=/secrets/server.crt \
--key=/secrets/server.key \
snapshot save /tmp/snapshot.db
EOT
chmod a+x /tmp/etcdbackup.sh
sudo mv /tmp/etcdbackup.sh /proc/ETCD_PID/root/tmp/etcdbackup.sh
Utilizza il comando nsenter per eseguire lo script all'interno del contenitore etcd per creare lo snapshot.
Copia tutti i file nella directory /secrets del contenitore etcd nella directory di backup. Questi file contengono i certificati che criptano e convalidano la comunicazione tra etcd e altri processi nel cluster. Insieme, il file dello snapshot e i file dei certificati costituiscono un backup completo dello stato del cluster etcd.
Utilizza lo strumento tar per raggruppare i file etc-backup in un pratico file tar.
tar -cvf etcd-backup.tar etcd-backup
Esci sulla tua macchina locale e utilizza lo strumento scp per copiare il file etcd-backup.tar dall'istanza del servizio di gestione. Questo esempio utilizza le variabili di ambiente BASTION_DNS e MANAGEMENT_IP definite in precedenza.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-31 UTC."],[],[],null,["# Backing up user clusters on AWS\n\nThis page shows how to back up the etcd data store for your\nGKE on AWS installation for recovery from events that may\ndamage your cluster's etcd data.\n\nLimitations\n-----------\n\n- Using a backup file to restore your etcd data is a last resort. We do\n not recommend restoring from a backup file unless the cluster is completely\n broken. Contact Google support for help in deciding the best course of action.\n\n- This procedure does not back up data from your workloads, including\n PersistentVolumes.\n\n- This backup cannot be used to restore a cluster from a different version of\n GKE on AWS.\n\nBacking up a user cluster\n-------------------------\n\nA user cluster backup is a snapshot of the user cluster's etcd store.\nThe etcd store contains all of the Kubernetes objects and custom objects\nthat represent the cluster's state. The snapshot contains the\ndata required to recreate the cluster's stateless workloads.\n\nTo create a snapshot of the etcd data store, perform the following steps:\n\n1. Open a shell on the management service instance running etcd for your cluster.\n\n 1. Find the IP address of your cluster's management service instance.\n\n export CLUSTER_ID=$(terraform output cluster_id)\n export MANAGEMENT_IP=$(aws ec2 describe-instances \\\n --filters \"Name=tag:Name,Values=$CLUSTER_ID-management-0\" \\\n --query \"Reservations[*].Instances[*].PrivateIpAddress\" \\\n --output text)\n\n 2. Use the `ssh` tool to open a connection to the management service instance.\n\n ### Direct connection\n\n ssh -i ~/.ssh/anthos-gke ubuntu@$MANAGEMENT_IP\n\n ### Bastion host\n\n export BASTION_DNS=$(terraform output bastion_dns_name)\n ssh -i ~/.ssh/anthos-gke -J ubuntu@$BASTION_DNS ubuntu@$MANAGEMENT_IP\n\n | **Note:** If the \\`ssh\\` command fails with a public key permission error, you might need to refresh your ssh authentication key with the following command: \n |\n | ```\n | ssh-add -k ~/.ssh/anthos-gke\n | ```\n | Replace \u003cvar translate=\"no\"\u003eanthos-gke\u003c/var\u003e with the name of the file containing your authentication key.\n2. Create a directory to store the etcd backup data.\n\n ```\n mkdir ./etcd-backups\n ```\n3. Use the `ps` command-line tool to find the process ID of the etcd\n process on that instance.\n\n ```\n ps -e | grep etcd\n ```\n\n The output shows details of your etcd process. The first element is etcd's\n process ID. In the following steps, replace \u003cvar translate=\"no\"\u003eETCD_PID\u003c/var\u003e with this\n process ID.\n4. Create a script within the etcd container's filesystem to take a snapshot.\n This script runs etcdctl to connect to the etcd daemon and perform a snapshot to\n back up the etcd database.\n\n ```\n cat \u003c\u003c EOT \u003e /tmp/etcdbackup.sh\n # Extract a snapshot of the anthos-gke etcd state database\n\n export ETCDCTL_API=3\n\n etcdctl \\\n --endpoints=https://127.0.0.1:2379 \\\n --cacert=/secrets/server-ca.crt \\\n --cert=/secrets/server.crt \\\n --key=/secrets/server.key \\\n snapshot save /tmp/snapshot.db\n EOT\n\n chmod a+x /tmp/etcdbackup.sh\n sudo mv /tmp/etcdbackup.sh /proc/ETCD_PID/root/tmp/etcdbackup.sh\n ```\n5. Use the `nsenter` command to run the script within the etcd container to\n create the snapshot.\n\n ```\n sudo nsenter --all --target ETCD_PID /tmp/etcdbackup.sh\n ```\n6. Copy the snapshot file out of the etcd container.\n\n ```\n sudo cp /proc/ETCD_PID/root/tmp/snapshot.db ./etcd-backups\n ```\n7. Copy all files in the /secrets directory of the etcd container to your\n backup directory. These files contain the certificates that encrypt and validate\n communication between etcd and other processes in the cluster. Together, the\n snapshot file and the certificates files are a full backup of your\n etcd cluster status.\n\n ```\n sudo cp -r /proc/ETCD_PID/root/secrets ./etcd-backups\n ```\n8. Use the `tar` tool to bundle the etc-backup files into a convenient tar file.\n\n ```\n tar -cvf etcd-backup.tar etcd-backup\n ```\n9. Exit to your local machine and use the `scp` tool to copy the\n etcd-backup.tar file from the management service instance. This example uses\n the BASTION_DNS and MANAGEMENT_IP environment variables defined earlier.\n\n ```\n scp -i ~/.ssh/anthos-gke -J ubuntu@$BASTION_DNS \\\n ubuntu@$MANAGEMENT_IP:~/etcd-backup/backup.tar\n ```\n\n### For More Information\n\n- [scp man page](http://manpages.org/scp)\n- [etcdctl man page](http://manpages.org/etcdctl)\n- [tar man page](http://manpages.org/tar)"]]