本頁說明如何設定資料管道,從 Microsoft SQL Server 資料表讀取資料。
事前準備
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Cloud Data Fusion, BigQuery, Cloud Storage, and Dataproc APIs.
- 建立 Cloud Data Fusion 執行個體。
- SQL Server 資料庫必須接受來自 Cloud Data Fusion 的連線。基於安全考量,請使用私人 Cloud Data Fusion 執行個體。
前往 Google Cloud 控制台的 Cloud Data Fusion「Instances」(執行個體) 頁面。
在執行個體所屬的「動作」欄中,按一下「查看執行個體」,即可在 Cloud Data Fusion 中開啟執行個體。
開啟 Cloud Data Fusion 執行個體
將 SQL Server 密碼儲存為安全金鑰
在 Cloud Data Fusion 執行個體中,將 SQL Server 密碼新增為安全金鑰。
在 Cloud Data Fusion 中,按一下「系統管理」。
按一下 [設定] 標籤。
按一下「Make HTTP Calls」。
選取「PUT」。
在路徑欄位中輸入
namespaces/NAMESPACE_ID/securekeys/password
。在「Body」欄位中輸入
{"data":"password"}
。 將 password 替換為您的 SQL Server 密碼。按一下 [傳送]。
回應必須具有 200
狀態碼,才能繼續。
取得 SQL Server 的 JDBC 驅動程式
您可以從 Hub 或 Cloud Data Fusion 的 Pipeline Studio 取得驅動程式。
中樞
在 Cloud Data Fusion UI 中,按一下「Hub」。
在搜尋列中輸入
SQL Server JDBC Driver
,然後選取所需驅動程式。按一下「下載」。按照畫面上的下載步驟操作。
按一下「Deploy」(部署)。上傳上一個步驟中的 JAR 檔案。
按一下「完成」。
Pipeline Studio
前往 Microsoft.com。
選擇要下載的內容,然後按一下「下載」。
在 Cloud Data Fusion 中,按一下 menu「Menu」(選單),然後前往「Pipeline Studio」(管道工作室) 頁面。
按一下
「新增」。按一下「上傳」上傳驅動程式。
選取位於
jre7
資料夾中的 JAR 檔案。點選「下一步」。
如要設定驅動程式,請輸入「Name」(名稱) 和「Class name」(類別名稱)。
按一下「完成」。
部署 SQL Server 外掛程式
在 Cloud Data Fusion 中,按一下「Hub」(中樞)。
在搜尋列中輸入
SQL Server Plugins
。按一下「SQL server plugins」(SQL Server 外掛程式)。
按一下 [Deploy] (部署)。
按一下「完成」。
按一下「建立管道」。
連線至 SQL Server
您可以在 Wrangler 或 Pipeline Studio 中,從 Cloud Data Fusion 連線至 SQL Server。
Wrangler
在 Cloud Data Fusion 中,按一下「選單」menu,然後前往「Wrangler」頁面。
按一下「新增連線」。
「新增連線」視窗隨即開啟。
按一下「SQL Server」,確認驅動程式已安裝。
在必要連線欄位中輸入詳細資料。在「Password」(密碼) 欄位中,選取先前儲存的安全金鑰。 確保密碼是透過 Cloud KMS 擷取。
如要檢查是否能與資料庫建立連線,請按一下「測試連線」。
按一下「新增連線」。
連線至 SQL Server 資料庫並建立從 SQL Server 資料表讀取資料的管道後,即可套用轉換作業,並將輸出內容寫入接收器。
Pipeline Studio
開啟 Cloud Data Fusion 執行個體,然後前往「Pipeline Studio」(Pipeline 工作室) 頁面。
展開「來源」選單,然後按一下「SQL Server」。
在「SQL Server」節點上,按一下「Properties」(屬性)。
在「Reference name」(參照名稱) 欄位中,輸入可識別 SQL Server 來源的名稱。
在「資料庫」欄位中,輸入要連線的資料庫名稱。
在「匯入查詢」欄位中,輸入要執行的查詢。例如:
SELECT * FROM table WHERE $CONDITIONS
。按一下「Validate」(驗證)。
按一下「關閉」圖示
。
連線至 SQL Server 資料庫並建立從 SQL Server 資料表讀取資料的管道後,請新增任何所需的轉換作業,然後將輸出內容寫入接收器。
後續步驟
- 瞭解如何從多個 SQL Server 資料表讀取資料。
- 進一步瞭解 Cloud Data Fusion。
- 按照其中一個教學課程操作。