啟動您的Datalab
Datalab為Google在大資料家族中針對連結各資料來源 進行互動,進一步對資料進行檢視、分析、視覺化呈現的工具,更進一步可以搭配Machine Learning進行更進一步的運算。
- 安裝gcloud工具
- 認證gcloud工具
- 設定ADC(Application Default Certification)
- 設定預設的zone與project id
收先,需要先行安裝gcloud component中的datalab的元件,可以透過下面指令來安裝:
gcloud components install datalab
安裝完成後,可以直接在gcloud的環境中直接使用datalab create來建置,如下:
$ datalab create simonlab
Creating the instance simonlab
Created [https://www.googleapis.com/compute/v1/projects/mitac-simonsu-2017/zones/asia-east1-c/instances/simonlab].
Connecting to simonlab.
This will create an SSH tunnel and may prompt you to create an rsa key pair.
Waiting for Datalab to be reachable at http://localhost:8081/
The connection to Datalab is now open and will remain until this command is killed.
You can connect to Datalab at http://localhost:8081/
建立過程會需要一些時間... 當一切建立無誤,則系統會搭配reverse proxy將雲端上的8081 port服務串連回本機,讓您可以使用 http://localhost:8081/ 來連線datalab服務。
在建立好後,我們也可以透過list顯示專案中目前有多少的datalab主機可以使用:
$ datalab list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
simonlab asia-east1-c n1-standard-1 10.140.0.2 123.123.123.123 RUNNING
下面是實際連線上的狀態:

我們可以透過/datalab/dosc/turtorials來找到許多與GCP Data Source連線的範例,下面是一個BigQuery連線的畫面..

我們可以開啟其中一個範例後,點選其中的一個查詢範例,然後點選最上方的執行按鈕,系統就會開始執行連接BigQuery的查詢動作...

接下來,執行結果會顯示在該段SQL下面...

最後完成測試後,可以透過點選右上方人頭後出現的"Stop VM"的按鈕,將Datalab停止。

Stop後的VM在GCE的介面中是以"Stopped"的狀態呈現,如果需要再次把它打開,可以試試從GCE介面中將該主機打開,然後透過datalab connect來連線服務...
$ datalab connect simonlab
Connecting to simonlab.
This will create an SSH tunnel and may prompt you to create an rsa key pair.
Waiting for Datalab to be reachable at http://localhost:8081/
The connection to Datalab is now open and will remain until this command is killed.
You can connect to Datalab at http://localhost:8081/
連線上後,系統會打開瀏覽器,讓您直接連線使用。
如果最後需要刪除這個資源,可以直接使用delete指令將該資源刪除...
$ datalab delete simonlab
Deleting simonlab
The following instances will be deleted. Attached disks configured to
be auto-deleted will be deleted unless they are attached to any other
instances. Deleting a disk is irreversible and any data on the disk
will be lost.
- [simonlab] in [asia-east1-c]
Do you want to continue (Y/n)? Y
Deleted [https://www.googleapis.com/compute/v1/projects/mitac-simonsu-2017/zones/asia-east1-c/instances/simonlab].
請注意,刪除的動作將回連同硬碟一起刪除,如果有需要,請先進行備份。
Last modified 4yr ago