部署拆分/合并服务以在分片数据库之间移动数据Deploy a split-merge service to move data between sharded databases

适用于:是Azure SQL 数据库 APPLIES TO: yesAzure SQL Database

可使用拆分/合并工具在分片数据库之间移动数据。The split-merge tool lets you move data between sharded databases. 请参阅在扩展云数据库之间移动数据See Moving data between scaled-out cloud databases

下载拆分/合并包Download the Split-Merge packages

  1. NuGet下载最新的 NuGet 版本。Download the latest NuGet version from NuGet.

  2. 打开命令提示符,并导航到用户下载 nuget.exe 的目录。Open a command prompt and navigate to the directory where you downloaded nuget.exe. 此下载包括 PowerShell 命令。The download includes PowerShell commands.

  3. 使用以下命令将最新的拆分/合并包下载到当前目录中:Download the latest Split-Merge package into the current directory with the below command:

    nuget install Microsoft.Azure.SqlDatabase.ElasticScale.Service.SplitMerge
    

文件放置在名为 Microsoft.Azure.SqlDatabase.ElasticScale.Service.SplitMerge.x.x.xxx.x 的目录中,其中 x.x.xxx.x 表示版本号。The files are placed in a directory named Microsoft.Azure.SqlDatabase.ElasticScale.Service.SplitMerge.x.x.xxx.x where x.x.xxx.x reflects the version number. 拆分/合并服务文件可在 content\splitmerge\service 子目录中找到;拆分/合并 PowerShell 脚本(和所需的客户端 dll)可在 content\splitmerge\powershell 子目录中找到。Find the split-merge Service files in the content\splitmerge\service sub-directory, and the Split-Merge PowerShell scripts (and required client dlls) in the content\splitmerge\powershell sub-directory.

先决条件Prerequisites

  1. 创建要用作拆分/合并状态数据库的 Azure SQL 数据库数据库。Create an Azure SQL Database database that will be used as the split-merge status database. 转到 Azure 门户Go to the Azure portal. 新建 SQL 数据库Create a new SQL Database. 为数据库指定一个名称,并新建管理员和密码。Give the database a name and create a new administrator and password. 确保记录该名称和密码以供日后使用。Be sure to record the name and password for later use.

  2. 确保服务器允许 Azure 服务与其连接。Ensure that your server allows Azure Services to connect to it. 在门户上的“防火墙设置”中,确保“允许访问 Azure 服务”设置设为“打开”。In the portal, in the Firewall Settings, ensure the Allow access to Azure Services setting is set to On. 单击“保存”图标。Click the "save" icon.

  3. 创建用于诊断输出的 Azure 存储帐户。Create an Azure Storage account for diagnostics output.

  4. 创建用于拆分/合并服务的 Azure 云服务。Create an Azure Cloud Service for your Split-Merge service.

配置拆分/合并服务Configure your Split-Merge service

