Membuat ulang dan mengupdate cluster
Anda dapat menggunakan alat command line gcloud atau Managed Service untuk Apache Spark API untuk menyalin konfigurasi dari cluster yang ada, mengupdate konfigurasi yang disalin, lalu membuat cluster baru dengan konfigurasi yang diupdate.
gcloud CLI
Petunjuk contoh menunjukkan cara mengupdate setelan versi image dalam konfigurasi cluster. Anda dapat mengubah contoh untuk mengupdate setelan konfigurasi cluster yang berbeda.
- Tetapkan variabel.
export PROJECT=project-id export REGION=region export OLD_CLUSTER=old-cluster-name export NEW_CLUSTER=new-cluster-name export NEW_IMAGE_VERSION=image-version (for example, '2.2-debian12')
- Ekspor konfigurasi cluster yang ada (lama) ke file YAML.
gcloud dataproc clusters export $OLD_CLUSTER \ --project=$PROJECT \ --region=$REGION > "${OLD_CLUSTER}-config.yaml" - Update konfigurasi. Contoh berikut menggunakan
seduntuk mengupdate versi image.sed -E "s|(^[[:blank:]]+)imageVersion: .+|\1imageVersion: ${NEW_IMAGE_VERSION}|g" "${OLD_CLUSTER}-config.yaml" | sed -E '/^[[:blank:]]+imageUri: /d' > "${NEW_CLUSTER}-config-updated.yaml" - Buat cluster baru dengan nama baru dan konfigurasi yang diupdate.
gcloud dataproc clusters import $NEW_CLUSTER \ --project=$PROJECT \ --region=$REGION \ --source="${NEW_CLUSTER}-config-updated.yaml" - Setelah mengonfirmasi bahwa workload Anda berjalan di cluster baru tanpa masalah, hapus cluster yang ada (lama). PENTING: Langkah ini akan menghapus semua data yang disimpan di HDFS dan di disk lokal di cluster Anda.
gcloud dataproc clusters delete $OLD_CLUSTER \ --project=$PROJECT \ --region=$REGION
REST API
Petunjuk contoh menunjukkan cara mengupdate nama cluster dan setelan versi image dalam konfigurasi cluster. Anda dapat mengubah variabel contoh untuk mengupdate setelan konfigurasi cluster yang berbeda.
- Tetapkan variabel.
export PROJECT=project-id export REGION=region export OLD_CLUSTER=old-cluster-name export NEW_CLUSTER=new-cluster-name export NEW_IMAGE_VERSION=image-version (for example, '2.2-debian12')
- Ekspor konfigurasi cluster yang ada (lama) ke file JSON.
curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://dataproc.googleapis.com/v1/projects/${PROJECT}/regions/${REGION}/clusters/${OLD_CLUSTER}?alt=json" > "${OLD_CLUSTER}-config.json" - Update konfigurasi. Contoh berikut menggunakan
jquntuk mengupdate nama cluster dan versi image.jq ".clusterName = \"${NEW_CLUSTER}\" | .config.softwareConfig.imageVersion=\"${NEW_IMAGE_VERSION}\" | del(.config.workerConfig.imageUri) | del(.config.masterConfig.imageUri)" "${OLD_CLUSTER}-config.json" > "${NEW_CLUSTER}-config-updated.json" - Impor konfigurasi cluster yang diupdate untuk membuat cluster baru dengan konfigurasi yang diupdate.
curl -i -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json; charset=utf-8" -d "@${NEW_CLUSTER}-config-updated.json" "https://dataproc.googleapis.com/v1/projects/${PROJECT}/regions/${REGION}/clusters?alt=json" - Setelah mengonfirmasi bahwa workload Anda berjalan di cluster baru tanpa masalah, hapus cluster yang ada (lama). PENTING: Langkah ini akan menghapus semua data yang disimpan di HDFS dan di disk lokal di cluster Anda.
curl -X DELETE -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://dataproc.googleapis.com/v1/projects/${PROJECT}/regions/${REGION}/clusters/${OLD_CLUSTER}"
Konsol
Konsol tidak mendukung pembuatan ulang cluster dengan mengimpor konfigurasi cluster.