使用 Dataproc 中心
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
目标
使用 Dataproc Hub 创建在 Dataproc 集群上运行的单用户 JupyterLab 笔记本环境。
在 Dataproc 集群上创建笔记本并运行 Spark 作业。
删除集群并在 Cloud Storage 中保留您的笔记本。
从 Dataproc 中心创建 Dataproc JupyterLab 集群
在 Google Cloud 控制台的 Dataproc→Workbench 页面上选择用户管理的笔记本标签页。
在管理员创建的 Dataproc Hub 实例所在行中,点击打开 JupyterLab。
- 如果您无权访问 Google Cloud 控制台,请输入管理员在网络浏览器中与您共享的 Dataproc Hub 实例网址。
在 Jupyterhub→Dataproc 选项页面上,选择集群配置和可用区。如果启用,请指定任何自定义设置,然后点击创建。
创建 Dataproc 集群后,系统会将您重定向到该集群上运行的 JupyterLab 接口。
创建笔记本并运行 Spark 作业
在 JupyterLab 界面的左侧面板中,点击 GCS
(Cloud Storage)。
通过 JupyterLab 启动器创建 PySpark 笔记本。
PySpark 内核会初始化 SparkContext(使用 sc
变量)。您可以从笔记本中检查 SparkContext 并运行 Spark 作业。
rdd = (sc.parallelize(['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'lorem'])
.map(lambda word: (word, 1))
.reduceByKey(lambda a, b: a + b))
print(rdd.collect())
为笔记本命名并保存。在删除 Dataproc 集群后,笔记本将保存并保留在 Cloud Storage 中。
关停 Dataproc 集群
在 JupyterLab 界面中,选择文件→中心控制台以打开 Jupyterhub 页面。
点击停止我的集群以关闭(删除)JupyterLab 服务器,这会删除 Dataproc 集群。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-03-25。
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]