Quantcast
Channel: VMware Communities: Message List - vCenter™ Server
Viewing all articles
Browse latest Browse all 15787

Re: Database Retention policy

$
0
0

Here is the full plan I put together for my project im working on to reduce our vcenter DB size:

 

vCenter Database Reduction

 

Checklist before starting

  1. Full database backup of vCenter database
  2. vCenter service MUST be STOPPED

   

Reducing the size of the vCenter Server database

Please note that running the below scripts on the vCenter database will clear ALL historical data, please make sure you have a FULL verified backup of the database.

 

Step 1

  • Make sure you have a FULL BACKUPof vCenter DATABASE!!!
  • Make sure that the VMWare Virtual Center service is stopped.

   

Step 2

The largest tables in the vCenter database are the table named:

  1. VPX_HIST_STAT [1-4] tables and corresponding
  2. VPX_SAMPLE_TIME [1-4] tables.

  Truncate these tables by executing the follow commands: 

  • Truncate table VPX_HIST_STAT1_n  (1-4)
  • Truncate table VPX_SAMPLE_TIME1 (1-4)
  • Truncate table VPX_TEMPTABLE0
  • Truncate table VPX_TEMPTABLE1
  • Truncate table VPX_TEMPTABLE2

   

Step 3

  1. Log into the vCenter server database using SQL management Studio
  2. Copy and paste the contents of the SQL_truncate_5.x.sql script into SQL Management studio
  3. Make sure the correct database is selected
  4. Execute the script to delete the data

   

Step 4

Run the VCDB_Purge_MSSQL script now, it should finish immediately, telling you, it did not find any records to process.

 

Step 5

If you haven’t tweaked the “Database Retention Policy” settings under the vCenter Server Settings, it is a good idea to do this also.

  • Under vCenter database > Tables > Right-Click the dbo.VPX_PARAMETER table and click Open.
  • Modify event.maxAge to 30 (or another reasonable value), and modify the event.maxAge.Enabled value to true.
  • Modify task.maxAge to 30, and modify the task.maxAgeEnabled value to true.

  It is recommended that you jump down from 180 days in increments or you will fill up the Transaction Log , you can then run the below procedure and repeat the above to changing the days in increments. 

 

Steps:

  1. Run stored procedure below
  2. Run transaction log backup
  3. Shrink trans database

See below for full instructions on steps

 

 

Step 6

Run the built-in stored procedure:

  • Navigate to Programmability > Stored Procedures.
  • Right-click dbo.cleanup_events_tasks_proc and click Execture Stored Procedure.

   

Script below:

 

USE [Vmtest_vcenterdb]

GO

 

DECLARE                @return_value int

 

EXEC       @return_value = [dbo].[cleanup_events_tasks_proc]

 

SELECT    'Return Value' = @return_value

 

GO

 

 

  • This purges the data from the vpx_event, vpx_event_arg, and vpx_task tables based on the date specified for maxAge.
  • The last action is to shrink the database files. Right-click the vCenter database > Tasks > Shrink > Database

   

Note: You can run the below script on the database if shrink is taking its time to run through to check the progress:

 

SELECT

                    percent_complete,

                    start_time,

                    status,

                    command,

                    estimated_completion_time,

                    cpu_time,

                    total_elapsed_time

FROM

                    sys.dm_exec_requests

WHERE

                    command = 'DbccFilesCompact'

 

Step 7

Run the rollup scripts using these steps:

  • Using SQL Management studio, connect to the SQL database for vCenter Server.
  • Navigate to SQL Server Agent > Jobs
  • Select the individual rollup jobs, right-click and select Start Job at Step.

   

Step 8

Start-up VMWare Virtual Center Server service and perform some health checks on the system.

 

Back out plan

 

  1. Restore backup file over existing database and remap users

Viewing all articles
Browse latest Browse all 15787

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>