CVAD - How to create Monitor and Config Logging Database using powershell
book
Article ID: CTX324187
calendar_today
Updated On:
Description
This article outlines steps required to create Monitor and Config Logging database when we have lost access to them and there is no way to restore .
Instructions
Monitor DB: 1. On the SQL Server, Create an empty database Named "MonitorDB" with the collation mentioned in
https://docs.citrix.com/en-us/citrix-virtual-apps-desktops/technical-overview/databases.html 2. Run the below cmdlets in PowerShell on the DDC
- Asnp citrix*
- Get-MonitorDBSchema -DatabaseName MonitorDBNew -ServiceGroupName MyServiceGroup -DataStore Monitor >C:\Script\Mondb.sql
In the above cmdlet,
- MonitorDBNew is the pre-created DB on SQL server
- MyServiceGroup is the Site Name (This can be obtained by running Get-BrokerSite with the field Name )
- Monitor is the Monitor database schema type and it needs to be used as is in the above command
- A .sql file will be created inside C:\Scripts\ named Mondb
3. On SQL Server -
- Copy the Mondb.sql file from the DDC to the SQL server
- Right client on the newly created Monitor DB(MonitorDBNew) > Select new query > Click on Query on the Taskbar > select SQLCMD mode
- Edit the Mondb.sql, copy the complete script into the SQLCMD query window, and execute
Note: This will create the required schema, table, etc inside the DB named "MonitorDBNew"
4. Run the following PowerShell cmdlets on the DDC to point the secondary datastore to the newly created database
- Set-MonitorDBConnection -DataStore Monitor -DBConnection $null
- Set-MonitorDBConnection -DataStore Monitor -DBConnection "Server=SQLServerHostName;Initial Catalog=MonitorDBNew;Integrated Security=True"
Logging DB:1. On SQL Server, Create an empty database Named "LoggingDB" with the collation mentioned in
https://docs.citrix.com/en-us/citrix-virtual-apps-desktops/technical-overview/databases.html
2. Run the Below command in PowerShell on the DDC
- asnp citrix*
- Get-LogDBSchema -DatabaseName LoggingDBNew -ServiceGroupName MyServiceGroup -DataStore Logging >C:\Script\Logdb.sql
In the above cmdlet,
- LoggingDBNew is the pre-created DB on SQL server .
- MyServiceGroup is the Site Name ( Can be obtained by running Get-BrokerSite with the field Name )
- Logging is the ConfigLogging database schema type and it needs to be used as is in the above cmdlet.
- A .sql file will be created inside C:\Scripts\ named Logdb
3. On SQL Server -
- Copy the Logdb.sql file from the DDC to the SQL server
- Right client on the newly created Logging DB(LoggingDBNew ) > Select new query > Click on Query on the Taskbar > select SQLCMD mode
- Edit the Logdb.sql, copy the complete script into the SQLCMD query window, and execute
Note - This will create the required schema, table,etc inside the DB named "LoggingDB"
4. Run the following PowerShell cmdlets to point the secondary datastore to the newly created database
- Set-LogDBConnection -DataStore Logging -DBConnection $null
- Set-LogDBConnection -DataStore Logging -DBConnection "Server=SQLServerHostName;Initial Catalog=LoggingDBNew;Integrated Security=True"
Note: Resetting the Monitor and Logging strings(Step 4 in Monitor DB and Logging DB sections) would be required on all the DDCs on the site.
Environment
The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.
Was this article helpful?
thumb_up
Yes
thumb_down
No