【问题标题】:How to upgrade a generic application running on a windows failover cluster如何升级在 Windows 故障转移群集上运行的通用应用程序
【发布时间】:2019-02-27 01:28:04
【问题描述】:

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

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

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

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

【问题讨论】:

  • 您是在集群中托管的 Windows 服务?
  • @UserName - 是的(它是 Microsoft 故障转移集群的内置选项)
  • 你问的和编程无关。这是一项管理操作,自 2008 年起就在 Technet 中进行了报道,如果不是更早的话。具体情况因操作系统而异,因此您应该查看与目标服务器相关的文档。较新的操作系统将采用更新、更好或更易于处理的技术来提供高可用性
  • 如果你愿意,我可以描述我们如何升级/更新我们的集群 [WSFC] Windows 服务。
  • 准备了答案。我希望它会有用。

标签: c# .net failovercluster


【解决方案1】:

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


服务部署使用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' 相同,但针对的是刚刚处于活动状态的节点。

【讨论】:

  • Tnx - 这很有帮助!数据库升级呢?这是您描述正确的 SAAS 应用程序(您部署到您控制的环境中)?
  • “这些任务包括其他角色,例如下载新版本包” - 这是什么类型的角色 - “通用应用程序”角色?
  • @barakcaf,部署发生在自己的环境中。目前,部署数据库、配置用户、配置链接服务器、集群等项目是自动化的。表模式升级不是自动的。目前正在测试 Liquibase 的数据库迁移,但没有任何自动化。
  • @barakcaf,是的,它是通用应用程序角色。所有组件都在私有 Nuget 存储库中。在我们的 Ansible 项目中存在基线文件。它描述了像component:version这样的键值对,用于升级-下载新版本。此外,所有组件都有配置文件,在升级时根据环境配置和配置模板进行修改。
  • @barakcaf,关于数据库升级的细节我就不详细描述了,因为这将是另外的文章,但是如果你有问题的话..
猜你喜欢
  • 2014-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-22
相关资源
最近更新 更多