更新 SQL 资源提供程序

重要

从 Azure Stack Hub 2108 版开始,SQL 和 MySQL 资源提供程序将提供给已获得访问权限的订阅。 如果想要开始使用此功能,或者需要从之前的版本升级,请创建支持案例,我们的支持工程师将指导你完成部署或升级过程。

重要

在更新资源提供程序之前,请查看发行说明,了解新功能、修补程序以及任何可能影响部署的已知问题。 发行说明还指定资源提供程序所需的最低 Azure Stack Hub 版本。

重要

更新资源提供程序时,不会更新宿主 SQL Server。

当 Azure Stack Hub 更新到新版本时,可能会发布新的 SQL 资源提供程序。 虽然现有的资源提供程序可以继续使用,但仍建议尽快更新到最新的内部版本。

支持的 Azure Stack Hub 版本 SQL RP 版本 RP 服务正在其上运行的 Windows Server
2206、2301、2306 SQL RP 版本 2.0.13.x Microsoft AzureStack 附加 RP Windows Server 1.2009.0
2108、2206 SQL RP 版本 2.0.6.x Microsoft AzureStack 附加 RP Windows Server 1.2009.0

更新 SQL Server 资源提供程序 V2

如果已部署了 SQL RP V2,并且想要检查更新,请查看如何将更新应用到资源提供程序

如果要从 SQL RP V1 更新到 SQL RP V2,请确保已先更新到 SQL RP V1.1.93.x,然后应用主版本升级过程从 SQL RP V1 升级到 SQl RP V2。

从 SQL RP V1.1.93.x 更新到 SQL RP V2.0.6.0

先决条件

  1. 请确保已将 SQL RP V1 更新到最新 1.1.93.x。 在“默认提供程序订阅”下,找到 RP 资源组(命名格式:system.<region>.sqladapter)。 确认资源组中的版本标记和 SQL RP VM 名称。 如果使用的仍是旧版本,并需要更新到 1.1.93.x,请建立一个支持案例以获取帮助。

  2. 建立支持案例以获取 MajorVersionUpgrade 包,并将订阅添加到未来 V2 版本的 ASH 市场允许列表中。

  3. 将 Microsoft Azure Stack 附加产品 RP Windows Server 1.2009.0 下载到市场。

  4. 请确保满足数据中心集成先决条件。

先决条件 参考
正确设置了条件性 DNS 转发。 Azure Stack Hub 数据中心集成 - DNS
资源提供程序的入站端口处于打开状态。 Azure Stack Hub 数据中心集成 - 入站端口和协议
正确设置了 PKI 证书使用者和 SAN。 Azure Stack Hub 部署必备 PKI 先决条件
Azure Stack Hub 部署 PaaS 证书先决条件
  1. (对于断开连接的环境)安装所需的 PowerShell 模块,类似于用于部署资源提供程序的更新过程。

触发 MajorVersionUpgrade

在权限提升的 PowerShell 控制台中运行以下脚本以执行主要版本升级。

注意

确保运行脚本的客户端计算机的 OS 版本不低于 Windows 10 或 Windows Server 2016,并且客户端计算机具有 X64 操作系统体系结构。

重要

强烈建议在运行部署或更新脚本之前,使用 Clear-AzureRmContext -Scope CurrentUser 和 Clear-AzureRmContext -Scope Process 清除缓存 。

# Check Operating System version
$osVersion = [environment]::OSVersion.Version
if ($osVersion.Build -lt 10240)
{
    Write-Host "OS version is too old: $osVersion."
    return
}

$osArch = (Get-WmiObject Win32_OperatingSystem).OSArchitecture
if ($osArch -ne "64-bit")
{
    Write-Host "OS Architecture is not 64 bit."
    return
}

# Check LongPathsEnabled registry key
$regPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem'
$longPathsEnabled = 'LongPathsEnabled'
$property = Get-ItemProperty -Path $regPath -Name $longPathsEnabled -ErrorAction Stop
if ($property.LongPathsEnabled -eq 0)
{
    Write-Host "Detect LongPathsEnabled equals to 0, prepare to set the property."
    Set-ItemProperty -Path $regPath -Name $longPathsEnabled -Value 1 -ErrorAction Stop
    Write-Host "Set the long paths property, please restart the PowerShell."
    return
} 

# Use the NetBIOS name for the Azure Stack Hub domain. 
$domain = "YouDomain" 

# For integrated systems, use the IP address of one of the ERCS VMs
$privilegedEndpoint = "YouDomain-ERCS01"

# Provide the Azure environment used for deploying Azure Stack Hub. Required only for Azure AD deployments.
$AzureEnvironment = "AzureChinaCloud"

# Point to the directory where the resource provider installation files were extracted.
$tempDir = 'C:\extracted-folder\MajorVersionUpgrade-SQLRP'

