Wednesday, March 30, 2016

Shrinking the size of the VMware vCenter Server SQL database

Purpose

This article provides the query to shrink the size of the vCenter Server SQL database and transaction logs.
 
You can shrink the size of the SQL database and transaction logs when:
  • The vSphere Client takes a long time to open the vCenter Server connection.
  • vCenter Server service crashes unexpectedly.
  • vCenter Server tasks are very slow to respond.
  • The database server used for vCenter Server has run out of disk space.
  • You see that the SQL VIM_VCDB size is 300% more than the estimated database size.

Resolution

To shrink the size of the vCenter Server SQL database and transaction logs:
  1. Connect to the vCenter Server database using the SQL Management Studio Express as an administrator.
  2. Stop the VMware VirtualCenter Server service.
  3. Take a backup of the vCenter Server database using this query:
    BACKUP DATABASE DatabaseName TO DISK = 'C:\DatabaseName.BAK'
    GO
  4. Right-click the vCenter Server database, click Run Query, and run this query :

    DBCC SHRINKDATABASE ( DatabaseName , 5);GO
  5. Start the VMware VirtualCenter Server service.
Note: When DBCC SHRINKDATABASE is specified with target_percent, the Database Engine calculates the target size to be thetarget_percent amount of space free in the file after shrinking. 
If you are unable to shrink the size of the vCenter Server database (VIM_VCDB) using the SQL Management Studio GUI, you have to run T-SQL scripts.

No comments:

Post a Comment