如何备份和还原 Service Reporting 数据库

 

发布日期: 2016年3月

适用于: System Center 2012 R2 Service Reporting

System Center 2012 R2 Service Reporting 环境中的数据库如下:

  • UsageDatawarehouseDB

  • UsageETLRepositoryDB

  • UsageStagingDB

  • UsageAnalysisDB

如果承载数据库的计算机出现故障,只需将数据库还原为与初始计算机同名的计算机即可进行恢复。 Service Reporting 数据库的灾难恢复策略应基于一般的 Microsoft SQL Server 灾难恢复步骤。 有关详细信息,请参阅 SQL Server 数据库的备份与还原

备份数据库时,安全信息(如 SQL Server 用户和角色)会与数据库一起备份。 如果用户的域凭据由 SQL Server 用户和角色使用,且它们在你还原到的电脑上存在不同,则必须通过使用已还原数据库的 SQL Server Management Studio 手动更新域凭据。

可在安装 Service Reporting 时将 Service Reporting 数据库还原为可选步骤,也可以通过覆盖当前数据库来还原数据库。 在还原数据库并更新 SQL Server 用户和角色(如有必要)之后,则可注册 Service Reporting 数据源系统(包括 System Center 2012 R2 Operations Manager 和 适用于 Windows Server 的 Windows Azure 包)以重建与数据源系统的连接。

如果要还原 适用于 Windows Server 的 Windows Azure 包 用法数据库,必须确保 Service Reporting 用法数据与 Windows Azure 包 同步。 若要确保两个系统之间的数据同步,请确保执行以下“将已还原的 Windows Azure 包用法数据与 Service Reporting 同步”步骤。

如果需要重新创建 UsageAnalysisDB,你可以使用以下步骤重新运行 PostDeploymentConfig.ps1 Windows PowerShell® 脚本。

若要备份 Service Reporting 数据库

  1. 启动 SQL Server Management Studio,选择要备份的数据库,右键单击该数据库,指向“任务”,然后单击“备份”。

  2. 在“备份数据库”对话框中,选择你的数据库备份选项,然后单击“确定”以备份该数据库。

  3. 备份完成后,单击“确定”以关闭“备份数据库”对话框。

若要还原 Service Reporting 数据库

  • 如果要在安装新 Service Reporting 的过程中还原数据库,请执行在 如何安装 Service Reporting 处安装 Service Reporting 的步骤。 备份数据库是安装的一部分。

  • 如果要还原数据库并覆盖现有数据库,请执行以下步骤:

    1. 启动 SQL Server Management Studio,选择要还原的数据库,右键单击该数据库,依次指向“任务”和“还原”,然后单击“数据库”。

    2. 在“还原数据库”对话框中,选择你的数据库还原选项,然后单击“确定”以还原该数据库。

    3. 还原完成后,单击“确定”以关闭“还原数据库”对话框。

若要使用数据源系统来注册 Service Reporting

若要重新创建 UsageAnalysisDB

  1. 在你想要还原数据库的服务器上,以管理员身份启动 Windows PowerShell。

  2. 浏览至 InstallationDrive:\Program Files\Microsoft System Center 2012 R2\Service Reporting\Maintenance 文件夹。 例如,键入 cd"c:\Program Files\Microsoft System Center 2012 R2\Service Reporting\Maintenance",然后按 Enter。

  3. 键入 .\PostDeploymentConfig.ps1 –User   UserName   -Password Password,并将 UserNamePassword 值替换为用于连接 Windows Azure 包 的凭据。 然后按 Enter。

    如果脚本成功,则会显示 Windows Azure 包 和 Operations Manager 注册的进程以及数据仓库模型的相关信息。 退出 Windows PowerShell。

若要将已还原的 Windows Azure 包 用法数据与 Service Reporting 同步

  1. 停止 Windows Azure 包 用法和 UsageCollector 服务,以防止在故障恢复期间有任何新的用法事件被添加到系统。

  2. 从保存的备份还原 Windows Azure 包 数据。

  3. 通过对 Windows Azure 包 用法数据库运行以下 SQL 查询,记下最近的用法事件 ID。

    SELECT MAX([RecordId])  
    FROM [Microsoft.MgmtSvc.Usage].[usage].[Records]  
    
  4. 通过对 Service Reporting UsageETLRepositoryDB 数据库运行以下 SQL 查询,同步记录的用法事件 ID。

    DECLARE @LastWAPEventId INT = <EventId>  
    DECLARE @CurrEventId INT  
    SELECT  @CurrEventId = InputString  
    FROM    [UsageETLRepositoryDB].[dbo].[ProcessModuleInput]  
    WHERE   InputName = '@StartEventId'  
    
    IF @CurrEventId > @LastWAPEventId  
    BEGIN  
        UPDATE  [UsageETLRepositoryDB].[dbo].[ProcessModuleInput]  
        SET     InputString = @LastWAPEventId  
        WHERE   InputName = '@StartEventId'  
    END  
    

    将上述查询中的 <EventId> 替换为你从步骤 3 中记下的值。

  5. 启动 Windows Azure 包 用法和 UsageCollector 服务。

请参阅

System Center 2012 R2 中的 Service Reporting
操作服务报告