Wednesday, October 22, 2014

Purge vCenter database

In my dev lab, vCenter is heavily used by developers to building up software, testing and running automation all the time. The vCenter database by default keeps 180 day worth of events and tasks. With a lot of activities in a small, default 10 GB size of database, it is eventually full in a few months. The symptom is that vCenter operations would start but fail in the Tasks & Events. Or your vCenter client is disconnected from vCenter constantly.

If the vCenter is installed on a Windows server, a MSSQL event similar to the following would show up in the Event Viewer / Windows Logs / Application:


To purge vCenter database (SQL), open the vCenter database (VIM_VCDB) by using SQL Management Studio. By inspecting the database properties, the Space Avaiable may only have several MB left. Since it's a dev lab, there's no need of keeping 180 day worth of events and tasks. I shrinked it down to 30 day by:

  1. Go to VIM_VCDB > Tables
  2. Right click the dbo.VPX_PARAMETER table and Edit Top 200 Rows
  3. Modify event.maxAgeEnabled to true
  4. Modify event.maxAge to 30
  5. Modify task.maxAgeEnabled to true
  6. Modify task.maxAge to 30
  7. Go to VIM_VCDB > Programmability > Stored Procedures and right click dbo.cleanup_events_tasks_proc and select Execute Stored Procedure

Depending on your environment, it took about 40 minutes to free up 4.6 GB (150 day worth of task and event) in the database. After cleanup, the database Space Available would show more available space:


After free up the vCenter database, all vCenter operations are back to normal. This is the VMware KB link with more details.

No comments:

Post a Comment