我想为我的应用程序使用 Windows 故障转移群集通用服务角色。我正在尝试找出如何执行升级。
我读到有一个选项可以执行“集群感知”升级,即:向集群提供一些 MSI\安装程序,并让他负责升级所有节点。
使用过该功能的人是否可以:
- 可以描述一下他是如何做到的吗?
- 启用它有什么特殊要求吗?
- 值得推荐吗?
最佳答案
我们拥有使用 .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'
这些任务与“在非事件节点上应用应用程序角色”
相同,但适用于刚才处于事件状态的节点。
关于c# - 如何升级在 Windows 故障转移群集上运行的通用应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52464015/