Archive and Purge a Database
This section describes how to archive and purge a monitoring store (default name of ApplicationServerMonitoring), or merely purge a persistence store (default name of ApplicationServerPersistence), in Windows Server AppFabric. As a monitoring or persistence store grows in size, it can accumulate lots of data. To maintain top performance, you will want to archive the older monitoring data based upon certain criteria, or purge any stale instance persistence data from the AppFabric monitoring and persistence stores, respectively.
With AppFabric, you can only archive and purge a store by using the Windows PowerShell cmdlets that ship with AppFabric specifically designed for this task. Archived data applies only in the context of the monitoring store. It makes sense to archive monitoring data because it is historical in nature and the AppFabric Dashboard displays historical monitoring metrics in the WCF Call History section/Tracked Events page, and the WF Instance History section/Tracked WF Instances page. However, the metrics displayed in the Persisted WF Instances section/Persisted WF Instances page are real-time live data for current persisted workflow instances. To archive persisted workflow instance information, and then view it at a later point in time when possibly these workflow instances have completed and no longer exist, will not provide you with very useful information. Therefore, all the archive-related cmdlets apply only to the monitoring store. Purging cmdlet capabilities apply to both the monitoring and persistence stores. The AppFabric automatic data store purge feature can be used only for AppFabric installations configured to use Microsoft SQL Server to store its monitoring. The monitoring store is the only AppFabric database for which the automatic purge functionality exists. It cannot be configured to use with the persistence store.
Cmdlets for Purging and Archiving a Database
The following AppFabric cmdlets for Windows PowerShell are used to perform various tasks associated with purging and archiving the AppFabric stores.
Cmdlet | Description |
---|---|
Clear-ASMonitoringSqlDatabase |
Purges data from a monitoring database. Optionally, the purged data can be sent to an archive database. |
Set-ASMonitoringSqlDatabaseArchiveConfiguration |
Associates a monitoring database with a destination archive database. The destination archive database must be a pre-existing, initialized monitoring database. |
Get-ASMonitoringSqlDatabaseArchiveConfiguration |
Returns the archive configuration (essentially, the connection string that identifies the archive destination database), if any, from the specified monitoring database. |
Remove-ASMonitoringSqlDatabaseArchiveConfiguration |
Removes configuration information about a monitoring database’s archive database. This assumes that the archive configuration was previously configured by using Set-ASMonitoringSqlDatabaseArchiveConfiguration. |
Remove-ASAppServiceInstance |
Purges “stale” instance data from the persistence store. There is no archive option for purged instance data. |
In the following sections each of these cmdlets is described in greater detail and an example is given to show how the cmdlet is used.
Set, Get, and Remove the Monitoring Store Configuration
Set-ASMonitoringSqlDatabaseArchiveConfiguration configures a given monitoring database with an associated archive destination database. The archive destination database must be an existing, initialized monitoring database. This cmdlet ensures that the primary and archive databases both contain monitoring database artifacts, and that their versions match.
Get-ASMonitoringSqlDatabaseArchiveConfiguration retrieves the archive database configuration from a monitoring database.
Remove-ASMonitoringSqlDatabaseArchiveConfiguration removes configuration information about a monitoring database’s archive database.
Set-ASMonitoringSqlDatabaseArchiveConfiguration
Syntax 1:
Set-ASMonitoringSqlDatabaseArchiveConfiguration -ArchiveDatabase <String> -Database <String> [-Confirm] [-LinkedArchiveServer <String>] [-Server <String>] [-WhatIf] [<CommonParameters>]
Syntax 2:
Set-ASMonitoringSqlDatabaseArchiveConfiguration -ArchiveDatabase <String> -ConnectionString <String> [-Confirm] [-LinkedArchiveServer <String>] [-WhatIf] [<CommonParameters>]
Parameter | Description |
---|---|
ArchiveDatabase |
Name of the destination archive database. |
Database |
Name of the primary database for which to configure archiving. Optional only if ConnectionString is specified. |
ConnectionString |
Connection string for the primary monitoring database. |
LinkedArchiveServer |
Name of the SQL Server that hosts the destination archive database. |
Server |
Name of the SQL Server that hosts the primary monitoring database. |
WhatIf |
Connects to the databases but does not actually configure archiving. Optional. |
Example
The following example sets the archive configuration for the primary monitoring database ApplicationServerMonitoring. The destination archive database is ArchiveMonitoringDatabase. The user will be prompted to confirm the operation before the archiving configuration is set.
Set-ASMonitoringSqlDatabaseArchiveConfiguration –ArchiveDatabase ArchiveMonitoringDatabase –Database ApplicationServerMonitoring
Get-ASMonitoringSqlDatabaseArchiveConfiguration
Syntax 1:
Get-ASMonitoringSqlDatabaseArchiveConfiguration -Database <String> [-Server <String>] [<CommonParameters>]
Syntax 2:
Get-ASMonitoringSqlDatabaseArchiveConfiguration -ConnectionString <String> [<CommonParameters>]
Parameter | Description |
---|---|
Database |
Name of the primary database whose archive configuration you want to retrieve. Optional only if a connection string is specified. |
Server |
The name of the SQL Server that hosts the primary monitoring database. Optional, so if not specified this parameter defaults to the local computer. |
ConnectionString |
Connection string to the primary monitoring database. Optional only if Database is specified and Server is specified or defaulted to the local computer. |
Remove-ASMonitoringSqlDatabaseArchiveConfiguration
Syntax 1:
Remove-MonitoringDatabaseArchiveConfiguration [-Database <String>] [–Server <String>] [-Confirm <Switch>][-ConnectionString<String>]
Parameter | Description |
---|---|
Database |
Name of the primary database whose archive configuration you want to retrieve. Optional only if a connection string is specified. |
Server |
The name of the SQL Server that hosts the primary monitoring database. Optional, so if not specified this parameter defaults to the local computer. |
Confirm |
When specified, users must confirm the removal of the link. |
ConnectionString |
Connection string to the primary monitoring database. Optional only if the Database parameter is specified and Server is specified or defaulted to the local computer. |
Example
The following example removes the archive configuration for the primary monitoring database ApplicationServerMonitoring.
Remove-MonitoringDatabaseArchiveConfiguration –Database “ApplicationServerMonitoring”
Purging and Archiving a Monitoring Store
You use the Clear-ASMonitoringSqlDatabase cmdlet to purge data from the monitoring database, and optionally, you can direct the purged data to a remote archive destination monitoring database.
Clear-ASMonitoringSqlDatabase
Syntax 1:
Clear-ASMonitoringSqlDatabase -Database <String> [-Archive] [-CutoffTime <DateTime>] [-MaxAge <TimeSpan>] [-PurgeMode {<EventAgeMode | None | WFInstanceCompletedMode}] [-Server <String>] [<CommonParameters> [-WhatIf]]
Syntax 2:
Clear-ASMonitoringSqlDatabase -ConnectionString <String> [-Archive] [-CutoffTime <DateTime>] [-MaxAge <TimeSpan>] [-PurgeMode {<EventAgeMode | None | WFInstanceCompletedMode>}] [-WhatIf] [<CommonParameters>]
Parameter | Description |
---|---|
Database |
Name of the database to purge. Optional only if a ConnectionString is specified. |
ConnectionString |
Connection string to the database to purge. Optional if Database and Server are specified. |
Archive |
Data to be purged will first be archived to the pre-configured (using Set-ASMonitoringSqlDatabaseArchiveConfiguration) archive database. Optional. |
CutoffTime |
All events in the database that were emitted before the cutoff time will be purged. When in WFInstanceCompletedMode, WF events related to active instances will be preserved. This parameter is optional and when not specified its value is calculated by taking the current time and subtracting the MaxAge parameter. |
MaxAge |
The amount of time that an event has been in a monitoring database before it is eligible for a time-based purge. This parameter is optional and defaults to 0. |
PurgeMode |
Determines how purging will be done. There are two options:
|
Server |
Name of the server that hosts the database to be purged. Optional; if not provided defaults to the local server. |
Example
This is a simple example that shows how to archive and purge events related to completed instances. This example will purge the ContosoDatabase monitoring database located on the local server.
Clear-ASMonitoringSqlDatabase –Database “ContosoDatabase” –PurgeMode “WFInstanceCompletedMode” –Archive
Purging Stale Instances from a Persistence Store
Instances of services that are removed from all computers in a Web farm may still remain in the persistence store and result in noise in persistence store queries. If a computer is removed from the network, a persisted instance linked to that removed computer remains as a stale instance in the persistence store. The Remove-ASAppServiceInstance cmdlet provides the ability to clean up such stale instances.
Remove-ASAppServiceInstance
Syntax 1:
Remove-ASAppServiceInstance -Database <String> -InstanceId <Guid> [-Confirm] [-Force] [-Server <String>] [-WhatIf] [<CommonParameters>]
Syntax 2:
Remove-ASAppServiceInstance -ConnectionString <String> [-Confirm] [-Force] [-WhatIf] [<CommonParameters>]
Syntax 3:
Remove-ASAppServiceInstance -ServiceInstanceInfo <InstanceInfo> [-Confirm] [-Force] [-WhatIf] [<CommonParameters>]
Parameter | Description |
---|---|
Database |
Name of the persistence store to be purged. Required unless ConnectionString is specified. |
InstanceId |
Service instance ID in the form of a GUID. |
Confirm |
Requires the user to confirm the operation before service instances are purged. Not to be used with Force. |
Force |
Forces the operation without user confirmation. Not to be used with Confirm. |
Server |
Name of the SQL Server that hosts the Database. Optional, defaults to the local server. |
WhatIf |
Connects to the store but does not actually purge service instance data. |
ConnectionString |
Connection string to the persistence store to purge. Optional, can be used in place of Database and Server. |
ServiceInstanceInfo |