拆分/合并服务配置Split-Merge service configuration

  1. 在下载了拆分/合并程序集的文件夹中,创建 SplitMergeService.cspkg 随附的 ServiceConfiguration.Template.cscfg 文件的副本,并将其重命名为 ServiceConfiguration.cscfgIn the folder into which you downloaded the Split-Merge assemblies, create a copy of the ServiceConfiguration.Template.cscfg file that shipped alongside SplitMergeService.cspkg and rename it ServiceConfiguration.cscfg.

  2. 在文本编辑器(如 Visual Studio)中打开 ServiceConfiguration.cscfg ,它会验证输入内容(例如证书指纹的格式)。Open ServiceConfiguration.cscfg in a text editor such as Visual Studio that validates inputs such as the format of certificate thumbprints.

  3. 新建数据库或选择现有数据库,以将其用作拆分/合并操作的状态数据库并检索该数据库的连接字符串。Create a new database or choose an existing database to serve as the status database for Split-Merge operations and retrieve the connection string of that database.

    重要

    目前,状态数据库必须使用拉丁语排序规则 (SQL_Latin1_General_CP1_CI_AS)。At this time, the status database must use the Latin collation (SQL_Latin1_General_CP1_CI_AS). 有关详细信息,请参阅 Windows 排序规则名称 (Transact-SQL)For more information, see Windows Collation Name (Transact-SQL).

    在 Azure SQL 数据库中,连接字符串通常采用以下形式:With Azure SQL Database, the connection string typically is of the form:

    Server=<serverName>.database.chinacloudapi.cn; Database=<databaseName>;User ID=<userId>; Password=<password>; Encrypt=True; Connection Timeout=30

  4. 在 ElasticScaleMetadata 设置的 SplitMergeWebSplitMergeWorker 角色部分中,在 cscfg 文件内输入此连接字符串。Enter this connection string in the .cscfg file in both the SplitMergeWeb and SplitMergeWorker role sections in the ElasticScaleMetadata setting.

  5. 对于 SplitMergeWorker 角色,在 WorkerRoleSynchronizationStorageAccountConnectionString 设置中输入有效的连接字符串用于连接到 Azure 存储。For the SplitMergeWorker role, enter a valid connection string to Azure storage for the WorkerRoleSynchronizationStorageAccountConnectionString setting.

配置安全性Configure security

有关配置服务安全性的详细说明,请参阅拆分/合并安全配置For detailed instructions to configure the security of the service, refer to the Split-Merge security configuration.

为了针对本教程创建一个简单的测试部署,我们会执行少量的配置步骤来使服务正常运行。For the purposes of a simple test deployment for this tutorial, a minimal set of configuration steps will be performed to get the service up and running. 仅一个计算机/帐户可以执行这些步骤,以便与服务进行通信。These steps enable only the one machine/account executing them to communicate with the service.

创建自签名证书Create a self-signed certificate

创建新的目录并使用 Visual Studio 的开发人员命令提示符窗口从该目录执行以下命令:Create a new directory and from this directory execute the following command using a Developer Command Prompt for Visual Studio window:

makecert ^
 -n "CN=*.chinacloudapp.cn" ^
 -r -cy end -sky exchange -eku "1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2" ^
 -a sha256 -len 2048 ^
 -sr currentuser -ss root ^
 -sv MyCert.pvk MyCert.cer

会要求你提供密码以保护私钥。You are asked for a password to protect the private key. 输入强密码并进行确认。Enter a strong password and confirm it. 之后,系统会提示再次输入该密码。You are then prompted for the password to be used once more after that. 在完成后单击“是” ,以将证书导入到“受信任的根证书颁发机构”存储中。Click Yes at the end to import it to the Trusted Certification Authorities Root store.

创建 PFX 文件Create a PFX file

从执行 makecert 的相同窗口中执行以下命令;使用用于创建证书的相同密码:Execute the following command from the same window where makecert was executed; use the same password that you used to create the certificate:

pvk2pfx -pvk MyCert.pvk -spc MyCert.cer -pfx MyCert.pfx -pi <password>

将客户端证书导入到个人存储中Import the client certificate into the personal store

  1. 在 Windows 资源管理器中,双击“MyCert.pfx” 。In Windows Explorer, double-click MyCert.pfx.
  2. 在“证书导入向导”中,选择“当前用户”,然后单击“下一步”。In the Certificate Import Wizard select Current User and click Next.
  3. 确认文件路径,并单击“下一步” 。Confirm the file path and click Next.
  4. 键入密码,保持选中“包括所有扩展属性”,然后单击“下一步”。Type the password, leave Include all extended properties checked and click Next.
  5. 保持选中“自动选择证书存储[…]”,然后单击“下一步”。Leave Automatically select the certificate store[…] checked and click Next.
  6. 依次单击“完成”和“确定”。Click Finish and OK.

