在 Azure Stack Hub 中更新 MySQL 资源提供程序

重要

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

重要

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

重要

更新资源提供程序时,不会更新宿主 MySQL 服务器。

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

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

更新 MySQL Server 资源提供程序 V2

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

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

从 MySQL RP V1.1.93.x 更新为 MySQL RP V2.0.6.0

先决条件

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

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

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

  4. 确保你的 Azure Stack Hub 满足数据中心集成先决条件。

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

  6. 准备具有所需版本的 MySQL 连接器 URI。 有关详细信息,请参阅部署 MySQL 资源提供程序。 例如,https://<storageAcountName>.blob.<region>.<FQDN>/<containerName>/mysql-connector-net-8.0.21.msi

触发 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-MySQLRP'
# The service admin account can be Azure Active Directory or Active Directory Federation Services.
$serviceAdmin = "admin@mydomain.partner.onmschina.cn"
$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\mysqlcert\SSL.pfx"
# Local blob uri where stores the required mysql connector
$MySQLConnector = "Provide the MySQL Connector Uri according to Prerequisites step."
# 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\MajorVersionUpgradeMySQLProvider.ps1 -AzureEnvironment $AzureEnvironment -AzCredential $AdminCreds -CloudAdminCredential $CloudAdminCreds -Privilegedendpoint $privilegedEndpoint -PfxPassword $PfxPass -PfxCert $PfxFilePath -MySQLConnector $MySQLConnector

注意

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

验证升级是否成功

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

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

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

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

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

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

更新脚本过程

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

注意

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

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

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

重要

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

更新脚本参数

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

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

更新脚本示例

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

如果要将 MySQL 资源提供程序更新到版本 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 模块并手动注册存储库,这是先决条件。 可以在部署 MySQL 资源提供程序中获取详细信息

以下示例演示可以通过权限提升的 PowerShell 控制台运行的 UpdateMySQLProvider.ps1 脚本。 请务必根据需要更改变量信息和密码:

# Use the NetBIOS name for the Azure Stack Hub domain. On the Azure Stack Hub SDK, the default is AzureStack but could have been changed at install time.
$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 environment name is  AzureChinaCloud. 
$AzureEnvironment = "<EnvironmentName>"

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

# The service admin account (can be Azure Active Directory or Active Directory Federation Services).
$serviceAdmin = "admin@mydomain.partner.onmschina.cn" 
$AdminPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force 
$AdminCreds = New-Object System.Management.Automation.PSCredential ($serviceAdmin, $AdminPass) 
 
# Set credentials for the new resource provider VM.
$vmLocalAdminPass = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force 
$vmLocalAdminCreds = New-Object System.Management.Automation.PSCredential ("mysqlrpadmin", $vmLocalAdminPass) 
 
# And 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\UpdateMySQLProvider.ps1 -AzCredential $AdminCreds -VMLocalCredential $vmLocalAdminCreds -CloudAdminCredential $cloudAdminCreds -PrivilegedEndpoint $privilegedEndpoint -AzureEnvironment $AzureEnvironment -DefaultSSLCertificatePassword $PfxPass -DependencyFilesLocalPath $tempDir\cert -AcceptLicense

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

后续步骤

维护 MySQL 资源提供程序