restoreClusterDatabase 函数 (clusapi.h)
[此函数可用于“要求”部分中指定的操作系统。 Windows Server 2008 中删除了对此函数的支持,此函数不执行任何操作并返回 ERROR_CALL_NOT_IMPLEMENTED。]
还原群集数据库,并在调用函数的节点上重启群集服务。 此节点称为还原节点。
语法
DWORD RestoreClusterDatabase(
[in] LPCWSTR lpszPathName,
[in] BOOL bForce,
[in, optional] LPCWSTR lpszQuorumDriveLetter
);
参数
[in] lpszPathName
以 Null 结尾的 Unicode 字符串,用于指定备份文件的路径。 群集配置信息包含在此位置;这是应保护的敏感数据。 例如,可以使用访问控制列表来保护此数据,以限制对存储数据的位置的访问。
[in] bForce
如果 为 FALSE,则还原操作将不会在下列任一情况下完成:
- 其他节点当前处于活动状态。
- 当前仲裁资源的分区布局与进行备份时就位的仲裁资源的分区布局不同。 (术语“分区布局”是指磁盘上的分区数和每个分区的偏移量。磁盘签名和驱动器号分配不必完全相同。)
[in, optional] lpszQuorumDriveLetter
可选。 标识群集 数据库 将还原到的仲裁资源的驱动器号。 仅当自备份以来已替换仲裁资源时,才使用此参数。 字符串的格式必须如下所示:
- 第一个字符必须按字母顺序排列,即在“a”-“z”或“A”-“Z”范围内。
- 第二个字符必须是冒号 (':') 。
- 第三个字符必须是终止 null ('\0') 。
返回值
如果操作成功,函数将返回 ERROR_SUCCESS。
如果操作失败,该函数将返回 系统错误代码。 下面是可能的错误代码。
返回代码 | 说明 |
---|---|
|
操作失败,因为其他群集节点当前处于活动状态。 如果在 bForce 设置为 TRUE 的情况下再次调用 RestoreClusterDatabase,群集将尝试关闭其他活动节点上的群集服务。 |
|
操作失败,因为备份中所述的仲裁磁盘与当前仲裁磁盘不匹配。 如果在 bForce 设置为 TRUE 的情况下再次调用 RestoreClusterDatabase,群集将尝试将当前仲裁磁盘的签名和驱动器号更改为备份中存储的值。 |
注解
如果还原操作成功,还原节点将根据还原的 群集 数据库中的配置数据形成群集。 当其他节点加入群集时,它们会从还原节点上的数据库更新其群集数据库。
请注意,还原的群集数据库不会识别自备份以来添加或更改的仲裁资源以外的群集 磁盘 ,并且即使还原操作成功,这些磁盘仍将保持 脱机 状态。 必须为这些磁盘创建新 资源 (请参阅 创建物理磁盘资源) 。
对于任何群集还原例程,建议使用以下常规过程:
- 调用 RestoreClusterDatabase 且 bForce 设置为 FALSE 且未指定驱动器号。 这是最佳方法,因为如果成功,操作不必强制更改配置。
-
如果第一次调用失败,让用户决定是强制该过程继续还是手动修复问题。 请务必传达每个决策的含义。
返回值 强制操作 手动修复 ERROR_CLUSTER_NODE_UP 还原操作将停止所有其他节点上的群集服务。 用户手动关闭所有其他群集节点上的群集服务。 命令 Net Stop ClusSvc 已足够;不需要完全关闭电源。 ERROR_QUORUM_DISK_NOT_FOUND 用户必须提供仲裁资源的驱动器号。 还原操作会将磁盘的签名和驱动器号更改为备份中存储的值。 用户对仲裁磁盘进行重新分区,使布局与备份中存储的布局相同。 如果用户同意强制继续,请在 bForce 设置为 TRUE 的情况下调用 RestoreClusterDatabase,并在适用) (指定的驱动器号。 强制并不保证成功。 如果还原操作再次失败,请测试返回值并相应地做出响应。
示例
下面的示例演示了上述过程。 有关包含 BackupClusterDatabase 的更完整示例,请参阅 备份和还原群集配置。 此示例使用故障转移群集文档中定义的 ClusDocEx.h 头文件。
int main( void )
{
WCHAR szPath[] = L"c:\\ClusBack\\19991215";
WCHAR szInput[3];
BOOL bForce = FALSE;
DWORD dwResult = ERROR_SUCCESS;
// First try: no force
dwResult = RestoreClusterDatabase( szPath, FALSE, NULL );
// Allow user to force shutdown if necessary.
if( dwResult == ERROR_CLUSTER_NODE_UP )
{
wprintf( L"The operation failed because other cluster nodes are currently active. " );
wprintf( L"The Cluster service must be shut down on all other nodes in order for this operation to succeed." );
wprintf( L"Enter 'f' to force automatic shutdown, or any other key to exit for manual shutdown: " );
fgetws( szInput, 2, stdin );
if( towupper( szInput[0] ) == L'F' )
dwResult = RestoreClusterDatabase( szPath, TRUE, NULL );
}
// Allow user to locate quorum resource if necessary.
if( dwResult == ERROR_QUORUM_DISK_NOT_FOUND )
{
wprintf( L"\n\nERROR: QUORUM DISK NOT FOUND\n" );
wprintf( L"The restore routine cannot find a quorum resource with the same partition layout as the quorum resource described in the backup. " );
wprintf( L"The existing quorum resource must have a layout (number of partitions and offsets to each partition) identical to the layout stored in the backup.\n" );
wprintf( L"Enter the drive letter of the quorum resource to force continuation, or any non-letter key to exit: " );
fgetws( szInput, 3, stdin );
if( iswalpha( szInput[0] ) )
{
szInput[1] = L':';
szInput[2] = L'\0';
dwResult = RestoreClusterDatabase( szPath, TRUE, szInput );
}
}
// Only one force attempt per error, then report success or failure.
if( dwResult == ERROR_SUCCESS )
{
wprintf( L"\n\nSUCCESS\n" );
wprintf( L"The restore routine succeeded. Start the Cluster service on the other cluster nodes to complete the restore operation." );
wprintf( L"As nodes join the cluster, they will update their cluster databases to match the restored configuration." );
return 0;
}
else
{
wprintf( L"RestoreClusterDatabase failed (%d)\n", dwResult );
return 1;
}
}
要求
要求 | 值 |
---|---|
最低受支持的客户端 | 无受支持的版本 |
最低受支持的服务器 | Windows Server 2003 企业版、Windows Server 2003 Datacenter |
目标平台 | Windows |
标头 | clusapi.h |
Library | ClusAPI.lib |
DLL | ClusAPI.dll |