# The service admin account can be Azure Active Directory or Active Directory Federation Services.
$serviceAdmin = "admin@mydomain.partner.onmschina.com"
$AdminPass = ConvertTo-SecureString 'xxxxxxxx' -AsPlainText -Force
$AdminCreds = New-Object System.Management.Automation.PSCredential ($serviceAdmin, $AdminPass)

# Add the cloudadmin credential that's required for privileged endpoint access.
$CloudAdminPass = ConvertTo-SecureString 'xxxxxxxx' -AsPlainText -Force
$CloudAdminCreds = New-Object System.Management.Automation.PSCredential ("$domain\cloudadmin", $CloudAdminPass)

# Change the following as appropriate.
$PfxPass = ConvertTo-SecureString 'xxxxxxx' -AsPlainText -Force

# Provide the pfx file path
$PfxFilePath = "C:\tools\sqlcert\SSL.pfx"

# PowerShell modules used by the RP MajorVersionUpgrade are placed in C:\Program Files\SqlMySqlPsh
# The deployment script adds this path to the system $env:PSModulePath to ensure correct modules are used.
$rpModulePath = Join-Path -Path $env:ProgramFiles -ChildPath 'SqlMySqlPsh'
$env:PSModulePath = $env:PSModulePath + ";" + $rpModulePath 

. $tempDir\MajorVersionUpgradeSQLProvider.ps1 -AzureEnvironment $AzureEnvironment -AzCredential $AdminCreds -CloudAdminCredential $CloudAdminCreds -Privilegedendpoint $privilegedEndpoint -PfxPassword $PfxPass -PfxCert $PfxFilePath

注意

SQL RP V2 的 DNS 地址和对应的 IP 地址不同。 要获取新的公共 IP,可以联系支持人员,要求 DRP 应急并找到 SQLRPVM1130-PublicIP 资源。 还可以从已通过终结点测试的客户端计算机上运行“nslookup sqlrp.dbadapter.<fqdn>”以找出公共 IP。

验证升级是否成功

  1. MajorVersionUpgrade 脚本执行时没有任何错误。
  2. 检查市场中的资源提供程序,确保 SQL RP 2.0 已成功安装。
  3. 默认提供程序订阅中的旧 system.location>.sqladapter 资源组和 system.<location>.dbadapter.dns 资源组不会被脚本自动删除。
  • 建议将存储帐户和密钥保管库保留在 sqladapter 资源组中一段时间。 如果升级后,任何租户用户观察到不一致的数据库或登录元数据,则可以获得从资源组还原元数据的支持。
  • 验证 dbadapter.dns 资源组中的 DNS 区域为空且没有 DNS 记录后,可安全地删除 dbadapter.dns 资源组。
  • [重要提示] 请勿使用 V1 部署脚本卸载 V1 版本。 升级完成并确认升级成功后,可以从提供程序订阅中手动删除该资源组。

从 SQL RP V1 早期版本更新到 SQL RP V1.1.93.x

SQL 资源提供程序 V1 更新是累积的。 可以直接更新到 1.1.93.x 版本。

若要将资源提供程序更新到 1.1.93.x,请使用 UpdateSQLProvider.ps1 脚本。 使用具有本地管理权限且是订阅的所有者的服务帐户。 资源提供程序的下载包中提供此更新脚本。

更新过程类似于部署资源提供程序时使用的过程。 更新脚本与 DeploySqlProvider.ps1 脚本使用相同的参数,你需要提供证书信息。

更新脚本过程

UpdateSQLProvider.ps1 脚本使用最新的 OS 映像创建新的虚拟机 (VM),部署最新的资源提供程序代码,并将设置从旧资源提供程序迁移到新资源提供程序。

注意

建议从市场管理下载 Microsoft AzureStack 附加产品 RP Windows Server 1.2009.0 映像。 如需安装更新,可以将单个 MSU 包放置在本地依赖项路径中。 如果此位置中有多个 MSU 文件,则脚本将失败。

UpdateSQLProvider.ps1 脚本在创建新的 VM 后,会从旧的资源提供程序 VM 中迁移以下设置:

  • 数据库信息
  • 宿主服务器信息
  • 必要的 DNS 记录

重要

强烈建议在运行部署或更新脚本之前,使用 Clear-AzureRmContext -Scope CurrentUser 和 Clear-AzureRmContext -Scope Process 清除缓存 。

更新脚本参数

运行 UpdateSQLProvider.ps1 PowerShell 脚本时,可在命令行中指定以下参数。 如果未指定参数或任何参数验证失败,系统会提示提供所需的参数。

