如何升级在 Windows 故障转移群集上运行的通用应用程序



我想为我的应用程序使用 Windows 故障转移群集通用服务角色。 我正在尝试弄清楚如何执行升级。

我读到有一个选项可以执行"集群感知"升级,即:给集群一些MSI \安装程序,让他负责升级所有节点。

使用该功能的任何人都可以:

  1. 能描述他是怎么做到的吗?
  2. 启用它是否有任何特殊要求?
  3. 推荐吗?

我们有使用.NET堆栈的群集 Windows 服务。目前,每个群集角色仅托管在两个节点上。部署和升级过程通过Ansible执行。以下代码片段仅涵盖升级部分。


对于服务部署,Nuget包一起使用。使用.nuspec如下所示。因此,包表示.zip存档,其中包含根目录中的所有内容。

<?xml version="1.0"?>
<package>
<metadata>
<id>$Id$</id>
<version>$Version$</version>
<authors>$Authors$</authors>
<description> $Description$ </description>
<releaseNotes>$ReleaseNotes$</releaseNotes>
</metadata>
<files>
<file src="$PackageInput$" target=" "/>
</files>
</package>

当一个群集角色包含多个资源时,下面描述的角色可用于复合群集角色。

- name: 'Copy the cluster_role.ps1 to all hosts'
win_copy:
src : 'cluster_role.ps1'
dest: 'cluster_role.ps1'

需要此任务将PowerShell脚本复制到所有主机,这是检测所有者节点和在节点之间移动角色所必需的。

param([String]$ClusterRoleName, [String]$ExcludeNode)
# Task: Define the owner node
if ($ClusterRoleName -ne [string]::Empty -and $ExcludeNode -eq [string]::Empty)
{
Get-ClusterResource -Name $ClusterRoleName | Format-List -Property OwnerNode
exit
}
# Task: Move the cluster role
if ($ClusterRoleName -ne [string]::Empty -and $ExcludeNode -ne [string]::Empty)
{
Move-ClusterGroup $ClusterRoleName (Get-ClusterNode | Where-Object { $_.State -eq 'Up' -and $_.Name -ne $ExcludeNode })
exit
}

- name: 'Define the owner node'
win_shell: 'cluster_role.ps1 -ClusterRoleName {{ cluster_role }}'
register: owner_node
run_once: True
when: 'cluster_role is defined'

- name: 'Define the owner node metadata'
set_fact:
owner_node_host: '{{ owner_node.stdout.split(":")[1] | trim }}.{{ windows_domain }}'
owner_node_name: '{{ owner_node.stdout.split(":")[1] | trim }}'
run_once: True
when: 'cluster_role is defined'

需要这些任务来检测所有者节点。第一个任务返回所有者节点,例如:s001srv000。第二个任务创建以下类型的两个变量:

owner_node_host  : s001srv.domain.net
owner_node_name: s001srv000 

- name: 'Apply the application roles on the inactive nodes'
include_role:
name: '{{ item }}'
when  : 'cluster_role is defined and (cluster_sets is defined or cluster_full is defined) and owner_node_host != inventory_hostname'
with_items: '{{ dependencies }}'

这些任务包括其他角色,例如下载新版本包、根据环境生成服务配置等。 在非活动节点上执行。


- pause:
prompt : 'A manual failover must be manually performed'
minutes: 30
run_once : True
when: 'cluster_full is defined and environment_type == "prod"'

- name: 'Move the cluster role'
win_shell: 'cluster_role.ps1 -ClusterRoleName {{ cluster_role }} -ExcludeNode {{ owner_node_name }}'
run_once : True
when: 'cluster_move is defined or cluster_full is defined'

需要这些任务来控制升级流程,如果当前环境是 STG,则将自动执行升级,否则在暂停时手动故障转移。


- name: 'Apply the application roles on the nodes which were active a moment ago'
include_role:
name: '{{ item }}'                                                                                                  
when  : 'cluster_role is defined and cluster_full is defined and owner_node_host == inventory_hostname'

这些任务与'Apply the application roles on the inactive nodes'相同,但适用于刚才处于活动状态的节点。

相关内容

最新更新