本页面介绍了如何设置数据流水线以从 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.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify 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.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Cloud Data Fusion, BigQuery, Cloud Storage, and Dataproc APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. - 创建 Cloud Data Fusion 实例。
- 您的 SQL Server 数据库必须接受来自 Cloud Data Fusion 的连接。出于安全考虑,请使用私有 Cloud Data Fusion 实例。
在 Google Cloud 控制台中,前往 Cloud Data Fusion 实例页面。
在实例的操作列中,点击查看实例,以在 Cloud Data Fusion 中打开该实例。
打开 Cloud Data Fusion 实例
将 SQL Server 密码存储为安全密钥
将 SQL Server 密码添加为 Cloud Data Fusion 实例中的安全密钥。
在 Cloud Data Fusion 中,点击系统管理员。
点击配置标签页。
点击进行 HTTP 调用。
选择看涨期权。
在路径字段中,输入
namespaces/NAMESPACE_ID/securekeys/password。在正文字段中,输入
{"data":"password"}。 将 password 替换为您的 SQL Server 密码。点击发送。
响应必须具有状态代码 200 才能继续。
获取适用于 SQL Server 的 JDBC 驱动程序
您可以从 Cloud Data Fusion 中的 Hub 或 Pipeline Studio 获取驱动程序。
中心
在 Cloud Data Fusion 界面中,点击 Hub。
在搜索栏中,输入
SQL Server JDBC Driver,然后选择相应驱动程序。点击下载。按照所示的下载步骤操作。
点击部署。上传上一步中的 JAR 文件。
点击完成。
Pipeline Studio
前往 Microsoft.com。
选择下载的内容,然后点击下载。
在 Cloud Data Fusion 中,依次点击 menu Menu 和 Pipeline Studio 页面。
点击 Add。
对于驱动程序,请点击上传。
选择位于
jre7文件夹中的 JAR 文件。点击下一步。
如需配置驱动程序,请输入名称和类名称。
点击完成。
部署 SQL Server 插件
在 Cloud Data Fusion 中,点击 Hub。
在搜索栏中,输入
SQL Server Plugins。点击 SQL Server 插件。
点击部署。
点击完成。
点击创建流水线。
连接到 SQL Server
您可以在 Wrangler 或流水线 Studio 中通过 Cloud Data Fusion 连接到 SQL Server。
Wrangler
在 Cloud Data Fusion 中,依次点击 menu 菜单,然后前往 Wrangler 页面。
点击添加连接。
系统会打开添加连接窗口。
点击 SQL Server,验证驱动程序是否已安装。
在必填的连接字段中输入详细信息。在密码字段中,选择您之前存储的安全密钥。 这可确保使用 Cloud KMS 检索您的密码。
如需检查是否可以与数据库建立连接,请点击测试连接。
点击添加连接。
在 SQL Server 数据库连接并且已创建一个从 SQL Server 表读取数据的流水线后,您可以应用转换,并将输出写入接收器。
Pipeline Studio
打开 Cloud Data Fusion 实例,然后前往流水线 Studio 页面。
展开来源菜单,然后点击 SQL Server。
在 SQL Server 节点上,点击属性。
在引用名称字段中,输入用于标识 SQL Server 来源的名称。
在数据库字段中,输入要连接的数据库的名称。
在导入查询字段中,输入要运行的查询。例如
SELECT * FROM table WHERE $CONDITIONS。点击验证。
点击“关闭”图标 。
在 SQL Server 数据库连接并且已创建一个从 SQL Server 表读取数据的流水线后,您可以添加所需的任何转换,并将输出写入接收器。
后续步骤
- 了解如何从多个 SQL Server 表读取数据。
- 详细了解 Cloud Data Fusion。
- 按照其中一个教程操作。