Shrinking the size of the VMware vCenter Server SQL database
search cancel

Shrinking the size of the VMware vCenter Server SQL database

book

Article ID: 304613

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

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.


Environment

VMware vCenter Server 4.0.x
VMware vCenter Server 5.1.x
VMware vCenter Server 6.5.x
VMware vCenter Server 4.1.x
VMware vCenter Server 5.0.x
VMware vCenter Server 5.5.x
VMware vCenter Server 6.7.x
VMware VirtualCenter 2.5.x
VMware vCenter Server 6.0.x

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 the target_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.

 
 


Additional Information

For more information on using DBCC SHRINKDATABASE, see the Microsoft Knowledge Base article190488

Note: The preceding link was correct as of July 21, 2014. If you find the link is broken, provide feedback and a VMware employee will update the link.

To check the status of the
database shrink, run this query:
 
SELECT percent_complete, start_time, status, command, estimated_completion_time, cpu_time, total_elapsed_time, * FROM sys.dm_exec_requests
Investigating the health of a vCenter Server database
Reducing the size of the vCenter Server database when the rollup scripts take a long time to run
Purging old data from the database used by vCenter Server
Determining where growth is occurring in the vCenter Server database
VMware vCenter Server の SQL データベースのサイズを縮小する
收缩 VMware vCenter Server SQL 数据库的大小