This article describes how to use PowerShell to replace an Audit instance with zero downtime. For an overview of the process and details for other deployment scenarios, see Replacing an Audit Instance.
Add a new audit instance
First, a new audit instance must be created. If it is on the machine where the existing instance is deployed, different ports must be specified for the new instance.
New-ServiceControlAuditInstance `
-Name Particular.ServiceControl.NewAudit `
-InstallPath C:\ServiceControl.NewAudit\Bin `
-DBPath C:\ServiceControl.NewAudit\DB `
-LogPath C:\ServiceControl.NewAudit\Logs `
-Port 44446 `
-DatabaseMaintenancePort 44447 `
-Transport MSMQ `
-AuditQueue audit `
-AuditRetentionPeriod 10:00:00:00 `
-ForwardAuditMessages:$false `
-ServiceControlQueueAddress "Particular.ServiceControl"
Add the instance to RemoteInstances
The new instance needs to be added to the Error instance's collection of remotes. Execute the following on the machine hosting the ServiceControl Error instance:
Add-ServiceControlRemote `
-Name "Particular.ServiceControl" `
-RemoteInstanceAddress "http://localhost:44446/api"
Disable audit queue ingestion on the old instance
Configure the old audit instance so that it will no longer ingest new messages from the audit queue, making the instance effectively read-only:
- Locate the
ServiceControl.file.Audit. exe. config - In the
appSettingssection, add a setting key forServiceControl/with a value ofIngestAuditMessages false. - Restart the Audit instance for the changes to take effect.
For versions 4.32.0 of ServiceControl and older use !disable as the AuditQueue name to disable the audit message ingestion.
Decommission the old audit instance
When the audit retention period has passed and there are no remaining processed messages in the database, you can decommission the old audit instance.
On the ServiceControl Error instance machine, remove the Audit instance URL from the collection of remote instances:
Remove-ServiceControlRemote `
-Name "Particular.ServiceControl" `
-RemoteInstanceAddress "http://localhost:44444/api"
Then, on the ServiceControl Audit instance machine, remove the Audit instance, including the database and logs.
Remove-ServiceControlAuditInstance `
-Name "Particular.ServiceControl.OriginalAudit" `
-RemoveDB `
-RemoveLogs