
Reducing the vCenter DB Size
This document will be useful in reducing the size of our VMware vCenter database, it will also be necessary when it reaches the limits if we have it in a SQL Express, since the services will not start and therefore we will have errors in the registry that will indicate it to us.
We will download the SQL script (there is also for Oracle) of the KB de VMware 1025914.
We will have to stop the vCenter services if we have them started.
We will previously make a backup of the DB that we are going to reduce.
The limits of the databases would be 4Gb in SQLExpress 2005, 10Gb in SQL Express 2008R2 or higher and 2Gb in MSDE database.
We open the SQL Management Console and perform a new query against the vCenter DB, paste the contents of the script .sql and modify the parameter 'SET @CUTOFF_DATE = GETUTCDATE()-XX’ to the days we want to keep or 'SET @CUTOFF_DATE = YYYY/MM/DD’ to set a specific date for you.
We will test before we have everything right, and we'll be able to run this statement to see how many rows would be affected.
And we modified 'SET @DELETE_DATA’ of 0 a 1 to perform such deletions in the DB & We run again.
This process will be slow, depending on the volume to be removed and the size of our database, We check at the end of the rows deleted from the history table, In my case he will have eliminated 578343!
Now at the DB level we must reduce it since we have freed up gaps, this will compact the DB and also reduce the DB files, for this, About the BD > “Tasks” > “Reduce…” > “Database”.
Click on “Accept” and wait as long as the database shrinks.
And nothing, we can see in this case that it reduced it from 4Gb to 500Mb approximately!