-
Notifications
You must be signed in to change notification settings - Fork 0
/
google-cloud-datalab-on-a-cloud-dataproc-cluster.html
411 lines (366 loc) · 16.8 KB
/
google-cloud-datalab-on-a-cloud-dataproc-cluster.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns# fb: https://www.facebook.com/2008/fbml">
<head>
<title>Google Cloud Datalab on a Cloud Dataproc cluster - Justin Naldzin</title>
<!-- Using the latest rendering mode for IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="./google-cloud-datalab-on-a-cloud-dataproc-cluster.html">
<meta name="author" content="Justin Naldzin" />
<meta name="keywords" content="google cloud,dataproc,datalab,pyspark,apache spark" />
<meta name="description" content="This guide shows how to use an initialization action to install Cloud Datalab on a Cloud Dataproc cluster." />
<meta property="og:site_name" content="Justin Naldzin" />
<meta property="og:type" content="article"/>
<meta property="og:title" content="Google Cloud Datalab on a Cloud Dataproc cluster"/>
<meta property="og:url" content="./google-cloud-datalab-on-a-cloud-dataproc-cluster.html"/>
<meta property="og:description" content="This guide shows how to use an initialization action to install Cloud Datalab on a Cloud Dataproc cluster."/>
<meta property="article:published_time" content="2018-03-30" />
<meta property="article:section" content="guides" />
<meta property="article:tag" content="google cloud" />
<meta property="article:tag" content="dataproc" />
<meta property="article:tag" content="datalab" />
<meta property="article:tag" content="pyspark" />
<meta property="article:tag" content="apache spark" />
<meta property="article:author" content="Justin Naldzin" />
<!-- Bootstrap -->
<link rel="stylesheet" href="./theme/css/bootstrap.paper.min.css" type="text/css"/>
<link href="./theme/css/font-awesome.min.css" rel="stylesheet">
<link href="./theme/css/pygments/emacs.css" rel="stylesheet">
<link rel="stylesheet" href="./theme/css/style.css" type="text/css"/>
<link href="./feeds/all.atom.xml" type="application/atom+xml" rel="alternate"
title="Justin Naldzin ATOM Feed"/>
<link href="./feeds/guides.atom.xml" type="application/atom+xml" rel="alternate"
title="Justin Naldzin guides ATOM Feed"/>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="./" class="navbar-brand">
Justin Naldzin </a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li >
<a href="./category/about.html">About</a>
</li>
<li >
<a href="./category/github-repos.html">Github repos</a>
</li>
<li class="active">
<a href="./category/guides.html">Guides</a>
</li>
<li >
<a href="./category/internet-of-things.html">Internet of things</a>
</li>
<li >
<a href="./category/notebooks.html">Notebooks</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
</div> <!-- /.navbar -->
<!-- Banner -->
<!-- End Banner -->
<!-- Content Container -->
<div class="container">
<div class="row">
<div class="col-sm-9">
<section id="content">
<article>
<header class="page-header">
<h1>
<a href="./google-cloud-datalab-on-a-cloud-dataproc-cluster.html"
rel="bookmark"
title="Permalink to Google Cloud Datalab on a Cloud Dataproc cluster">
Google Cloud Datalab on a Cloud Dataproc cluster
</a>
</h1>
</header>
<div class="entry-content">
<div class="panel">
<div class="panel-body">
<footer class="post-info">
<span class="label label-default">Date</span>
<span class="published">
<i class="fa fa-calendar"></i><time datetime="2018-03-30T00:00:00-04:00"> Fri 30 March 2018</time>
</span>
<span class="label label-default">Tags</span>
<a href="./tag/google-cloud.html">google cloud</a>
/
<a href="./tag/dataproc.html">dataproc</a>
/
<a href="./tag/datalab.html">datalab</a>
/
<a href="./tag/pyspark.html">pyspark</a>
/
<a href="./tag/apache-spark.html">apache spark</a>
</footer><!-- /.post-info --> </div>
</div>
<h1>Overview</h1>
<p>This guide shows how to use an initialization action to install Cloud Datalab on a Cloud Dataproc cluster.</p>
<p align="center">
<img src="images/logos/card_gcp_clouddatalab.png" alt="Cloud Datalab" hspace="20" vspace="20" valign="middle">
<img src="images/logos/card_gcp_clouddataproc.png" alt="Cloud Dataproc" hspace="20" vspace="20" valign="middle">
<img src="images/logos/spark.png" alt="Apache Spark" hspace="20" vspace="20" valign="middle">
</p>
<h2>Create a Cloud Storage bucket</h2>
<blockquote>
<p>NOTE: The Dataproc staging bucket is NOT used to store Datalab notebooks.</p>
</blockquote>
<div class="highlight"><pre><span></span><span class="nv">PROJECT_NAME</span><span class="o">=</span>my-project-name
<span class="nv">STORAGE_CLASS</span><span class="o">=</span>regional
<span class="nv">BUCKET_LOCATION</span><span class="o">=</span>us-east1
<span class="nv">CLUSTER_NAME</span><span class="o">=</span>dataproc-spark-cluster-1
<span class="nv">BUCKET_NAME</span><span class="o">=</span><span class="si">${</span><span class="nv">CLUSTER_NAME</span><span class="si">}</span>-<span class="si">${</span><span class="nv">BUCKET_LOCATION</span><span class="si">}</span>
gsutil mb -p <span class="nv">$PROJECT_NAME</span> -c <span class="nv">$STORAGE_CLASS</span> -l <span class="nv">$BUCKET_LOCATION</span> gs://<span class="nv">$BUCKET_NAME</span>/
</pre></div>
<h2>Create Dataproc cluster with Datalab initialization action</h2>
<div class="highlight"><pre><span></span><span class="nv">PROJECT_ID</span><span class="o">=</span>my-project-id
<span class="nv">REGION</span><span class="o">=</span><span class="nv">$BUCKET_LOCATION</span>
<span class="nv">ZONE</span><span class="o">=</span><span class="si">${</span><span class="nv">REGION</span><span class="si">}</span>-d
gcloud dataproc clusters create <span class="nv">$CLUSTER_NAME</span> --project <span class="nv">$PROJECT_ID</span> --bucket <span class="nv">$BUCKET_NAME</span> --region <span class="nv">$REGION</span> --zone <span class="nv">$ZONE</span> --initialization-actions gs://dataproc-initialization-actions/datalab/datalab.sh
</pre></div>
<h2>Dynamic Port Forwarding</h2>
<p>To avoid opening a publicly reachable port on the cluster's master node, use dynamic port forwarding (via an SSH tunnel using the SOCKS protocol) to connect your browser to the Datalab notebook running on your cluster's master node.</p>
<h2>Setup SSH tunnel</h2>
<p>Create an SSH tunnel to your cluster's master node from port 10000 on your localhost machine</p>
<div class="highlight"><pre><span></span><span class="nv">MASTER_HOST_NAME</span><span class="o">=</span><span class="si">${</span><span class="nv">CLUSTER_NAME</span><span class="si">}</span>-m
<span class="nv">PORT</span><span class="o">=</span><span class="m">10000</span>
gcloud compute ssh <span class="nv">$MASTER_HOST_NAME</span> --project <span class="nv">$PROJECT_ID</span> --zone<span class="o">=</span><span class="nv">$ZONE</span> -- -D <span class="nv">$PORT</span> -N
</pre></div>
<h2>Open Datalab in your browser</h2>
<p>Launch a new browser that connects through the SSH tunnel (using the SOCKS protocol) to the Datalab application running on your cluster's master node.</p>
<div class="highlight"><pre><span></span>/Applications/Google<span class="se">\ </span>Chrome.app/Contents/MacOS/Google<span class="se">\ </span>Chrome <span class="s2">"http://</span><span class="nv">$MASTER_HOST_NAME</span><span class="s2">:8080"</span> --proxy-server<span class="o">=</span><span class="s2">"socks5://localhost:</span><span class="nv">$PORT</span><span class="s2">"</span> --host-resolver-rules<span class="o">=</span><span class="s2">"MAP * 0.0.0.0 , EXCLUDE localhost"</span> --user-data-dir<span class="o">=</span>/tmp/
</pre></div>
<p>Creating a new notebook with the Python3 kernel has the <code>SparkContext</code> available as <code>sc</code></p>
<h2>Dataproc Web Interfaces</h2>
<ul>
<li>Yarn Resource Manager: http://master-host-name:8088</li>
<li>HDFS NameNode: http://master-host-name:9870</li>
<li>Spark Master UI: http://master-host-name:4040</li>
<li>Spark History Server: http://master-host-name:18080</li>
<li>Hadoop Job History Server: http://master-host-name:19888</li>
</ul>
</div>
<!-- /.entry-content -->
</article>
</section>
</div>
<div class="col-sm-3" id="sidebar">
<aside>
<!-- Sidebar -->
<section class="well well-sm">
<ul class="list-group list-group-flush">
<!-- Sidebar/Social -->
<li class="list-group-item">
<h4><i class="fa fa-home fa-lg"></i><span class="icon-label">Social</span></h4>
<ul class="list-group" id="social">
<li class="list-group-item"><a href="https://www.linkedin.com/in/justinnaldzin"><i class="fa fa-linkedin-square fa-lg"></i> LinkedIn</a></li>
<li class="list-group-item"><a href="https://www.github.com/justinnaldzin"><i class="fa fa-github-square fa-lg"></i> GitHub</a></li>
<li class="list-group-item"><a href="https://www.youtube.com/justinnaldzin"><i class="fa fa-youtube-square fa-lg"></i> YouTube</a></li>
<li class="list-group-item"><a href="https://www.facebook.com/justinnaldzin"><i class="fa fa-facebook-square fa-lg"></i> Facebook</a></li>
<li class="list-group-item"><a href="https://www.twitter.com/justinnaldzin"><i class="fa fa-twitter-square fa-lg"></i> Twitter</a></li>
</ul>
</li>
<!-- End Sidebar/Social -->
<!-- Sidebar/Tag Cloud -->
<li class="list-group-item">
<a href="./"><h4><i class="fa fa-tags fa-lg"></i><span class="icon-label">Tags</span></h4></a>
<ul class="list-group list-inline tagcloud" id="tags">
<li class="list-group-item tag-3">
<a href="./tag/about.html">about</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/apache.html">apache</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/apache-spark.html">apache spark</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/aws.html">aws</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/benchmarking.html">benchmarking</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/big-data.html">big data</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/bokeh.html">bokeh</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/change-data-capture.html">change data capture</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/cloud-sql.html">cloud sql</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/container-registry.html">container registry</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/datalab.html">datalab</a>
</li>
<li class="list-group-item tag-2">
<a href="./tag/dataproc.html">dataproc</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/debezium.html">debezium</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/docker.html">docker</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/gcloud.html">gcloud</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/github.html">github</a>
</li>
<li class="list-group-item tag-1">
<a href="./tag/google-cloud.html">google cloud</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/google-cloud-platform.html">google cloud platform</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/hadoop.html">hadoop</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/hana.html">hana</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/hdfs.html">hdfs</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/hive.html">hive</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/information-technology.html">information technology</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/iot.html">iot</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/java.html">java</a>
</li>
<li class="list-group-item tag-1">
<a href="./tag/jupyter.html">jupyter</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/kafka.html">kafka</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/kubectl.html">kubectl</a>
</li>
<li class="list-group-item tag-2">
<a href="./tag/kubernetes.html">kubernetes</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/magic-mirror.html">magic-mirror</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/matplotlib.html">matplotlib</a>
</li>
<li class="list-group-item tag-2">
<a href="./tag/minikube.html">minikube</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/mysql.html">mysql</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/oracle.html">oracle</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/pelican.html">pelican</a>
</li>
<li class="list-group-item tag-2">
<a href="./tag/pyspark.html">pyspark</a>
</li>
<li class="list-group-item tag-1">
<a href="./tag/python.html">python</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/rds.html">rds</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/scala.html">scala</a>
</li>
<li class="list-group-item tag-1">
<a href="./tag/spark.html">spark</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/sql-server.html">sql server</a>
</li>
<li class="list-group-item tag-3">
<a href="./tag/sqoop.html">sqoop</a>
</li>
<li class="list-group-item tag-4">
<a href="./tag/vagrant.html">vagrant</a>
</li>
</ul>
</li>
<!-- End Sidebar/Tag Cloud -->
<!-- Sidebar/Github -->
<li class="list-group-item">
<h4><i class="fa fa-github fa-lg"></i><span class="icon-label">GitHub Repos</span></h4>
<div id="gh_repos">
<p class="list-group-item">Status updating...</p>
</div>
</li>
<!-- End Sidebar/Github -->
</ul>
</section>
<!-- End Sidebar --> </aside>
</div>
</div>
</div>
<!-- End Content Container -->
<footer>
<div class="container">
<hr>
<div class="row">
<div class="col-xs-10">© 2018 Justin Naldzin
· Powered by <a href="https://github.com/getpelican/pelican-themes/tree/master/pelican-bootstrap3" target="_blank">pelican-bootstrap3</a>,
<a href="http://docs.getpelican.com/" target="_blank">Pelican</a>,
<a href="http://getbootstrap.com" target="_blank">Bootstrap</a> </div>
<div class="col-xs-2"><p class="pull-right"><i class="fa fa-arrow-up"></i> <a href="#">Back to top</a></p></div>
</div>
</div>
</footer>
<script src="./theme/js/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="./theme/js/bootstrap.min.js"></script>
<!-- Enable responsive features in IE8 with Respond.js (https://github.com/scottjehl/Respond) -->
<script src="./theme/js/respond.min.js"></script>
<!-- GitHub JS Code -->
<script type="text/javascript">
$(document).ready(function () {
if (!window.jXHR) {
var jxhr = document.createElement('script');
jxhr.type = 'text/javascript';
jxhr.src = './theme/js/jXHR.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(jxhr, s);
}
github.showRepos({
user: 'justinnaldzin',
count: 5,
skip_forks: false,
target: '#gh_repos'
});
});
</script>
<script src="./theme/js/github.js" type="text/javascript"></script>
<!-- End GitHub JS Code -->
</body>
</html>