UiPath Documentation
automation-suite
2.2510
true
Linux 版 Automation Suite 安装指南
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

执行数据库维护

执行例行数据库维护操作,保持 Automation Suite 数据库的整洁。

保持数据库整洁有序,这一点很重要。 为此,我们建议执行以下操作:

使用 SQL Server 维护解决方案

SQL Server 维护解决方案是一组脚本,让您可以从 2005 版本开始在所有版本的 Microsoft SQL Server 上运行备份、完整性检查以及索引和统计信息维护。有关详细信息,请参阅此 GitHub 项目

备份数据库

我们建议对 SQL Server 数据库实施定期备份,例如每周完整备份或每日增量备份。

此外,我们建议您使用在该位置使用脚本创建的 DatabaseBackup 存储程序。

定期删除旧数据

共享的 Suite 功能

在删除项目之前,创建一个单独的数据库来保存项目。此数据库充当因某些原因(例如审核)可能需要存储的项目的存档。

  1. 创建一个新的调用数据库,例如 UiPathArchives

    create database UiPathArchives
    create database UiPathArchives
    
  2. 创建以下备份表:

    ArchiveAuditEvent,其结构与 AuditEvent 表相同:

    SELECT * INTO [UiPathArchives].[dbo].[ArchiveAuditEvent] from [AutomationSuite_Platform].[adt].[AuditEvent] where 1 = 2
    SELECT * INTO [UiPathArchives].[dbo].[ArchiveAuditEvent] from [AutomationSuite_Platform].[adt].[AuditEvent] where 1 = 2
    
  3. 将数据存档。

    要将审核事件记录存档,请使用以下示例脚本:

       DECLARE @NumberOfDaysToKeep INT
       DECLARE @CurrentDate DATETIME
    
       -- Specify the number of days
       SET @NumberOfDaysToKeep = 60
       -- Archive the list of audit event records that you want to delete
       SET @CurrentDate = GetDate()
       BEGIN TRANSACTION
       INSERT INTO [UiPathArchives].[dbo].[ArchiveAuditEvent]
       SELECT
       [Id],[CreatedOn],[Version],[OrganizationId],[Source],[Category],[Action],[IsUserEvent],
       [UserId],[FullName],[Email],[DetailsVersion],[Details],[OperationId]
       FROM [adt].[AuditEvent]
       WHERE DateDiff(day, CreatedOn, @CurrentDate) > @NumberOfDaysToKeep
       -- Delete the audit events
       DELETE FROM [adt].[AuditEvent]
       WHERE EXISTS (SELECT 1 FROM [UiPathArchives].[dbo].[ArchiveAuditEvent] WHERE Id = [adt].[AuditEvent].[Id])
       COMMIT TRANSACTION
       DECLARE @NumberOfDaysToKeep INT
       DECLARE @CurrentDate DATETIME
    
       -- Specify the number of days
       SET @NumberOfDaysToKeep = 60
       -- Archive the list of audit event records that you want to delete
       SET @CurrentDate = GetDate()
       BEGIN TRANSACTION
       INSERT INTO [UiPathArchives].[dbo].[ArchiveAuditEvent]
       SELECT
       [Id],[CreatedOn],[Version],[OrganizationId],[Source],[Category],[Action],[IsUserEvent],
       [UserId],[FullName],[Email],[DetailsVersion],[Details],[OperationId]
       FROM [adt].[AuditEvent]
       WHERE DateDiff(day, CreatedOn, @CurrentDate) > @NumberOfDaysToKeep
       -- Delete the audit events
       DELETE FROM [adt].[AuditEvent]
       WHERE EXISTS (SELECT 1 FROM [UiPathArchives].[dbo].[ArchiveAuditEvent] WHERE Id = [adt].[AuditEvent].[Id])
       COMMIT TRANSACTION
    

    使用以下查询时,在删除旧数据之前,会将旧数据先复制到这些档案中。

  4. 删除表格中的数据。

    重要提示:

    在运行以下脚本之前,请确保使它们适应您的环境。

    审核事件:

       declare @NumberOfDaysToKeep int
       declare @CurrentDate datetime
    
       -- Specify the number of days
       SET @NumberOfDaysToKeep = 60
       -- Create temporary table with the list of audit event records that you want to delete
       SET @CurrentDate = GetDate()
       SELECT
       [Id],[CreatedOn],[Version],[OrganizationId],[Source],[Category],[Action],[IsUserEvent],
       [UserId],[FullName],[Email],[DetailsVersion],[Details],[OperationId]
       INTO #TempAuditRecordsToDelete
       FROM [adt].[AuditEvent]
       WHERE DateDiff(day, CreatedOn, @CurrentDate) > @NumberOfDaysToKeep
       -- Review the audit event records to be deleted
       SELECT * FROM #TempAuditRecordsToDelete
       -- Delete the audit events
       BEGIN TRANSACTION
       DELETE FROM [adt].[AuditEvent]
       WHERE EXISTS (SELECT 1 FROM #TempAuditRecordsToDelete WHERE Id = [adt].[AuditEvent].[Id])
       DROP TABLE #TempAuditRecordsToDelete
       COMMIT TRANSACTION
       declare @NumberOfDaysToKeep int
       declare @CurrentDate datetime
    
       -- Specify the number of days
       SET @NumberOfDaysToKeep = 60
       -- Create temporary table with the list of audit event records that you want to delete
       SET @CurrentDate = GetDate()
       SELECT
       [Id],[CreatedOn],[Version],[OrganizationId],[Source],[Category],[Action],[IsUserEvent],
       [UserId],[FullName],[Email],[DetailsVersion],[Details],[OperationId]
       INTO #TempAuditRecordsToDelete
       FROM [adt].[AuditEvent]
       WHERE DateDiff(day, CreatedOn, @CurrentDate) > @NumberOfDaysToKeep
       -- Review the audit event records to be deleted
       SELECT * FROM #TempAuditRecordsToDelete
       -- Delete the audit events
       BEGIN TRANSACTION
       DELETE FROM [adt].[AuditEvent]
       WHERE EXISTS (SELECT 1 FROM #TempAuditRecordsToDelete WHERE Id = [adt].[AuditEvent].[Id])
       DROP TABLE #TempAuditRecordsToDelete
       COMMIT TRANSACTION
    

身份服务器

在删除项目之前,创建一个单独的数据库来保存项目。此数据库充当因某些原因(例如审核)可能需要存储的项目的存档。

备注:

仅在使用 SQL Server 内部部署 SQL 时才支持本节中提供的数据库维护脚本。它不适用于 Azure SQL。如果您的 Automation Suite 部署使用 Azure SQL,请不要运行此脚本。

  1. 创建一个新的调用数据库,例如 UiPathIdentityArchives

    create database UiPathIdentityArchives
    create database UiPathIdentityArchives
    
  2. 创建以下备份表:

    ArchiveLoginAttempts,其结构与 UserLoginAttempts 表相同:

    select * into [UiPathIdentityArchives].[dbo].[ArchiveUserLoginAttempts] from [AutomationSuite_Platform].[identity].[UserLoginAttempts] where 1=2
    select * into [UiPathIdentityArchives].[dbo].[ArchiveUserLoginAttempts] from [AutomationSuite_Platform].[identity].[UserLoginAttempts] where 1=2
    

    使用以下查询时,在删除旧数据之前,会将旧数据先复制到这些档案中。

  3. 删除表格中的数据。

    重要提示:

    在运行以下脚本之前,请确保使它们适应您的环境。

    例如,要删除超过 60 天的登录尝试,请使用以下查询。它可以手动执行,也可以在 SQL Server 作业中计划。

       declare @NumberOfDaysToKeep int
       set @NumberOfDaysToKeep = 60
       if OBJECT_ID('[UiPathIdentityArchives].[dbo].[UserLoginAttemps]') = NULL 
         begin select * into [UiPathIdentityArchives].[dbo].[UserLoginAttemps] from [identity].UserLoginAttempts where 1=2 end
       begin transaction
         set identity_insert [UiPathIdentityArchives].[dbo].[UserLoginAttemps] on
         insert into [UiPathIdentityArchives].[dbo].[UserLoginAttemps] ([Id],[PartitionId],[UserId],[UserNameOrEmailAddress],[ClientIpAddress],[ClientName],[BrowserInfo],[Result],[CreationTime],[AuthenticationProvider],[PartitionName])
           select [Id],[PartitionId],[UserId],[UserNameOrEmailAddress],[ClientIpAddress],[ClientName],[BrowserInfo],[Result],[CreationTime],[AuthenticationProvider],[PartitionName]
             from [identity].UserLoginAttempts where DateDiff(day, CreationTime, GetDate()) > @NumberOfDaysToKeep
         delete from [identity].UserLoginAttempts where DateDiff(day, CreationTime, GetDate()) > @NumberOfDaysToKeep
       commit transaction
       declare @NumberOfDaysToKeep int
       set @NumberOfDaysToKeep = 60
       if OBJECT_ID('[UiPathIdentityArchives].[dbo].[UserLoginAttemps]') = NULL 
         begin select * into [UiPathIdentityArchives].[dbo].[UserLoginAttemps] from [identity].UserLoginAttempts where 1=2 end
       begin transaction
         set identity_insert [UiPathIdentityArchives].[dbo].[UserLoginAttemps] on
         insert into [UiPathIdentityArchives].[dbo].[UserLoginAttemps] ([Id],[PartitionId],[UserId],[UserNameOrEmailAddress],[ClientIpAddress],[ClientName],[BrowserInfo],[Result],[CreationTime],[AuthenticationProvider],[PartitionName])
           select [Id],[PartitionId],[UserId],[UserNameOrEmailAddress],[ClientIpAddress],[ClientName],[BrowserInfo],[Result],[CreationTime],[AuthenticationProvider],[PartitionName]
             from [identity].UserLoginAttempts where DateDiff(day, CreationTime, GetDate()) > @NumberOfDaysToKeep
         delete from [identity].UserLoginAttempts where DateDiff(day, CreationTime, GetDate()) > @NumberOfDaysToKeep
       commit transaction
    

Orchestrator

有关如何定期删除 Orchestrator 数据库中旧数据的详细信息,请参阅清理 Orchestrator 数据库

Automation Hub

Automation Hub 依赖其运行时视图和仪表板的历史数据,并且由于其性质,它没有清理旧数据的概念。 与其他服务类似,建议通过每周完整备份或每日增量备份等方法定期备份 Automation Hub 数据库。

Process Mining

Automation Suite 上的 Process Mining 提供内置的自动数据库清理功能,可确保实现最佳效率和性能。这可确保定期删除不必要的数据,从而保持数据库清理并正常运行,而无需执行任何手动操作来释放资源。

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新