将 PFX 文件上传到云服务Upload the PFX file to the cloud service

  1. 转到 Azure 门户Go to the Azure portal.
  2. 选择“云服务” 。Select Cloud Services.
  3. 选择你之前为拆分/合并服务创建的云服务。Select the cloud service you created above for the Split/Merge service.
  4. 单击顶部菜单上的“证书” 。Click Certificates on the top menu.
  5. 单击底部栏中的“上传” 。Click Upload in the bottom bar.
  6. 选择 PFX 文件并输入上面所述的相同密码。Select the PFX file and enter the same password as above.
  7. 完成操作后,从列表中的新条目复制证书指纹。Once completed, copy the certificate thumbprint from the new entry in the list.

更新服务配置文件Update the service configuration file

将之前复制的证书指纹粘贴到这些设置的指纹/值属性中。Paste the certificate thumbprint copied above into the thumbprint/value attribute of these settings. 对于辅助角色:For the worker role:

 <Setting name="DataEncryptionPrimaryCertificateThumbprint" value="" />
 <Certificate name="DataEncryptionPrimary" thumbprint="" thumbprintAlgorithm="sha1" />

对于 Web 角色:For the web role:

 <Setting name="AdditionalTrustedRootCertificationAuthorities" value="" />
 <Setting name="AllowedClientCertificateThumbprints" value="" />
 <Setting name="DataEncryptionPrimaryCertificateThumbprint" value="" />
 <Certificate name="SSL" thumbprint="" thumbprintAlgorithm="sha1" />
 <Certificate name="CA" thumbprint="" thumbprintAlgorithm="sha1" />
 <Certificate name="DataEncryptionPrimary" thumbprint="" thumbprintAlgorithm="sha1" />

请注意,对于生产部署,应针对用于加密的 CA 使用单独的证书(服务器证书和客户端证书)。Please note that for production deployments separate certificates should be used for the CA, for encryption, the Server certificate and client certificates. 有关此内容的详细说明,请参阅安全配置For detailed instructions on this, see Security Configuration.

部署服务Deploy your service

  1. 转到 Azure 门户Go to the Azure portal
  2. 选择先前创建的云服务。Select the cloud service that you created earlier.
  3. 单击“概览”。Click Overview.
  4. 选择过渡环境,并单击“上传”。Choose the staging environment, then click Upload.
  5. 在对话框中,输入一个部署标签。In the dialog box, enter a deployment label. 对于“程序包”和“配置”,单击“从本地”,并选择 SplitMergeService.cspkg 文件和之前配置的 cscfg 文件。For both 'Package' and 'Configuration', click 'From Local' and choose the SplitMergeService.cspkg file and your cscfg file that you configured earlier.
  6. 确保选中标记为“即使一个或多个角色包含单个实例也部署” 的复选框。Ensure that the checkbox labeled Deploy even if one or more roles contain a single instance is checked.
  7. 点击右下角的勾选按钮以开始部署。Hit the tick button in the bottom right to begin the deployment. 它预计需要几分钟的时间才能完成。Expect it to take a few minutes to complete.

排查部署问题Troubleshoot the deployment

如果 Web 角色无法联机,可能是安全配置出现了问题。If your web role fails to come online, it is likely a problem with the security configuration. 检查是否如上所述配置了 TLS/SSL。Check that the TLS/SSL is configured as described above.

如果辅助角色无法联机,但是 Web 角色已成功,很可能是在连接到之前创建的状态数据库时出现了问题。If your worker role fails to come online, but your web role succeeds, it is most likely a problem connecting to the status database that you created earlier.

  • 确保 cscfg 中的连接字符串正确。Make sure that the connection string in your cscfg is accurate.

  • 检查服务器和数据库是否存在,以及用户 ID 和密码是否正确。Check that the server and database exist, and that the user id and password are correct.

  • 对于 Azure SQL 数据库,连接字符串应采用以下形式:For Azure SQL Database, the connection string should be of the form:

    Server=<serverName>.database.chinacloudapi.cn; Database=<databaseName>;User ID=<user>; Password=<password>; Encrypt=True; Connection Timeout=30

  • 确保服务器名称不以 https:// 开头。Ensure that the server name does not begin with https://.

  • 确保服务器允许 Azure 服务与其连接。Ensure that your server allows Azure Services to connect to it. 为此,请在门户中打开数据库,并确保“允许访问 Azure 服务”设置设为“启用”。To do this, open your database in the portal and ensure that the Allow access to Azure Services setting is set to **On****.

