Purge and Shrink vCenter Database

How to Shrink vCenter Database

This articles describes how to purge old data from your vCenter DB and shrink vCenter database files in order to free up space; running out of disk space brings a whole host of potential problems with complete outage in a worst case scenario.

This example shows a Windows 2008 v5.5 vCenter server running a MSSQL database and is broken down into five  procedures:

  1. Stop the vCenter Server service – very important otherwise major corruption will occur!
  2. Set the retention policy on your vCenter server – optional
  3. Purge old data from your existing database using MS SQL Server Manager
  4. Shrink database using MS SQL Server Manager
  5. Restart the vCenter Server service

As with all operations of this nature, a full backup / snapshot of your database is advised before proceeding!

Stop vCenter Service

  • Open your services configuration pane in your favourite server management console snap-in, locate the VMware VirtualCenter Server service, right-click and choose “Stop” –  this may take a few minutes to complete.

stop vcenter service

Set Retention Policy

  • In the vSphere client, click “Administration” and then “Database Retention Policy” in the newly-opened window.

vcenter settings

  • Here you can select the length of time your logs will be kept for before an automatic purge is executed.

db retention policy settings

Purge Old Data

Once you have set your retention policy you can purge your old data.

  • Open a new query in MS SQL Server Manager and paste in the contents of the sql script on the link below.

open a new query

  • Click “Execute” to run the script. By default, the script will only count the rows of data which can  be deleted – do this as a first dry run before committing to deletion.

execute script

  • Once you have performed the above test, change the value of DELETE_DATA to 1 and then click “Execute” – the script may return a “non-updateable” error which can be safely ignored.
  • Download the script: VCDB_table_cleanup_MSSQL

 

Shrink vCenter Database

  • Open MS SQL Server Manager and locate the database (default: VIM_VCDB) in Object Explorer, right-click -> Tasks -> Shrink -> Database]

shrink vcenter database

Restart vCenter Service

  • In the services configuration pane, right-click “VMware VirtualCenter Server” and choose “Start” – again this may take a minute or two to complete. When done, test that you can log Back in with either the web gui or vSphere client.

start vcenter service

 

 

 

VMWare: How to Set ESXi Sytem Time Using NTP

Once we have set the system and hardware clocks via the CLI, we can move on to set ESXi sytem time using NTP on the vSphere Client:
This is very easily achieved by following these steps from the VMware knowledge base:
  1. Connect to the ESX/ESXi host using the vSphere Client.
  2. Select a host in the inventory.
  3. Click the Configuration tab.
  4. Click Time Configuration.
  5. Click Properties.
  6. Click Options.
  7. Click NTP Settings.
  8. Click Add.
  9. Enter the NTP Server name. For example, pool.ntp.org.

    Note: When entering the multiple NTP Server names, use a comma (,) followed by a space ( ) between the entries.

  10. Click OK.
  11. Click the General tab.
  12. Click Start automatically under Startup Policy.

    Note: It is recommended to set the time manually prior to starting the service.

  13. Click Start and click OK.
  14. Click OK to exit.

esxiad02[1]

Debian Jessie – su, sudo and Wheel Group

Allow Users to su With the Wheel Group or sudo

Users in Jessie are not allowed to su by default and the Wheel group (whose members are allowed to su) is not created by default. Should this be a requirement, follow the steps here to set it up:

Restrict ‘su’ execution

Login as root and uncomment the line below in /etc/pam.d/su, by removing the leading ‘#’.

#auth       required pam_wheel.so

This means that no user can execute su anymore and is the most secure configuration.

Create the Wheel Group

Create the group wheel with root privileges:

# groupadd wheel

Add User to Wheel Group

# usermod -aG wheel <user>

<user> can now execute su.

Optionally (and Insecurely) Trust Users in Wheel

This will put users in the wheel group directly into root without prompting for a password. Edit the /etc/pam.d/su file again and uncomment the following line:

#auth       sufficient pam_wheel.so trust