Thursday, March 29, 2012

And tonight it's small scale VCenter DB maintenance.

A customer of mine wanted to use VMWare VCenter 4.1 a while back, so I installed and configured it for them following their specifications. Of course, I monitor the living daylights out of it too. Tonight vpxd started failing repeatedly. A quick check into this shows that the DB is full. The error message in question is quite literally "CREATE DATABASE or ALTER DATABASE failed because the resulting cumulative database size would exceed your licensed limit of 4096 MB per database."


Now given that it's using SQL express instead of a full SQL install, that's pretty understandable. However, my joy stemmed from the fact that I couldn't run the stored procedures to clean it up (DB was literally too full), so I wound up having to clean the DB using a script from VMWare's help site, specifically the one found here. If you haven't already done so, you'll need to install Microsoft SQL Server Management Studio Express. It's fairly simple and straight forward. Once you're finished, you'll need to run the sql script you downloaded earlier. Make sure you are logged in with the right permissions, otherwise the script will fail repeatedly. Also, make sure you select the correct DB before running the script.


There is one gotcha with the script, you do need the change at least one parameter, possibly more depending on how much data you want to clear.


-- ######### USER CONFIGURABLE PARAMETERS ########################
-- 0 = COUNT ONLY; 1 = DELETE ROWS
SET @DELETE_DATA = 0
-- Use one of these methods to specifiy the data cutoff date
SET @CUTOFF_DATE = GETUTCDATE()-180
--SET @CUTOFF_DATE = '2007/01/01'

-- Number of rows to delete per transaction
SET @BATCH_SIZE = 10000

-- ######### END USER CONFIGURABLE PARAMETERS ####################

Make sure you change @DELETE_DATA to 1, otherwise this script won't do anything. I also had to change the cutoff date calculation to 30 due to the fact that I had a lot of activity in the last 3 months. And I do mean a lot- over 6 million entries.


I shouldn't have been surprised by this, but it came nearly 6 months sooner than I expected it to. Good luck with your own maintenance!

No comments:

Post a Comment