测试服务部署Test the service deployment

使用 Web 浏览器建立连接Connect with a web browser

确定拆分/合并服务的 Web 终结点。Determine the web endpoint of your Split-Merge service. 可以在门户中找到此终结点,方法是转到云服务的“概述”并在右侧的“站点 URL”下查找。You can find this in the portal by going to the Overview of your cloud service and looking under Site URL on the right side. 由于默认的安全设置将禁用 HTTP 终结点,因此请将 http:// 替换为 https://Replace http:// with https:// since the default security settings disable the HTTP endpoint. 将此 URL 的页面加载到浏览器中。Load the page for this URL into your browser.

使用 PowerShell 脚本进行测试Test with PowerShell scripts

可以通过运行包含的示例 PowerShell 脚本测试部署和环境。The deployment and your environment can be tested by running the included sample PowerShell scripts.

包含的脚本文件为:The script files included are:

  1. SetupSampleSplitMergeEnvironment.ps1 - 为拆分/合并设置测试数据层(有关详细说明,请参阅下表)SetupSampleSplitMergeEnvironment.ps1 - sets up a test data tier for Split/Merge (see table below for detailed description)

  2. ExecuteSampleSplitMerge.ps1 - 在测试数据层上执行测试操作(有关详细说明,请参阅下表)ExecuteSampleSplitMerge.ps1 - executes test operations on the test data tier (see table below for detailed description)

  3. GetMappings.ps1 - 可输出分片映射的当前状态的最上层示例脚本。GetMappings.ps1 - top-level sample script that prints out the current state of the shard mappings.

  4. ShardManagement.psm1 - 可包装 ShardManagement API 的帮助程序脚本ShardManagement.psm1 - helper script that wraps the ShardManagement API

  5. SqlDatabaseHelpers.psm1 - 用于在 SQL 数据库中创建和管理数据库的帮助程序脚本SqlDatabaseHelpers.psm1 - helper script for creating and managing databases in SQL Database

    PowerShell 文件PowerShell file 步骤Steps
    SetupSampleSplitMergeEnvironment.ps1SetupSampleSplitMergeEnvironment.ps1 1. 创建分片映射管理器数据库Creates a shard map manager database
    2. 创建 2 个分片数据库。Creates 2 shard databases.
    3. 为这些数据库创建一个分片映射(删除这些数据库上的任何现有分片映射)。Creates a shard map for those databases (deletes any existing shard maps on those databases).
    4. 在这两个分片中创建一个小的示例表,然后使用一个分片填充该表。Creates a small sample table in both the shards, and populates the table in one of the shards.
    5. 声明分片表的 SchemaInfo。Declares the SchemaInfo for the sharded table.
    PowerShell 文件PowerShell file 步骤Steps
    ExecuteSampleSplitMerge.ps1ExecuteSampleSplitMerge.ps1 1. 将拆分请求发送到拆分/合并服务 Web 前端,以将数据从第一个分片到第二个分片拆分为两半。Sends a split request to the Split-Merge Service web frontend, which splits half the data from the first shard to the second shard.
    2. 轮询拆分请求状态的 Web 前端并等待该请求完成。Polls the web frontend for the split request status and waits until the request completes.
    3. 将合并请求发送到拆分/合并服务 Web 前端,以将数据从第二个分片移回到第一个分片。Sends a merge request to the Split-Merge Service web frontend, which moves the data from the second shard back to the first shard.
    4. 轮询合并请求状态的 Web 前端并等待该请求完成。Polls the web frontend for the merge request status and waits until the request completes.

