Reducing the size of the vCenter Server database when the rollup scripts take a long time to run (1007453)
From: http://kb.vmware.com/selfservice/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1007453
Reducing the size of the vCenter Server database when the rollup scripts take a long time to run (1007453)
Symptoms
- The vCenter Server database is very large (50 GB or more) and the row count in the
VPX_HIST_STATtables is very high (800 million lines or more). - Rollup scripts are running very slowly or may not complete successfully.
- Performance Charts may not display recent data.
- Gaps are appearing in the Performance Charts.
- When this issue is encountered, you may see this message in the Windows Event Viewer on vCenter Server:
Stats insertion failed for entity esxhost.domain.com due to ODBC error
Purpose
Cause
Resolution
VPX_HIST_STAT# table is very high (800 million lines or more), the database rollup scripts may have difficulty handling the amount of data. Rollup scripts run faster if you reduce the size of the vCenter Server database.Before you reduce the size of the vCenter Server database, you may want to defragment the indexes on your Microsoft SQL database server. For more information, see Defragmenting VirtualCenter performance data indexes on a Microsoft SQL database (1003990).
Reducing the size of the vCenter Server database
Note: The below steps are not applicable to vCenter Server 5.1 and 5.5. To truncate performance data on the vCenter Server 5.1 and 5.5 database see the following section, To truncate all performance data from vCenter Server 5.1.
- Ensure that you have a good backup of the vCenter Server database. Do not skip this step.
- Shut down the VMware VirtualCenter Server service and any other services (such as VMware VDI or VMware Lab Manager) that use the database. For more information, see Stopping, starting, or restarting vCenter services (1003895).
Note: Again, ensure that you have a recent backup of the vCenter Server database before continuing. Do not skip this step.
- Truncate the
VPX_HIST_STAT1table and correspondingVPX_SAMPLE_TIME1table. Once the truncate has completed, verify if the rollup jobs are now completing successfully. For more information, see step 4.Warning: The truncate function is destructive. VMware highly recommends that a Database Administrator perform this step.
To truncate the tables, execute these SQL statements:
truncate table VPX_HIST_STAT1;
Note: In vCenter Server 5.1and 5.5, the table name is VPX_HIST_STAT1_n.truncate table VPX_SAMPLE_TIME1;
Note: To reduce the size of vCenter Server Database, you can also delete the data from theVPX_EVENT,VPX_EVENT_ARG, andVPX_TASKtables. To delete the data from these tables, see Purging old data from the database used by vCenter Server (1025914) or Purging old data from the database used by VirtualCenter 2.x (1000125).If the rollup jobs do not complete successfully, it may be necessary to truncate the
VPX_HIST_STAT2table, and the corresponding table,VPX_SAMPLE_TIME2. Continue truncating theVPX_HIST_STAT[1-4]tables and correspondingVPX_SAMPLE_TIME[1-4]tables until the rollup jobs are completing successfully.Note: These additional tables in vCenter Server 4.1 and 5.0 can also be truncated to further reduce the vCenter Server database size. The
VPX_TEMPTABLExtables are a staging/cache area for the performance data before they are processed and moved toVPX_HIST_STAT1.truncate table VPX_TEMPTABLE0;
truncate table VPX_TEMPTABLE1;
truncate table VPX_TEMPTABLE2; - Run the rollup scripts using these steps:
- Using SQL Management Studio, connect to the SQL database for vCenter Server.
- Navigate to SQL Server Agent > Jobs.
- Select the individual rollup jobs, right-click and select Start Job at Step.
- Start the VMware VirtualCenter Server service and any other service service that you stopped in step 2.
Truncating all performance data from vCenter Server 5.1 and 5.5
- Stop the VMware VirtualCenter Server service. For more information, see Stopping, starting, or restarting vCenter services (1003895).
Note: Ensure that you have a recent backup of the vCenter Server database before continuing. Do not skip this step.
- Log in to the vCenter Server database using SQL*Plus (for Oracle) or SQL Management Studio (for SQL Server).
- Copy and paste the contents of the Oracle_truncate_5.x.sql script attached to this article into SQL*Plus. Alternatively, for SQL Server, copy and paste the contents of the SQL_truncate_5.x.sql script into SQL Management Studio.
- Execute the script to delete the data.
- Restart the vCenter Server services.
Additional Information
- For more information about the truncate function, refer to the applicable database vendor documentation or support. Refer to these pages for information which may assist in the process:
- For additional database maintenance:
- Set the vCenter Server database to simple recovery mode
- Shrink log and database files
- Setting the Recovery Model to Simple ensures that the transaction log does not grow to the maximum size.
- For translated versions of this article, see:
Note: The links in this article were correct as of January 25, 2013. If you find a link is broken, provide feedback and a VMware employee will update the link.
Tags
See Also
Update History
03/05/2013 – Added note about the VPX_HIST_STAT1_n table name in vCenter Server 5.1