当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何在 Exchange Server 上启用维护模式

作者:精品下载站 日期:2024-12-14 23:34:45 浏览:15 分类:玩电脑

如何在 Exchange Server 上启用维护模式


在本文中,我们将向您展示如何正确地将 Exchange Server 2019/2016 主机置于维护模式。如果要在 Exchange Server 主机上安装更新(Windows 更新或 Exchange CU)或维护服务器硬件,则必须将数据库可用性组 (DAG) 置于维护模式。启用维护模式时,必须将活动数据库移出 Exchange 服务器并将队列切换到其他服务器。

Exchange Server 有两个内置的 PowerShell 脚本用于管理维护模式:

  • StartDagServerMaintenance.ps1 - 允许将活动数据库和主活动管理器 (PAM) 角色移动到另一台服务器,并阻止邮箱数据库的反向迁移,直到维护结束;

  • StopDagServerMaintenance.ps1 - 允许您通过执行相反的过程使 Exchange 服务器退出维护模式。

这些脚本位于 Scripts 文件夹 (

CD $ExScripts

) Exchange 安装目录。使用以下语法:

.\StartDagServerMaintenance.ps1 -ServerName <ServerName> -MoveComment Maintenance -PauseClusterNode
.\StopDagServerMaintenance.ps1 -serverName <ServerName>

这些脚本使您能够自动执行某些操作。在大多数情况下,Exchange 管理员更喜欢手动将服务器置于维护模式。

有一个 PowerShell 脚本示例,您可以使用它来启用 Exchange 服务器的维护模式。在安装了 Exchange 命令行管理程序和 RSAT 群集模块的计算机上运行命令:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
Import-Module FailoverClusters

或者您可以使用 PowerShell 远程连接到 Exchange Server:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://munexh01.a-d.site/PowerShell/ -Authentication Kerberos -Credential (Get-Credential)
Import-PSSession $Session

设置 Exchange 服务器的名称:

# a server that you want to enable the maintenance mode for
$maintance_srv = "munexh01.a-d.site"
# a target server you want to move mail queues to
$target_srv = "munexh02.a-d.site"
# Disable the HubTransport component of the server and put it into Draining mode
Set-ServerComponentState $maintance_srv -Component HubTransport -State Draining -Requester Maintenance
Restart-Service MSExchangeTransport
# Check that the HubTransport status has changed to Draining
Get-ServerComponentState -Identity $maintance_srv -Component Hubtransport

[玩转系统] 如何在 Exchange Server 上启用维护模式

如果你跑

Get-ServerComponentState -Identity $maintance_srv

现在,所有 Exchange 组件(Monitoring 和 RecoveryActionsEnabled 除外)都将处于非活动状态。

# Move mail queue to another server
Redirect-Message -Server $maintance_srv -Target $target_srv
# Make sure that the mail queue have been cleared:
Get-Queue
# Pause your cluster node. This will move the Primary Active Manager (PAM) role to another DAG host
Suspend-ClusterNode -Name $maintance_srv
# Move all the mounted copies of mailbox databases to other servers
Set-MailboxServer $maintance_srv -DatabaseCopyActivationDisabledAndMoveNow $true
# Prevent a database activation on the server
Set-MailboxServer $maintance_srv -DatabaseCopyAutoActivationPolicy Blocked

等待邮箱数据库成功移动到另一台主机(这将需要几分钟)。确保服务器上已安装的数据库列表为空:

Get-MailboxDatabaseCopyStatus -Server $maintance_srv | where {$_.Status -like "Mounted"}
# Put Exchange components into maintenance mode
Set-ServerComponentState $maintance_srv -Component ServerWideOffline -State InActive -Requester Maintenance
# Check if the server is in maintenance mode
Get-ServerComponentState -Identity $maintance_srv -Component ServerWideOffline
Get-MailboxDatabaseCopyStatus

现在您可以完成所需的 Exchange 主机的维护过程。在服务器上完成所有操作后,您需要执行相反的步骤以使 Exchange Server 主机退出维护模式:

Set-ServerComponentState $maintance_srv -Component ServerWideOffline -State Active -Requester Maintenance
# You may check the status as shown below (it must change to Active):
Get-ServerComponentState $maintance_srv -Component ServerWideOffline

[玩转系统] 如何在 Exchange Server 上启用维护模式

Resume-ClusterNode -Name $maintance_srv
Set-MailboxServer $maintance_srv -DatabaseCopyAutoActivationPolicy Unrestricted
Set-MailboxServer $maintance_srv -DatabaseCopyActivationDisabledAndMoveNow $false
Set-ServerComponentState $maintance_srv -Component HubTransport -State Active -Requester Maintenance

检查 Exchange 服务器状态:

Test-ServiceHealth $maintance_srv

使用 RedistributeActiveDatabases.ps1 根据配置的激活首选项在 DAG 主机之间重新平衡活动邮箱数据库:

cd $exscripts
.\RedistributeActiveDatabases.ps1 -DagName mun-dag -BalanceDbsByActivationPreference

如果要将邮箱数据库的所有活动副本从一台服务器移动到另一台服务器,请运行以下命令:

Move-ActiveMailboxDatabase -Server $target_srv -ActivateOnServer $maintance_srv -Confirm:$false

执行 MAPI 可用性检查:

Test-MAPIConnectivity -Server $maintance_srv

检查 DAG 中的数据库状态和复制:

Get-MailboxDatabaseCopyStatus
Test-ReplicationHealth -DatabaseAvailabilityGroup

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