使用 PowerShell 验证部署Use PowerShell to verify your deployment

  1. 打开新的 PowerShell 窗口并导航到下载拆分/合并包的目录,然后导航到“powershell”目录中。Open a new PowerShell window and navigate to the directory where you downloaded the Split-Merge package, and then navigate into the "powershell" directory.

  2. 创建一个将要在其中创建分片映射管理器和分片的服务器(或选择现有服务器)。Create a server (or choose an existing server) where the shard map manager and shards will be created.

    备注

    在默认情况下,SetupSampleSplitMergeEnvironment.ps1 脚本将在同一服务器上创建所有这些数据库以简化脚本。The SetupSampleSplitMergeEnvironment.ps1 script creates all these databases on the same server by default to keep the script simple. 这并不表示拆分/合并服务本身存在限制。This is not a restriction of the Split-Merge Service itself.

    拆分/合并服务需要具有数据库读/写访问权限的 SQL 身份验证登录,才能移动数据并更新分片映射。A SQL authentication login with read/write access to the DBs will be needed for the Split-Merge service to move data and update the shard map. 由于拆分/合并服务在云中运行,因此它当前不支持集成的身份验证。Since the Split-Merge Service runs in the cloud, it does not currently support Integrated Authentication.

    确保服务器已配置为允许从运行这些脚本的计算机的 IP 地址进行访问。Make sure the server is configured to allow access from the IP address of the machine running these scripts. 可以在 SQL Server/防火墙和虚拟网络/客户端 IP 地址下找到此设置。You can find this setting under SQL server / Firewalls and virtual networks / Client IP addresses.

  3. 执行 SetupSampleSplitMergeEnvironment.ps1 脚本以创建示例环境。Execute the SetupSampleSplitMergeEnvironment.ps1 script to create the sample environment.

    运行此脚本会擦除分片映射管理器数据库和分片上任何现有的分片映射管理数据结构。Running this script will wipe out any existing shard map management data structures on the shard map manager database and the shards. 如果想要重新初始化分片映射或分片,重新运行脚本可能会很有用。It may be useful to rerun the script if you wish to re-initialize the shard map or shards.

    示例命令行:Sample command line:

    .\SetupSampleSplitMergeEnvironment.ps1
     -UserName 'mysqluser' -Password 'MySqlPassw0rd' -ShardMapManagerServerName 'abcdefghij.database.chinacloudapi.cn'
    
  4. 执行 Getmappings.ps1 脚本以查看示例环境中当前存在的映射。Execute the Getmappings.ps1 script to view the mappings that currently exist in the sample environment.

    .\GetMappings.ps1
     -UserName 'mysqluser' -Password 'MySqlPassw0rd' -ShardMapManagerServerName 'abcdefghij.database.chinacloudapi.cn'
    
  5. 执行 ExecuteSampleSplitMerge.ps1 脚本以执行拆分操作(将第一个分片上一半的数据移至第二个分片),然后执行合并操作(将数据移回第一个分片)。Execute the ExecuteSampleSplitMerge.ps1 script to execute a split operation (moving half the data on the first shard to the second shard) and then a merge operation (moving the data back onto the first shard). 如果已配置 TLS 并且已将 http 终结点保留为禁用,请确保改用 https:// 终结点。If you configured TLS and left the http endpoint disabled, ensure that you use the https:// endpoint instead.

    示例命令行:Sample command line:

    .\ExecuteSampleSplitMerge.ps1
    -UserName 'mysqluser' -Password 'MySqlPassw0rd'
    -ShardMapManagerServerName 'abcdefghij.database.chinacloudapi.cn' 
    -SplitMergeServiceEndpoint 'https://mysplitmergeservice.chinacloudapp.cn' 
    -CertificateThumbprint '0123456789abcdef0123456789abcdef01234567'
    

    如果收到以下错误,很有可能是 Web 终结点证书出现了问题。If you receive the below error, it is most likely a problem with your Web endpoint's certificate. 尝试使用最喜欢的 Web 浏览器连接到 Web 终结点并检查是否存在证书错误。Try connecting to the Web endpoint with your favorite Web browser and check if there is a certificate error.

    Invoke-WebRequest : The underlying connection was closed: Could not establish trust relationship for the SSL/TLSsecure channel.

    如果成功,则输出应如下所示:If it succeeded, the output should look like the below:

    > .\ExecuteSampleSplitMerge.ps1 -UserName 'mysqluser' -Password 'MySqlPassw0rd' -ShardMapManagerServerName 'abcdefghij.database.chinacloudapi.cn' -SplitMergeServiceEndpoint 'http://mysplitmergeservice.chinacloudapp.cn' -CertificateThumbprint 0123456789abcdef0123456789abcdef01234567
    > Sending split request
    > Began split operation with id dc68dfa0-e22b-4823-886a-9bdc903c80f3
    > Polling split-merge request status. Press Ctrl-C to end
    > Progress: 0% | Status: Queued | Details: [Informational] Queued request
    > Progress: 5% | Status: Starting | Details: [Informational] Starting split-merge state machine for request.
    > Progress: 5% | Status: Starting | Details: [Informational] Performing data consistency checks on target     shards.
    > Progress: 20% | Status: CopyingReferenceTables | Details: [Informational] Moving reference tables from     source to target shard.
    > Progress: 20% | Status: CopyingReferenceTables | Details: [Informational] Waiting for reference tables copy     completion.
    > Progress: 20% | Status: CopyingReferenceTables | Details: [Informational] Moving reference tables from     source to target shard.
    > Progress: 44% | Status: CopyingShardedTables | Details: [Informational] Moving key range [100:110) of     Sharded tables
    > Progress: 44% | Status: CopyingShardedTables | Details: [Informational] Successfully copied key range     [100:110) for table [dbo].[MyShardedTable]
    > ...
    > ...
    > Progress: 90% | Status: Completing | Details: [Informational] Successfully deleted shardlets in table     [dbo].[MyShardedTable].
    > Progress: 90% | Status: Completing | Details: [Informational] Deleting any temp tables that were created     while processing the request.
    > Progress: 100% | Status: Succeeded | Details: [Informational] Successfully processed request.
    > Sending merge request
    > Began merge operation with id 6ffc308f-d006-466b-b24e-857242ec5f66
    > Polling request status. Press Ctrl-C to end
    > Progress: 0% | Status: Queued | Details: [Informational] Queued request
    > Progress: 5% | Status: Starting | Details: [Informational] Starting split-merge state machine for request.
    > Progress: 5% | Status: Starting | Details: [Informational] Performing data consistency checks on target     shards.
    > Progress: 20% | Status: CopyingReferenceTables | Details: [Informational] Moving reference tables from     source to target shard.
    > Progress: 44% | Status: CopyingShardedTables | Details: [Informational] Moving key range [100:110) of     Sharded tables
    > Progress: 44% | Status: CopyingShardedTables | Details: [Informational] Successfully copied key range     [100:110) for table [dbo].[MyShardedTable]
    > ...
    > ...
    > Progress: 90% | Status: Completing | Details: [Informational] Successfully deleted shardlets in table     [dbo].[MyShardedTable].
    > Progress: 90% | Status: Completing | Details: [Informational] Deleting any temp tables that were created     while processing the request.
    > Progress: 100% | Status: Succeeded | Details: [Informational] Successfully processed request.
    >
    
  6. 试用其他数据类型!Experiment with other data types! 所有这些脚本均采取可选的 -ShardKeyType 参数,该参数允许指定密钥类型。All of these scripts take an optional -ShardKeyType parameter that allows you to specify the key type. 默认值为 Int32,但你也可以指定 Int64、Guid 或 Binary。The default is Int32, but you can also specify Int64, Guid, or Binary.