参数名称 说明 注释或默认值
CloudAdminCredential 访问特权终结点时所需的云管理员凭据。 必需
AzCredential Azure Stack Hub 服务管理员帐户的凭据。 使用部署 Azure Stack Hub 时所用的相同凭据。 如果用于 AzCredential 的帐户需要多重身份验证 (MFA),脚本将失败。 必需
VMLocalCredential SQL 资源提供程序 VM 的本地管理员帐户的凭据。 必需
PrivilegedEndpoint 特权终结点的 IP 地址或 DNS 名称。 必需
AzureEnvironment 用于部署 Azure Stack Hub 的服务管理员帐户的 Azure 环境。 仅对于 Microsoft Entra 部署为必需项。 受支持的环境名称是 AzureChinaCloud AzureChinaCloud
DependencyFilesLocalPath 同样必须将证书 .pfx 文件放在此目录中。 对单节点为可选,但对多节点为必选
DefaultSSLCertificatePassword .pfx 证书的密码。 必需
MaxRetryCount 操作失败时,想要重试每个操作的次数。 2
RetryDuration 每两次重试的超时间隔(秒)。 120
卸载 删除资源提供程序和所有关联的资源。
DebugMode 防止在失败时自动清除。

更新脚本 PowerShell 示例

如果要将 SQL 资源提供程序版本更新为 1.1.33.0 或早期版本,则需要在 PowerShell 中安装特定版本的 AzureRm.BootStrapper 和 Azure Stack Hub 模块。

如果要将 SQL 资源提供程序更新到版本 1.1.47.0 或更高版本,可以跳过此步骤。 部署脚本会自动下载所需的 PowerShell 模块并将其安装到路径 C:\Program Files\SqlMySqlPsh。

注意

如果文件夹 C:\Program Files\SqlMySqlPsh 已存在并已下载 PowerShell 模块,建议在运行更新脚本之前清理此文件夹。 这是为了确保下载并使用正确版本的 PowerShell 模块。

# Run the following scripts when updating to version 1.1.33.0 only.
# Install the AzureRM.Bootstrapper module, set the profile, and install the AzureStack module.
# Note that this might not be the most currently available version of Azure Stack Hub PowerShell.
Install-Module -Name AzureRm.BootStrapper -Force
Use-AzureRmProfile -Profile 2018-03-01-hybrid -Force
Install-Module -Name AzureStack -RequiredVersion 1.6.0

注意

在断开连接的情况下,需要下载所需的 PowerShell 模块并手动注册存储库,这是先决条件。 可以在部署 SQL 资源提供程序中获取详细信息

下面是 UpdateSQLProvider.ps1 脚本的使用示例,该脚本可以通过提升的 PowerShell 控制台来运行。 请务必根据需要更改变量信息和密码:

# Use the NetBIOS name for the Azure Stack Hub domain. On the Azure Stack Hub SDK, the default is AzureStack but this might have been changed at installation.
$domain = "AzureStack"

# For integrated systems, use the IP address of one of the ERCS VMs.
$privilegedEndpoint = "AzS-ERCS01"

# Provide the Azure environment used for deploying Azure Stack Hub. Required only for Azure AD deployments. Supported values for the <environment name> parameter is AzureChinaCloud depending which Azure subscription you're using.
$AzureEnvironment = "<EnvironmentName>"

# Point to the directory where the resource provider installation files were extracted.
$tempDir = 'C:\TEMP\SQLRP'

# The service admin account (this can be Azure AD or AD FS).
$serviceAdmin = "admin@mydomain.partner.onmschina.cn"
$AdminPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force
$AdminCreds = New-Object System.Management.Automation.PSCredential ($serviceAdmin, $AdminPass)

# Set the credentials for the new resource provider VM.
$vmLocalAdminPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force
$vmLocalAdminCreds = New-Object System.Management.Automation.PSCredential ("sqlrpadmin", $vmLocalAdminPass)

# Add the cloudadmin credential required for privileged endpoint access.
$CloudAdminPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force
$CloudAdminCreds = New-Object System.Management.Automation.PSCredential ("$domain\cloudadmin", $CloudAdminPass)

# Change the following as appropriate.
$PfxPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force

# For version 1.1.47.0 or later, the PowerShell modules used by the RP deployment are placed in C:\Program Files\SqlMySqlPsh
# The deployment script adds this path to the system $env:PSModulePath to ensure correct modules are used.
$rpModulePath = Join-Path -Path $env:ProgramFiles -ChildPath 'SqlMySqlPsh'
$env:PSModulePath = $env:PSModulePath + ";" + $rpModulePath

# Change directory to the folder where you extracted the installation files.
# Then adjust the endpoints.
. $tempDir\UpdateSQLProvider.ps1 -AzCredential $AdminCreds -VMLocalCredential $vmLocalAdminCreds -CloudAdminCredential $cloudAdminCreds -PrivilegedEndpoint $privilegedEndpoint -AzureEnvironment $AzureEnvironment -DefaultSSLCertificatePassword $PfxPass -DependencyFilesLocalPath $tempDir\cert

资源提供程序更新脚本完成后,请关闭当前的 PowerShell 会话。

后续步骤

维护 SQL 资源提供程序