Script to clean up Virtual Center database
I was directed to a VMware Knowledge Base article about a script for cleaning up the VC database while upgrading to VC2.5. The company had about 18 months worth of data in their VC SQL database and wanted to preserve some recent historical data, but didn’t need to keep all of it. Purging data helped free disk space and reduce the time the upgrade actually took to complete.
The VMware article links to scripts for both
SQL and Oracle databases. From the KB article:
The scripts attached to this KB article are intended for database administrators (DBAs) that are experienced with using database client tools to execute SQL commands. The purpose of this script is to delete data. You are strongly advised to stop the VirtualCenter Server service and make a full, reliable backup of your database before attempting this process.
These scripts will delete rows, in batches, from designated tables in the VirtualCenter DB. However, by default it will only report how many rows would be deleted. To actually delete data, a configuration parameter within the script must be modified. This is a safety precaution. Please see the comments in the heading of the script for details. Diagnostic messages will be printed that summarize the operations.
The database transaction log may fill up during this procedure if sufficient disk space is not available. For SQL Server, if the required disk space cannot be made available, one option to consider is to utilize the “simple” recovery model on the database for the duration of this operation.
Available disk space on the SQL server is why I found this script. In my scenario the upgrade stalled and failed because we ran out of disk space. After restoring the database from the last night’s backup and then having to reinstall VC 2.0.2 we were ready to upgrade again, but it was definitely an unexpected hour or so of scrambling. Make sure the SQL server has enough free disk space before you upgrade to VC 2.5 regardless if you are purging any old data or not.
Related Posts
-
http://blog.scottlowe.org Scott Lowe
-
http://blog.scottlowe.org Scott Lowe
-
http://vmetc.com rbrambley
-
http://vmetc.com Rich