创建请求Create requests

可以通过 Web UI 或通过导入并使用 SplitMerge.psm1 PowerShell 模块(该模块会通过 Web 角色提交你的请求)使用该服务。The service can be used either by using the web UI or by importing and using the SplitMerge.psm1 PowerShell module which will submit your requests through the web role.

该服务可以移动分片表和引用表中的数据。The service can move data in both sharded tables and reference tables. 分片表具有一个分片密钥列并在不同的分片上具有不同的行数据。A sharded table has a sharding key column and has different row data on each shard. 引用表未进行分片,因此它在每个分片上都包含相同的行数据。A reference table is not sharded so it contains the same row data on every shard. 引用表适用于不经常更改的数据,并且可用于接联查询中的分片表。Reference tables are useful for data that does not change often and is used to JOIN with sharded tables in queries.

为了执行拆分/合并操作,必须声明要移动的分片表和引用表。In order to perform a split-merge operation, you must declare the sharded tables and reference tables that you want to have moved. 使用 SchemaInfo API 完成此操作。This is accomplished with the SchemaInfo API. 此 API 位于 Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.Schema 命名空间中。This API is in the Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.Schema namespace.

  1. 对于每个分片表,请创建一个 ShardedTableInfo 对象,该对象在包含分片密钥的表中描述了此表的父架构名称(可选,默认为“dbo”)、表名称以及列名称。For each sharded table, create a ShardedTableInfo object describing the table's parent schema name (optional, defaults to "dbo"), the table name, and the column name in that table that contains the sharding key.
  2. 对于每个引用表,请创建一个 ReferenceTableInfo 对象,该对象描述了此表的父架构名称(可选,默认为“dbo”)和表名称。For each reference table, create a ReferenceTableInfo object describing the table's parent schema name (optional, defaults to "dbo") and the table name.
  3. 将上面的 TableInfo 对象添加到新的 SchemaInfo 对象。Add the above TableInfo objects to a new SchemaInfo object.
  4. 获取对 ShardMapManager 对象的引用,然后调用 GetSchemaInfoCollectionGet a reference to a ShardMapManager object, and call GetSchemaInfoCollection.
  5. SchemaInfo 添加到 SchemaInfoCollection,从而提供分片映射名称。Add the SchemaInfo to the SchemaInfoCollection, providing the shard map name.

