Jephe Wu - http://linuxtechres.blogspot.com
Environment: SQL server 2008 Express edition on vcenter server, no SSMS installed by default
Objective: learn how to truncate sql server database size in SQL Server Management Studio so that it won't exceed 10G limit, otherwise, database engine service will stop after 10G.
Steps:
1. check the current database size
run the following query in new query window in SSMSE
exec sp_spaceused
2. stop Vmware VirtualCenter Service
Just click on Vmware VirtualCenter Server, then stop it, then it will also stop some other services due to dependency.
4. Backup data and log files for database VIM_SQLEXP somewhere else
Must make sure database service is stopped first then take backup.
Must make sure database service is stopped first then take backup.
5. Install SSMS
Install locally on the same server or copy 2 database files over to another server which has SSMS installed.
Install locally on the same server or copy 2 database files over to another server which has SSMS installed.
refer to http://blogs.msdn.com/b/bethmassi/archive/2011/02/18/step-by-step-installing-sql-server-management-studio-2008-express-after-visual-studio-2010.aspx for installation
During installation of SSMS, choose 'Perform a new installation of SQL Server 2008' as follows:
During installation of SSMS, choose 'Perform a new installation of SQL Server 2008' as follows:
Use SSMSE to connect to local Vcenter SQL express database
If you copied data .mdf and log .ldf files to another server which has SSMS installed, then attach database then choose those 2 copied files
When you attach database to another full edition of SQL server, SQL server must be the same version as original vcenter database
7. Check tables disk usage
Right click on database VIM_VCDB, reports, standard reports, disk usage by table to check table disk usage, normally, VPX_EVENT table should be very big.
8. Change event.maxage and task.maxAge to 7 days if it's not set yet. You may also set to 30 days as per suggested by Vmware KB
go to dbo.VPX.PARAMETER table to edit event.maxAge to 7 days, and also for task.maxAge.
Note: this step might take around one hour time, be patient, do not touch anything once click
When this has successfully completed, close SQL Management Studio and start the VMware Virtual Center Server service.
Right click on database VIM_VCDB, reports, standard reports, disk usage by table to check table disk usage, normally, VPX_EVENT table should be very big.
8. Change event.maxage and task.maxAge to 7 days if it's not set yet. You may also set to 30 days as per suggested by Vmware KB
go to dbo.VPX.PARAMETER table to edit event.maxAge to 7 days, and also for task.maxAge.
9. To truncate the data in the
VPX_EVENT
table:- Connect to
SQL Database
and log in with the appropriate credentials. - Expand databases ,VIM_VCDB ,Tables.
- Right-click the dbo.VPX_PARAMETER table and click Open.
- Modify event.maxAge to 7, and modify the event.maxAgeEnabled value to true.
- Modify task.maxAge to 7, and modify the task.maxAgeEnabled value to true.
- Run the built-in stored procedure:
- Connect to
- Navigate to VIM_VCDB - Programmability - Stored Procedures.
- Right-click dbo.cleanup_events_tasks_proc and click Execute Stored Procedure.
- This purges the data from the
vpx_event
,vpx_event_arg
, andvpx_task
tables based on the date specified for maxAge.
Note: this step might take around one hour time, be patient, do not touch anything once click
10. truncate all performance tables - optional
right click on VIM_VCDB database, new query, then paste the following code to truncate all performance tables.
refer to http://kb.vmware.com/selfservice/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1007453
refer to http://kb.vmware.com/selfservice/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1007453
right click database, tasks, Shrink - database
12. References