创建集群后如何在 GCP 上 运行 集群初始化脚本
How to run cluster initialization script on GCP after creation of cluster
我已经创建了一个 Google Dataproc 集群,但需要安装 presto,因为我现在有一个要求。 Presto 作为 Dataproc here 上的初始化操作提供,我如何 运行 在创建集群后执行此初始化操作。
您可以使用 initialization-actions 参数
例:
gcloud dataproc clusters create $CLUSTERNAME \
--project $PROJECT \
--num-workers $WORKERS \
--bucket $BUCKET \
--master-machine-type $VMMASTER \
--worker-machine-type $VMWORKER \
--initialization-actions \
gs://dataproc-initialization-actions/presto/presto.sh \
--scopes cloud-platform
也许这个脚本可以帮助你:https://github.com/kanjih-ciandt/script-dataproc-datalab
大多数初始化操作可能会 运行 即使在集群创建之后(尽管我还没有尝试过 Presto 初始化操作)。
我想 运行 clusters describe
获取实例名称,然后 运行 每个节点的 gcloud compute ssh <NODE> -- -T sudo bash -s < presto.sh
之类的东西。参考:How to use SSH to run a shell script on a remote machine?.
备注:
--
之后的所有内容都是普通 ssh 命令的参数
-T
表示不要尝试创建交互式会话(否则您会收到类似 "Pseudo-terminal will not be allocated because stdin is not a terminal." 的警告)
- 我使用 "sudo bash" 因为 init 操作脚本假定它们是 运行 root。
- presto.sh 必须是本地计算机上脚本的副本。您也可以选择 ssh 和
gsutil cp gs://dataproc-initialization-actions/presto/presto.sh . && sudo bash presto.sh
.
但@Kanji Hara 总的来说是正确的。启动一个新的集群很漂亮 fast/painless,所以我们提倡在创建集群时使用初始化操作。
我已经创建了一个 Google Dataproc 集群,但需要安装 presto,因为我现在有一个要求。 Presto 作为 Dataproc here 上的初始化操作提供,我如何 运行 在创建集群后执行此初始化操作。
您可以使用 initialization-actions 参数
例:
gcloud dataproc clusters create $CLUSTERNAME \
--project $PROJECT \
--num-workers $WORKERS \
--bucket $BUCKET \
--master-machine-type $VMMASTER \
--worker-machine-type $VMWORKER \
--initialization-actions \
gs://dataproc-initialization-actions/presto/presto.sh \
--scopes cloud-platform
也许这个脚本可以帮助你:https://github.com/kanjih-ciandt/script-dataproc-datalab
大多数初始化操作可能会 运行 即使在集群创建之后(尽管我还没有尝试过 Presto 初始化操作)。
我想 运行 clusters describe
获取实例名称,然后 运行 每个节点的 gcloud compute ssh <NODE> -- -T sudo bash -s < presto.sh
之类的东西。参考:How to use SSH to run a shell script on a remote machine?.
备注:
--
之后的所有内容都是普通 ssh 命令的参数-T
表示不要尝试创建交互式会话(否则您会收到类似 "Pseudo-terminal will not be allocated because stdin is not a terminal." 的警告)- 我使用 "sudo bash" 因为 init 操作脚本假定它们是 运行 root。
- presto.sh 必须是本地计算机上脚本的副本。您也可以选择 ssh 和
gsutil cp gs://dataproc-initialization-actions/presto/presto.sh . && sudo bash presto.sh
.
但@Kanji Hara 总的来说是正确的。启动一个新的集群很漂亮 fast/painless,所以我们提倡在创建集群时使用初始化操作。