可在 SetupSampleSplitMergeEnvironment.ps1 脚本中看到此操作的示例。An example of this can be seen in the SetupSampleSplitMergeEnvironment.ps1 script.

拆分/合并服务不会为用户创建目标数据库(或为数据库中的任何表创建架构)。The Split-Merge service does not create the target database (or schema for any tables in the database) for you. 在将请求发送到服务之前,必须预先创建它们。They must be pre-created before sending a request to the service.

故障排除Troubleshooting

在运行示例 PowerShell 脚本时,可能会看到下面的消息:You may see the below message when running the sample PowerShell scripts:

Invoke-WebRequest : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

此错误表示 TLS/SSL 证书未正确配置。This error means that your TLS/SSL certificate is not configured correctly. 请按照“与 Web 浏览器连接”部分中的说明进行操作。Please follow the instructions in section 'Connecting with a web browser'.

如果无法提交请求,可能会看到:If you cannot submit requests you may see this:

[Exception] System.Data.SqlClient.SqlException (0x80131904): Could not find stored procedure 'dbo.InsertRequest'.

在这种情况下,请检查配置文件,尤其是 WorkerRoleSynchronizationStorageAccountConnectionString的设置。In this case, check your configuration file, in particular the setting for WorkerRoleSynchronizationStorageAccountConnectionString. 此错误通常表示辅助角色无法成功初始化首次使用的元数据数据库。This error typically indicates that the worker role could not successfully initialize the metadata database on first use.

其他资源Additional resources

尚未使用弹性数据库工具?Not using elastic database tools yet? 请查看入门指南Check out our Getting Started Guide.