Knowledge Base

The VMware Knowledge Base provides support solutions, error messages and troubleshooting guides
 
Search the VMware Knowledge Base (KB)   View by Article ID
 

Purging old data from the database used by vCenter Server

Symptoms

vCenter Server stores performance data in the vCenter Server database. Over time, data collection results in growth of the database files and a mechanism is needed to shrink these files.For more information on shrinking databases, see:

vCenter Server has a Database Retention Policy setting that allows you to specify when vCenter Server tasks and events should be deleted. Since this setting does not affect performance data records it is still possible to purge or shrink old records from the database using the scripts attached to this article. To access the Database Retention Policy setting in the vSphere Client, click Administration > vCenter Server Settings > Database Retention Policy. 

The scripts attached to this article support purging the performance data from vCenter Server.
 
Caution: Do not run the scripts attached to this article against a VirtualCenter 2.x database. For information about purging data in VirtualCenter 2.x, see Purging old data from the database used by VirtualCenter Server 2.x (1000125).
 
Note: SQL Express 2005/2008 (vCenter Server 5.0 has SQL Express 2008 as the bundled edition) supports a maximum of 5 hosts and 50 virtual machines. If your environment exceeds this threshold, you must upgrade your database to SQL Standard.

Resolution

 
Note: This video was originally created for Purging old data from the database used by VirtualCenter Server 2.x (1000125). However, the steps can be used for this article as well.
 
Caution: The scripts attached to this article are intended for execution by database administrators (DBAs) who are experienced with using database client tools to execute SQL commands. The purpose of the scripts is to delete data. VMware strongly recommends that you stop the vCenter Server service and make a full, reliable backup of your database before attempting this process.

Note: If you are using SQL 2005 Express, you may need to download and install Microsoft SQL Server Management Studio Express.

These scripts delete rows, in batches, from designated tables in the vCenter Server database. However, by default it only reports how many rows are 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 are 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 is to utilize the “simple” recovery model on the database for the duration of this operation.

Warning: The VirtualCenter Server service must be stopped while the script is running. For more information, see Stopping, starting, or restarting vCenter services (1003895).
 
Notes:
  • If the database is very large it may take a very long time to run this script. Running the script in increments by changing the default cut off days of 180 which represents 6 months, you can increase this to a larger value like 330 at first and this will purge only one month of data. You can then run the script with cut off date set to 300 to purge another month of data.
  • If the scripts fail to run because a lack of available database space, you may need to truncate your performance data. If you want to truncate all performance data instead of purging it, see Reducing the size of the VirtualCenter database when the rollup scripts take a long time to run (1007453).
  • If the DB has reached a 4GB limit in SQL express, if the DB is corrupted, or if vCenter is unavailable for any reason, purge the event and event_arg tables either by manually enabling the DB retention policy in the DB using SQL Studio, or by running the stored procedure to purge the data from these tables
    • To enable the database retention policy for the events and tasks, Open table dbo.VPX_PARAMETER:
      • Modify event.maxAge to a value in days.
      • Modify event.maxAgeEnabled to value of true.
      • Modify task.maxAge to a value in days.
      • Modify task.maxAgeEnabled to a value of true
    • Run the built in stored procedure: from the VCDB > Programmability > Stored Procedures > Right-Click dbo.cleanup_events_tasks_proc and click execute. This purges the data from tables: vpx_event, vpx_event_arg and vpx_task based on the date specified for maxAge
To ensure that the default Statistics Level is set to 1:
  1. Using the vSphere Client, log in to vCenter Server as an administrator.
  2. Navigate to Administrator > vCenter Server Settings > Statistics.
  3. Under Statistics Intervals, ensure the Statistics Level column is set to 1.
  4. To change the value, select the Interval Duration, click Edit and select Level 1 from dropdown.

Additional Information

For IBM DB2 database, see Reorganizing the database. Engage your database administrator to perform any required actions.
 
For further assistance, file a support request with VMware Support and note this KB Article ID in the problem description. For more information, see How to Submit a Support Request.

Note: When the vCenter Database has been purged, you may notice an improvement in the performance of the vSphere Client connected to the vCenter Server.

Tags

vcenter-purge-scripts vCenter-Database-Health

See Also

Update History

29/09/2011 - Added VC 5.0 updates 05/06/2011 - Added warning about SQL Express 2005 supportability.

Attachments

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback


Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.
What can we do to improve this information? (4000 or fewer characters)
Actions